Create bulk consents

POST /v1/Consents/Bulk
application/x-www-form-urlencoded

Body

  • Items array Required

    This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: contact_id, which must be a string representing phone number in E.164 format; correlation_id, a unique 32-character UUID used to uniquely map the request item with the response item; sender_id, which can be either a valid messaging service SID or a from phone number; status, a string representing the consent status. Can be one of [opt-in, opt-out]; source, a string indicating the medium through which the consent was collected. Can be one of [website, offline, opt-in-message, opt-out-message, others]; date_of_consent, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty.

Responses

  • 201 application/json

    Created

    Hide headers attributes Show headers attributes
    • Access-Control-Allow-Origin string

      Specify the origin(s) allowed to access the resource

    • Access-Control-Allow-Methods string

      Specify the HTTP methods allowed when accessing the resource

    • Access-Control-Allow-Headers string

      Specify the headers allowed when accessing the resource

    • Access-Control-Allow-Credentials boolean

      Indicates whether the browser should include credentials

    • Access-Control-Expose-Headers string

      Headers exposed to the client

    Hide response attribute Show response attribute object
    • items

      A list of objects where each object represents the result of processing a correlation_id. Each object contains the following fields: correlation_id, a unique 32-character UUID that maps the response to the original request; error_code, an integer where 0 indicates success and any non-zero value represents an error; and error_messages, an array of strings describing specific validation errors encountered. If the request is successful, the error_messages array will be empty.

POST /v1/Consents/Bulk
curl \
 --request POST 'https://accounts.twilio.com/v1/Consents/Bulk' \
 --user "username:password" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'Items=%7B%22contact_id%22%3A%22%2B19999999999%22%2C%22correlation_id%22%3A%22ad388b5a46b33b874b0d41f7226db2ef%22%2C%22sender_id%22%3A%22MG00000000000000000000000000000001%22%2C%22date_of_consent%22%3A%222025-02-28T10%3A05%3A27Z%22%2C%22status%22%3A%22opt-out%22%2C%22source%22%3A%22website%22%7D&Items=%7B%22contact_id%22%3A%22%2B19%22%2C%22correlation_id%22%3A%2202520cfa6c432f0e3ec3a38c122d428d%22%2C%22sender_id%22%3A%22123456%22%2C%22date_of_consent%22%3A%222025-03-25%22%2C%22status%22%3A%22opt-in%22%2C%22source%22%3A%22opt-in-message%22%7D'
Request example
{"Items"=>["{\"contact_id\":\"+19999999999\",\"correlation_id\":\"ad388b5a46b33b874b0d41f7226db2ef\",\"sender_id\":\"MG00000000000000000000000000000001\",\"date_of_consent\":\"2025-02-28T10:05:27Z\",\"status\":\"opt-out\",\"source\":\"website\"}", "{\"contact_id\":\"+19\",\"correlation_id\":\"02520cfa6c432f0e3ec3a38c122d428d\",\"sender_id\":\"123456\",\"date_of_consent\":\"2025-03-25\",\"status\":\"opt-in\",\"source\":\"opt-in-message\"}"]}
Response examples (201)
{
  "items": [
    {
      "error_code": 0,
      "correlation_id": "ad388b5a46b33b874b0d41f7226db2ef",
      "error_messages": []
    },
    {
      "error_code": 30646,
      "correlation_id": "02520cfa6c432f0e3ec3a38c122d428d",
      "error_messages": [
        "INVALID_CONTACT_ID",
        "INVALID_DATE_OF_CONSENT"
      ]
    }
  ]
}