Skip to content

Send a message

POST /v1/messages

Checks a message and accepts it for sending; it reaches WhatsApp a moment later. Follow it with the message.sent and message.status webhooks, or with GET /v1/messages/{id}.

Needs messages:send. Counts against api_messages_per_second.

Outside the 24-hour window, only a template can be sent.

A message to send. Exactly one of to and contact_id, and the one content object that goes with type: text, media (for image, video, audio and document), template or interactive.

type string Required

One of text image video audio document template interactive.

to string

The phone number, with its country code. Spaces, dashes, dots and brackets are ignored, and 00 counts as +. Send this or contact_id, not both.

contact_id string · uuid

The contact to send to. Send this or to, not both.

number_id string · uuid

The ID of an active number in your workspace. Leave it out to let Soosh choose.

text object

For type: text.

Show 2 child parametersHide child parameters

text.body string Required

1 to 4,096 characters.

text.preview_url boolean

Show a preview of the first link in the text.

Default false.

media object

For type: image, video, audio or document. The file is exactly one of media_id and url.

Show 4 child parametersHide child parameters

media.media_id string · uuid

An upload from POST /v1/media. Send this or url, not both.

media.url string · uri

An https:// link to the file. Send this or media_id, not both.

media.caption string

A caption for the file. Not for audio.

Up to 1,024 characters.

media.filename string

For type: document. The name the customer sees.

template object

For type: template. The template, by id or by name and language, and its variables.

Show 7 child parametersHide child parameters

template.id string · uuid

The template’s ID. Send this, or name and language.

template.name string

The template’s name. Send it with language, or send id instead.

template.language string

The template’s language, such as en. Needed with name.

template.body object

Keys are the variable names in the template’s variables.body.

A map; each value is a string.

template.header object

The header’s variable as text, or the file of an image, video or document header as one of media_id and url.

Show 3 child parametersHide child parameters

template.header.text string

template.header.media_id string · uuid

template.header.url string · uri

template.buttons object

Keys are button indexes, as in the template’s variables.buttons. A value is a link’s suffix or a coupon code.

A map; each value is a string.

template.products object

For a product template only: its products by SKU, as skus or (for an MPM button) sections, and optionally catalog_id.

Show 3 child parametersHide child parameters

template.products.catalog_id string

The catalog’s WhatsApp ID. Leave it out to use the sending number’s catalog.

template.products.skus array of strings

1 to 30 items.

template.products.sections array of objects

For an MPM template, instead of skus.

1 to 10 items.

Show 2 child parametersHide child parameters

Each item:

template.products.sections[].title string Required

1 to 24 characters.

template.products.sections[].skus array of strings Required

At least 1 item.

interactive object

For type: interactive. Up to 3 reply buttons (type: buttons), one link button (type: cta_url, with url and display_text), or products from the sending number’s catalog (type: product or type: product_list).

Show 10 child parametersHide child parameters

interactive.type string Required

One of buttons cta_url product product_list.

interactive.body string

Required, except for a product message.

Up to 1,024 characters.

interactive.header string

For type: product_list, required: the heading over the products, up to 60 characters.

1 to 60 characters.

interactive.footer string

For products. Up to 60 characters.

interactive.catalog_id string

For products. The catalog’s WhatsApp ID, as Commerce Manager shows it. Leave it out to use the catalog connected to the sending number’s WhatsApp Business Account.

interactive.skus array of strings

For products. Each product’s SKU (its content ID in Commerce Manager), in the order to show them: one for product, up to 30 for product_list.

1 to 30 items.

interactive.sections array of objects

For type: product_list, instead of skus: up to 10 sections, each with a title of up to 24 characters and its skus.

Show 2 child parametersHide child parameters

Each item:

interactive.sections[].title string Required

1 to 24 characters.

interactive.sections[].skus array of strings Required

At least 1 item.

interactive.buttons array of objects

Each id is unique.

1 to 3 items.

Show 2 child parametersHide child parameters

Each item:

interactive.buttons[].id string Required

1 to 256 characters.

interactive.buttons[].title string Required

