Skip to main content
POST
Send a campaign message
Use an API key with Send campaign messages and access to this campaign. The response includes the request ID and camelCase pricing fields. For a campaign with Chosen per request, send usecase, to, and data. Send no params or media. For a campaign with one template, send no usecase. The response includes the usecase that was sent. The request is rate limited. Honor Retry-After on retryable failures. See Campaigns API for lifecycle and charging.

Hidden data

The optional data object holds values for the reply conversation. When the end user replies, the flow reads each value as {{trigger.data.<key>}}. On a campaign that sends usecases, a key the usecase maps into its template appears in the message. The recipient never sees any other key. See Read hidden data from a webhook campaign. An empty data object counts as no data.

Encrypted recipient numbers

The to field can hold the number encrypted with the incoming-numbers key of your organization. Add the key in Settings → Integrations → Encryption keys, and test a sample there before you send. For AES-256-GCM:
  • <nonce> is 12 random bytes. Use a new nonce for each message.
  • <ciphertext> is the ciphertext followed by the 16-byte authentication tag.
  • Both parts use base64url. The scheme uses no additional authenticated data.
For AES-256-CBC, the ciphertext uses PKCS#7 padding. Base64 can contain line breaks and URL-safe characters, and it can omit padding. The encrypted text is the phone number. Tars removes spaces, hyphens, parentheses, and periods. It changes a leading 00 to +, and it adds + to a value that holds only digits. The result must be a valid international number.

Validation errors

These errors use the code validation_failed, with entries in errors. See API errors.

Authorizations

Authorization
string
header
required

An API key (tars_sk_…) sent as Authorization: Bearer <key>. Each operation names the permission it needs. Create keys in Settings → Integrations → API keys.

Path Parameters

id
string
required

The id.

Required string length: 1 - 128

Body

application/json

One webhook campaign message.

to
string
required

E.164 phone number, or the number encrypted with your organization's incoming-numbers key (Settings → Integrations → Encryption keys), as AES-256-GCM v1.. or AES-256-CBC ciphertext. An encrypted value that can't be decrypted returns validation_failed with recipient_undecryptable.

params
object

Template parameters by name.

media
object

Media for the template's media header.

data
object

Data for the reply conversation, read as {{trigger.data.}}. On a usecase campaign, a key the usecase maps into its template appears in the message; the recipient never sees any other key. Up to 50 top-level keys of letters, digits and underscores that start with a letter or digit, 5 levels of nesting, and 8 KB. Nested keys use printable ASCII and can't start with $.

usecase
string

The usecase to send, for a campaign that defines usecases.

Response

The message was sent.

The message was sent and charged.

status
any
required
quotedUsd
number
required

What the send cost in US dollars.

requestId
string
required

The request id (req_…). Quote it when you contact support.

balance
number

The credit balance in US dollars after the charge.

externalMessageId
string

The provider's message id, when it returned one.

usecase
string

The usecase that was sent, when the request named one.