# 30646: Failed to Upsert Consent

Log Type: APPLICATION

Log Level: ERROR

## Description

This error occurs when a bulk consent upsert contains one or more invalid consent fields, or when the upsert fails because of an internal server error. Twilio maps validation failures to the submitted `correlation_id` so you can identify which consent object failed.

### Possible causes

* `INVALID_CORRELATION_ID`. The `correlation_id` value is not a valid unique 32-character UUID for the request item.
* `INVALID_SENDER_ID`. The `sender_id` value is not a valid Messaging Service SID or a valid From phone number.
* `INVALID_CONTACT_ID`. The `contact_id` value is not a valid phone number in `E.164` format.
* `INVALID_STATUS`. The `status` value is not `opt-in` or `opt-out`.
* `INVALID_SOURCE`. The `source` value is not `website`, `offline`, `opt-in-message`, `opt-out-message`, or `others`.
* `INVALID_DATE_OF_CONSENT`. The `date_of_consent` value is not a valid ISO-8601 datetime, or it is set in the future.
* `INTERNAL_SERVER_ERROR`. The upsert failed because of an internal server error during processing.

### Possible solutions

* Generate a new unique 32-character UUID for each `correlation_id` so each consent object can be matched to its response item.
* Set `sender_id` to a valid Messaging Service SID or a valid From phone number. If you want consent and opt-outs synchronized across RCS, SMS, and MMS, use a Messaging Service SID when possible.
* Format `contact_id` as a valid `E.164` phone number, such as `+14155552671`.
* Send only accepted `status` values. Use `opt-in` to record consent or re-opt-in, and use `opt-out` to record revoked consent.
* Send only accepted `source` values: `website`, `offline`, `opt-in-message`, `opt-out-message`, or `others`.
* If you provide `date_of_consent`, send it as an ISO-8601 datetime and do not use a future timestamp. If you do not have this value, omit it instead of sending an invalid date.
* If you receive an internal server error, retry the request. If the problem continues, collect at least three `correlation_id` values from the last 24 hours before contacting Support.

#### Additional resources

* [Consent Management API](/docs/messaging/features/consent-api)
* [Compliance Toolkit for Programmable Messaging](/docs/messaging/features/compliance-toolkit)
* [What is E.164?](/docs/glossary/what-e164)
