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.
Headers
Section titled “Headers”Idempotency-Key string
Send one so a retry doesn’t send the message twice. See Retrying safely.
1 to 255 characters.
How it works
Section titled “How it works”Choosing the customer
Section titled “Choosing the customer”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.
Which number it's sent from
Section titled “Which number it's sent from”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.
Quoting a message
Section titled “Quoting a message”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.
The window is per number
Section titled “The window is per number”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.
Closed chats
Section titled “Closed chats”Sending anything but a template reopens a closed chat and sends chat.reopened.
Sending a template
Section titled “Sending a template”- 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_idis required. - Send exactly the keys in the template’s
variables, no more and no fewer. Read them withGET /v1/templates. - A template with an image, video or document header needs its file in
header.media_idorheader.url. A header file must be JPEG or PNG (image), MP4 or 3GPP (video), or PDF (document). - For an authentication template,
bodyis{"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 aPRODUCTheader, up to 30 for one with anMPMbutton (asskusunder its header, or in titledsections), and 2 to 10 for a carousel of product cards. Each SKU must be in Soosh’s copy of the catalog.
Sending a file
Section titled “Sending a file”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.
Sending products
Section titled “Sending products”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_fielduntil it’s fetched again from the catalog settings. - Leave out
catalog_idto use the number’s catalog. A number with no catalog, or acatalog_idnot connected to it, isinvalid_field. - WhatsApp sends product messages only inside the 24-hour window.
Returns
Section titled “Returns”201 The message object. The message, in status: pending. Nothing is saved when a check fails.
Errors
Section titled “Errors”Besides the ones every request can get:
window_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.invalid_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.template_paramsThe template’s variables are missing or extra. details.missing and details.unexpected say which.template_ambiguousTwo of your numbers have a template with that name and language, and you sent no number_id.contact_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.idempotency_mismatchThe Idempotency-Key was used before for a different request, or by another of your API keys.