Cue Docs
APIsBroadcast API

Broadcast API - V2

The V2 Broadcasts API uses a payload-variable model. You supply a tabular payload (like a CSV) where each row is a recipient, and the template object maps column names to template variable slots via payload_variable fields with optional fallback values.

See the authentication page for how to obtain a bearer token.

Create a Broadcast

POST https://api.cuedesk.com/v2/broadcasts
Authorization: Bearer <token>
Content-Type: application/json

Examples

{
  "name": "Holiday Sale",
  "from": "447576209857",
  "scheduled_at": "2024-06-15T10:00:00Z",
  "valid_until": "2024-12-31T23:59:59Z",
  "client_unique_identifier": "abe120b4-048c-4d00-9c1a-0b01d34c583c",
  "template": {
    "name": "holiday_sale_template",
    "locale": "en",
    "header": {
      "type": "image",
      "payload_variable": "header_image_url",
      "fallback": "https://www.example.com/default-sale.jpg"
    },
    "body": {
      "payload_variables": ["first_name", "discount_code", "expiry_date"],
      "fallbacks": ["Customer", "SALE2024", "31 Dec"]
    },
    "buttons": [
      {
        "index": 0,
        "type": "URL",
        "payload_variable": "tracking_url_suffix",
        "fallback": "default"
      }
    ]
  },
  "payload": [
    {
      "identifier": "447592850122",
      "client_reference": "order-abc-123",
      "first_name": "Alex",
      "discount_code": "ALEX20",
      "expiry_date": "25 Dec",
      "header_image_url": "https://www.example.com/alex-promo.jpg",
      "tracking_url_suffix": "alex-campaign"
    },
    {
      "identifier": "27827134468",
      "client_reference": "order-def-456",
      "first_name": "Jordan",
      "discount_code": "JORDAN15",
      "expiry_date": "30 Dec"
    }
  ]
}

In this example, the second recipient does not have header_image_url or tracking_url_suffix in their payload row, so the fallback values from the template definition will be used instead.

Instead of providing recipients inline via payload, you can reference a pre-uploaded contact list by UUID:

{
  "name": "Monthly Newsletter",
  "from": "447576209857",
  "template": {
    "name": "monthly_newsletter",
    "locale": "en",
    "body": {
      "payload_variables": ["first_name"],
      "fallbacks": ["Subscriber"]
    }
  },
  "contact_list_uuid": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}

When using contact_list_uuid, the payload field should be omitted. The contact list provides the recipient identifiers and any payload variables associated with each contact.

Request Body

FieldTypeRequiredDescription
namestringNoName of the broadcast (for your reference)
fromstringYesPhone number or channel identifier used as the sender
scheduled_atdatetimeNoISO 8601 timestamp for when to send. Sends immediately if omitted
valid_untildatetimeNoISO 8601 timestamp after which undelivered messages expire. No expiry if omitted
templateobjectYesTemplate definition with payload variable mappings
payloadarrayNoArray of recipient rows (max 50,000). Each row is a key-value map
contact_list_uuidUUIDNoUUID of a pre-uploaded contact list. Alternative to payload
client_unique_identifierstringNoIdempotency key. See Retries and timeouts

Template Object

The template object defines which template to use and how payload columns map to template variable slots.

FieldTypeRequiredDescription
namestringYesName of the approved WhatsApp template
localestringYesLanguage code (e.g. en, pt_BR)
headerobjectNoHeader variable mapping
bodyobjectNoBody variable mappings
buttonsarrayNoButton variable mappings
cardsarrayNoCard definitions for carousel templates
FieldTypeRequiredDescription
typestringNoHeader media type: image, video, document, or text
payload_variablestringNoPayload column name containing the header value (URL for media, text for text headers)
fallbackstringNoDefault value used when payload_variable is missing from a recipient's row
filenamestringNoFilename for document type headers

Media hosting requirements

When a header (or fallback) points at a media URL, WhatsApp fetches the file directly from your server for each recipient. Because a broadcast can deliver to thousands of recipients in a short period, the server hosting the media must be able to handle a high volume of concurrent requests to the media resource. We recommend serving media from a CDN or object storage service built to deliver files at scale. If you use a CDN or web application firewall, make sure it won't flag this burst of requests as bot traffic and block or rate-limit WhatsApp's fetches.

Body

FieldTypeRequiredDescription
payload_variablesarray[string]NoOrdered list of payload column names. Position 0 maps to {{1}}, position 1 maps to {{2}}, etc.
fallbacksarray[string]NoPositional fallback values. Must be the same length as payload_variables if provided

Buttons

FieldTypeRequiredDescription
indexintegerYesZero-based position of the button in the template
typestringNoButton type: URL, OTP, QUICK_REPLY
payload_variablestringNoPayload column name for the button's dynamic value
fallbackstringNoDefault value when payload_variable is missing