1 to 20 characters.

interactive.url string · uri

An https:// link.

interactive.display_text string

1 to 20 characters.

reply_to_message_id string · uuid

A message with the same contact, workspace and sending number to quote.

Idempotency-Key string

Send one so a retry doesn’t send the message twice. See Retrying safely.

1 to 255 characters.

A template sent to a number with no contact creates one, messaged from the sending number. That counts against your contacts limit and sends contact.created. Any other type to such a number is window_closed. A contact you deleted is brought back.

Soosh uses number_id if you send it. Otherwise it uses the template’s number, then the contact’s number, then your default number. At that final fallback, an active number is preferred over a disconnected default. An explicitly chosen inactive number is number_unavailable; a removed explicit number is invalid_field.

A number’s ID stays the same when it is renamed. Renaming keeps queued sends on that number.

reply_to_message_id must belong to the same contact, workspace and sending number. A quote from another number is 422 invalid_field on reply_to_message_id.

It counts from the contact’s last customer message to the sending number, not to your other numbers. System notices, edits, deletions, chat-open events and reactions do not open the window. If WhatsApp disagrees with Soosh’s record, the message fails later with error.code 131047.

Sending anything but a template reopens a closed chat and sends chat.reopened.

  • With number_id, the template must be that number’s. If two of your numbers have a template with the same name and language, number_id is required.
  • Send exactly the keys in the template’s variables, no more and no fewer. Read them with GET /v1/templates.
  • A template with an image, video or document header needs its file in header.media_id or header.url. A header file must be JPEG or PNG (image), MP4 or 3GPP (video), or PDF (document).
  • For an authentication template, body is {"1": "<code>"}. The code button is filled in for you.
  • A product template shows products from the sending number’s catalog, chosen for each send in template.products: one SKU for a template with a PRODUCT header, up to 30 for one with an MPM button (as skus under its header, or in titled sections), and 2 to 10 for a carousel of product cards. Each SKU must be in Soosh’s copy of the catalog.

A media_id must be an upload that hasn’t expired. Soosh downloads a url once, within 10 seconds, without following redirects, and reads the type from the file. Either way the file is kept with the message.

A product message shows products from the catalog connected to the sending number’s WhatsApp Business Account. The customer can view them, add them to a cart and send an order. type: product shows one product; type: product_list shows up to 30, under a header, as one list in skus or in up to 10 titled sections.

  • Products are named by SKU, the content ID in Commerce Manager. Each must be in Soosh’s copy of the catalog: a product added in Commerce Manager since the catalog was last fetched is invalid_field until it’s fetched again from the catalog settings.
  • Leave out catalog_id to use the number’s catalog. A number with no catalog, or a catalog_id not connected to it, is invalid_field.
  • WhatsApp sends product messages only inside the 24-hour window.

201 The message object. The message, in status: pending. Nothing is saved when a check fails.

Besides the ones every request can get:

422window_closedThe contact has no customer message to the sending number in the last 24 hours. Messages to another number, system notices, edits, deletions, chat-open events and reactions do not open the window. Send a template instead.
422invalid_phoneThe to isn’t a valid phone number.
422invalid_fieldA field breaks a rule: for example both to and contact_id, a contact_id or number_id that isn’t in your workspace, an unknown or expired media_id, a file type the message can’t carry, or a url that can’t be fetched. A reply_to_message_id from another contact, workspace or sending number is also refused.
422template_paramsThe template’s variables are missing or extra. details.missing and details.unexpected say which.
422template_ambiguousTwo of your numbers have a template with that name and language, and you sent no number_id.
422template_not_approvedThe template isn’t approved.
422contact_opted_outA marketing template goes to a contact who opted out of all marketing or of marketing from the sending number. Renaming the number preserves its opt-outs.
422number_unavailableThe number you send from isn’t active.
422limit_reachedThe number has no contact yet, and your workspace is at its contacts limit.
409idempotency_in_progressA request with the same Idempotency-Key is still running.
422idempotency_mismatchThe Idempotency-Key was used before for a different request, or by another of your API keys.