Cards

FieldTypeRequiredDescription
indexintegerYesZero-based card position. Fully static cards can be omitted
headerobjectNoCard-level header (same structure as above)
bodyobjectNoCard-level body (same structure as above)
buttonsarrayNoCard-level buttons (same structure as above)

Payload

The payload is an array of objects where each object represents one recipient. Every row must contain an identifier key with the recipient's phone number. All other keys are custom column names referenced by payload_variable in the template definition.

KeyTypeRequiredDescription
identifierstringYesRecipient phone number with country code (no leading +)
client_referencestringNoCustom reference ID for this recipient, returned in webhook status updates (max 255 chars)
(custom keys)stringNoValues for payload variables referenced in the template

If a recipient row is missing a column referenced by a payload_variable and no fallback is defined, a warning will be generated for that recipient.

Response

200 OK

{
  "broadcast": {
    "uuid": "d3b3b3b3-3b3b-3b3b-3b3b-3b3b3b3b3b3b",
    "name": "Holiday Sale",
    "scheduled_at": "2024-06-15T10:00:00Z",
    "status": "scheduled",
    "created_at": "2024-06-01T12:00:00Z",
    "recipients": 19750
  },
  "warnings": [
    {
      "identifier": "6563546436",
      "errors": [
        "Missing payload variable 'discount_code' with no fallback defined"
      ]
    }
  ]
}
FieldTypeDescription
broadcast.uuidUUIDUnique identifier of the created broadcast
broadcast.namestringBroadcast name
broadcast.scheduled_atdatetimeScheduled send time (null if immediate)
broadcast.statusstringBroadcast status: scheduled, processing, completed, cancelled
broadcast.created_atdatetimeWhen the broadcast was created
broadcast.recipientsintegerTotal number of valid recipients
warningsarrayPer-recipient warnings for validation issues
warnings[].identifierstringRecipient phone number
warnings[].errorsarray[string]Warning messages for this recipient

Error Responses

400 Bad Request:

{
  "message": "Broadcast could not be created",
  "details": "Template 'holiday_sale_template' not found or not approved"
}

403 Forbidden:

{
  "message": "Forbidden",
  "details": "Channel does not belong to your workspace"
}

422 Unprocessable Entity:

{
  "error": {
    "message": "Validation failed",
    "details": "Template parameter count mismatch",
    "violations": [
      {
        "field": "template.body.payload_variables",
        "rule": "PARAMETER_COUNT_MISMATCH",
        "message": "Template expects 3 body parameters but 2 were provided"
      }
    ]
  }
}

504 Gateway Timeout:

{
  "detail": "The broadcast service did not answer in time. The broadcast may still have been created and sent, so do not create it again. Repeat this request with the same client_unique_identifier to check: an existing broadcast is reported, never sent again."
}

The broadcast may exist. See Retries and timeouts before you send the request again.

Retries and Timeouts

The API answers a create request only after it has saved every recipient, so a large request can take tens of seconds. Set the timeout of your HTTP client to at least 90 seconds.

Send a client_unique_identifier with every create request

client_unique_identifier is an idempotency key. Use a new value for each broadcast (a UUID, for example) and keep it until you have a response.

When you repeat a request with a client_unique_identifier that your workspace has already used, the API does not create or send a second broadcast. It returns 200 OK with the broadcast that already exists, with the same broadcast.uuid. This also applies while the first request is still being processed.

  • Only the identifier is compared, not the rest of the request. A different request with a used identifier returns the earlier broadcast.
  • If two requests with the same identifier arrive at almost the same moment, the second one can get 409 Conflict. Wait a few seconds and repeat it.
  • A request without a client_unique_identifier has no such protection: each request creates a new broadcast.

When a create request fails or times out

A 5xx response, or a timeout in your HTTP client, does not mean that the broadcast was not created. The broadcast can exist and be sent.

  1. Do not create the broadcast again as a new request, and do not change the client_unique_identifier.
  2. Repeat the same request with the same client_unique_identifier.
  3. A 200 OK response contains the broadcast: the one that the first request created, or a new one if the first request created nothing. In both cases only one broadcast exists.
  4. Use broadcast.uuid with Get Broadcast Details to see its status.

If the request had no client_unique_identifier, do not repeat it. Check the broadcasts in your workspace first.

504 Gateway Timeout

The API returns 504 Gateway Timeout when a create request takes longer than 60 seconds. The detail field says what is known:

  • The broadcast service did not answer in time. The broadcast may still have been created and sent, so do not create it again. The result is unknown. Follow the steps above.
  • The broadcast service could not be reached in time. No broadcast was created, so it is safe to send this request again. Nothing was created.

A repeat with the same client_unique_identifier is safe in both cases.

On this page