DM Champ Docs

WhatsApp Templates API

WhatsApp message templates are pre-written messages approved for sending outside the normal 24-hour conversation window: a welcome message, an appointment reminder, a re-engagement nudge. This API lets you create, edit, submit, check, delete and send them. Every field, request body and response shape is in the API Reference, linked from each row below.

All paths are relative to https://api.dmchamp.com/v1. Authenticate every request (Authentication); errors use the standard envelope in Errors & Pagination.

Note: Templates ride on the WhatsApp Business API channel, so this part of the API needs both API access and a plan that includes WhatsApp channels. Without them requests get a 403.

Working with sub-accounts (agencies)

Agencies: every endpoint on this page takes an optional sub_account_id, so you can build, submit, and send a client’s templates with your agency key. Send it as a query parameter on GET/DELETE and in the JSON body on POST/PUT. Leave it out and the request acts on your own account. See API for Agencies.

How templates work

The lifecycle. You create a template in your library, edit it while it is a draft, submit it for review, poll its status, send it once it is approved, and delete it when you no longer need it.

Approval states. Every template carries a status:

Status Meaning
draft Saved, not yet sent for review. You can still edit it.
received Submitted and accepted into the review queue.
pending Under review.
approved Cleared for sending.
rejected Turned down. rejection_reason says why; fix it and submit again.

Only draft and rejected templates can be edited or (re)submitted. An approved template is locked: create a new one if you need changes.

Auto-approval: some channels have no external review step. Templates created or submitted on such a channel are stored as approved straight away, with no content ID (sid).

Variables. Placeholders may be written {{first_name}}, {first_name} or [first_name]; all are normalized to the double-curly form. When a template is sent, each variable is filled from the contact, and the body supports:

  • Basic variables: {{first_name}}, {{email}}, {{company}}
  • Default values: {{first_name|there}} shows there if the field is empty
  • Transformations: {{company|uppercase}}, {{name|lowercase}}, {{name|capitalize}}
  • Combined: {{company|Your Company|uppercase}}

A value you pass explicitly in variables on a send wins over the contact’s field for that variable.

Authentication (one-time code) templates. WhatsApp does not accept free-text authentication templates: the body is preset by WhatsApp and the template must carry a “copy code” button. When you create a template with category: "authentication", we submit it in that fixed shape for you. Your body is kept as the preview shown in the app, but the contact receives WhatsApp’s own wording (the code, a security reminder and a 10-minute expiry note). Declare exactly one variable, for example ["code"], and pass the code in variables when you send (Send a template to a contact). The code must be shorter than 15 characters. This works the same on a managed connection and on your own Meta app.

Templates on Meta-connected accounts

The endpoints work the same whichever WhatsApp connection the account runs on, but what happens behind them differs:

  • On a managed WhatsApp connection, templates are registered with the messaging provider and sid is the provider’s content ID (HXXXXXXXX…).
  • On an account whose number runs on its own WhatsApp Business Account (either Meta connection option), templates are created and reviewed in that WhatsApp Business Account and sid is Meta’s own numeric template id, such as "3394843740694756". status uses the same values, and rejection_reason carries Meta’s explanation.

Check which connection templates run on

GET /whatsapp-templates/provider answers provider (twilio for the managed provider, meta for your own WhatsApp Business Account), lane (meta_cloud_api for your own Meta app, meta_embedded for a connection through our Meta app, null when managed), waba_id, and templates_enabled. templates_enabled: false means the Meta connection is not finished (no WhatsApp Business Account or access token stored yet); creating or submitting templates fails with a 400 until it is.

Sync templates from Meta

POST /whatsapp-templates/meta-sync refreshes the status of every template in your WhatsApp Business Account and imports any template that exists there but not in your library, so a later GET /whatsapp-templates lists them like any other. It reports imported, updated and total. Safe to call as often as you like; on a managed connection there is nothing to sync and it just reports your total.

Talking to Meta directly (advanced)

For what the library endpoints do not expose (headers, footers, buttons, a fully hand-built template), /v1/meta-templates passes your request straight to Meta’s template API without storing anything in your library. It only works on an account with its own WhatsApp Business Account; on a managed connection every call is a 400 asking you to connect a Meta app first. A template Meta refuses returns 400 with Meta’s explanation in error.

  • GET /meta-templates lists the templates on the WhatsApp Business Account; ?name= filters to one exact name.
  • POST /meta-templates creates a template and submits it for review in one step, from body or a complete components array. With category: "AUTHENTICATION" no body is needed: it is submitted in WhatsApp’s fixed one-time-code shape with a copy code button, and add_security_recommendation (default true) and code_expiration_minutes (1 to 90, adds the expiry note) are the only options.
  • DELETE /meta-templates/{name} deletes the template by its Meta name in every language. Add ?hsm_id= with Meta’s template id to remove a single language.

Endpoints

Task Method + path Reference
List templates GET /whatsapp-templates Open in API Reference
Get a template GET /whatsapp-templates/{templateId} Open in API Reference
Create a standalone template POST /whatsapp-templates/docs Open in API Reference
Update a draft or rejected template PUT /whatsapp-templates/{templateId} Open in API Reference
Submit for approval POST /whatsapp-templates/{templateId}/submit Open in API Reference
Check approval status GET /whatsapp-templates/{templateId}/status Open in API Reference
Delete a template DELETE /whatsapp-templates/{templateId} Open in API Reference
Send to a contact (by id or phone, template by id or name) POST /whatsapp-templates/send Open in API Reference
Send to an existing contact POST /whatsapp-templates/{templateId}/send-to-contact Open in API Reference
Estimate a bulk send POST /whatsapp-templates/{templateId}/estimate-bulk-cost Open in API Reference
Bulk-send POST /whatsapp-templates/{templateId}/bulk-send Open in API Reference
Retry a failed template message POST /whatsapp-templates/messages/{contactId}/{messageId}/retry-template Open in API Reference
Retry any failed message POST /whatsapp-templates/messages/{contactId}/{messageId}/retry Open in API Reference
Which connection templates run on GET /whatsapp-templates/provider Open in API Reference
Sync from Meta POST /whatsapp-templates/meta-sync Open in API Reference
List Meta templates directly GET /meta-templates Open in API Reference
Create a Meta template directly POST /meta-templates Open in API Reference
Delete a Meta template directly DELETE /meta-templates/{name} Open in API Reference
Save the WhatsApp Business profile PUT /whatsapp-templates/profile Open in API Reference
Upload a profile picture POST /whatsapp-templates/profile/picture Open in API Reference
Check a sender’s status GET /whatsapp-templates/sender-status/{phoneNumber} Open in API Reference
Generate follow-up templates with AI POST /agents/{agentId}/template-generation Open in API Reference
Bring a campaign’s approved template into the library POST /whatsapp-templates/from-campaign Open in API Reference
Deprecated: set a campaign’s opening template POST /whatsapp-templates Open in API Reference
Deprecated: create a live campaign’s template POST /whatsapp-templates/campaign/{campaignId} Open in API Reference
Deprecated: edit a live campaign’s template PUT /whatsapp-templates/campaign/{campaignId} Open in API Reference
Deprecated: campaign follow-up generation job POST /campaigns/{campaignId}/template-generation Open in API Reference
Older: start follow-up generation in the background POST /whatsapp-templates/campaign/{campaignId}/generate-async Open in API Reference
Older: generate a campaign’s follow-ups now POST /whatsapp-templates/campaign/{campaignId}/generate-followups Open in API Reference
Older: generate an Agent’s follow-ups now POST /whatsapp-templates/agent/{agentId}/generate-followups Open in API Reference

List templates

GET /whatsapp-templates returns every template on the account with a short summary (id, name, status, language, body). GET /whatsapp-templates/{templateId} returns the full record, including variables, sid, type, category, rejection_reason and timestamps. A template that is not on your account is a 404.

Create a template

POST /whatsapp-templates creates a template in your library and submits it for review in the same call, so the response already carries the outcome: on a WhatsApp Business API number status is received or pending plus a template_sid; on a channel without external review it is approved at once (status: "approved", template_sid: null). Every call makes its own template, and you send it by name or by the returned template_id once it is approved. campaign_id is optional and only links the template; a linked campaign with no WhatsApp channel creates nothing (status: "not_applicable"). campaign_status repeats status for older integrations. To set an agent’s opening message instead, use POST /whatsapp-templates/campaign/{campaignId}.

To store a draft first and submit later, use the standalone create below.

Create a standalone template

Creates a library template without a review result in the response: as a draft, or queued for review in the background.

curl -X POST "https://api.dmchamp.com/v1/whatsapp-templates/docs?apiKey=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "welcome_message",
    "language": "en",
    "body": "Hi {{first_name}}, thanks for reaching out!",
    "variables": ["first_name"],
    "status": "draft",
    "category": "marketing"
  }'

The response returns the new template_id and its status.

Good to know

  • status: "draft" (the default) only stores it. status: "submitted" queues it for WhatsApp review straight away, in the background: check the status endpoint for the outcome rather than expecting it in the response.
  • The body is limited to 1024 characters. type is general (default) or smart_followup; category is marketing, utility, authentication (see the one-time code note above) or authentication-international.
  • campaign_id is optional here; one that is not yours is a 404.

Update, submit, check, delete

  • Update (PUT /whatsapp-templates/{templateId}): only draft or rejected templates. Send any of name, body, language, variables; only what you send changes. Editing does not resubmit: call submit afterwards. Editing an approved template, or sending no fields, is a 400.
  • Submit (POST /whatsapp-templates/{templateId}/submit): for draft or rejected templates. On a channel without external review it is approved at once; otherwise it goes to WhatsApp and the returned status (usually received or pending) is stored. Follow-up templates must declare and use their required variables before they can be submitted: a first-name placeholder, plus a personal-context placeholder for smart follow-ups.
  • Check approval status (GET /whatsapp-templates/{templateId}/status): a light call for polling. It reads the stored record, which is refreshed in the background, so a very recent approval or rejection can take a short while to show.
  • Delete (DELETE /whatsapp-templates/{templateId}): on a managed connection only the stored record is removed, and content WhatsApp already approved may stay registered with the messaging provider. On an account with its own WhatsApp Business Account the template is deleted there too. Either way, switch any broadcast, automation or follow-up that uses the template to another one before deleting, or the sends that rely on it fail.

Send a template to a contact

POST /whatsapp-templates/send sends an approved template even when there is no open conversation, which reopens the chat session. Target the contact by contactId or phoneNumber (looked up, or created with the optional firstName, lastName, email), and pick the template by whatsappTemplateId or templateName.

curl -X POST "https://api.dmchamp.com/v1/whatsapp-templates/send?apiKey=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: my-message-123" \
  -d '{
    "phoneNumber": "+31612345678",
    "templateName": "login_code",
    "variables": { "code": "482913" }
  }'

Good to know

  • Credits: on a number the platform manages, a template send costs credits, depending on the recipient’s country and the template’s category. On a number on your own Twilio account or your own Meta app the provider bills you directly and the template costs 0 credits.
  • Retries without double sends: send an Idempotency-Key header with a unique value per send. A retry with the same key after a successful send gets the first response back, and nothing is sent or charged again; a retry while the first call is still running gets 409. A call that sent nothing frees the key, so a retry with it runs normally.
  • Every variable must end up with a value. A variable your variables map does not fill and the contact’s fields cannot fill (a numbered {{1}} never comes from the contact) is a 400 that lists them in missing_variables; nothing is sent or charged. This also holds for a template created without a variables list: its numbered placeholders count as its variables.
  • A template WhatsApp rejected is a 400 with the rejection reason (template_status: "rejected"); nothing is sent or charged.
  • Neither contact identifier, or neither template identifier, is a 400. An account without the messaging credentials needed to send gets a 403.

Bring a campaign’s approved template into the library

A template approved as a campaign’s opening message lives on that campaign, so the library endpoints cannot see it by name or SID. POST /whatsapp-templates/from-campaign copies it into your library as an already-approved template with the same provider content SID, so there is nothing to resubmit. From then on it works with every library endpoint, in particular Send a template to an existing contact. It replaces sending a campaign’s template through the deprecated Campaigns API.

curl -X POST "https://api.dmchamp.com/v1/whatsapp-templates/from-campaign?apiKey=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "campaign_id": "campaign123" }'
  • Pass campaign_id, or a broadcast_id that mirrors a classic campaign (its campaign is resolved for you). A native broadcast is a 400, since its template is already in the library.
  • 201 when created; calling again returns the existing library template with 200 and created: false, so it is safe to run before every send.
  • A campaign that is not yours is a 404; one whose template is not approved yet is a 400.

Send a template to an existing contact

POST /whatsapp-templates/{templateId}/send-to-contact with a contactId is the simpler, path-scoped send: both the template and the contact must already exist, and nothing is looked up by name or created. Credits work as in Send a template to a contact. A contactId that is missing or not on your account is a 403; an unknown templateId is a 404.

Bulk-send a template

Estimate first, then send.

  • Estimate (estimate-bulk-cost, up to 500 contactIds, duplicates counted once): returns the cost per destination country without sending anything or moving credits. Template pricing is per country, so this is computed server-side against the real contacts. skippedContacts counts ids that were missing, not yours, or had no phone number; a non-zero value means the real send reaches fewer contacts than you selected.
  • Send (bulk-send, up to 5000 contactIds): sends to every contact, resolving smart variables per contact and charging credits per send. A contact that fails (not found, not yours, a send error) is skipped and counted in failed, and the batch carries on. The response reports sent, failed and total.
curl -X POST "https://api.dmchamp.com/v1/whatsapp-templates/template_abc123/bulk-send?apiKey=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "contactIds": ["contact123", "contact456"] }'

Retry a failed message

Both retry endpoints resend a failed message without creating a new message record or spending credits again, and take no body.

  • .../retry-template is for a failed template message only (status failed, type template). It re-resolves the template content from the campaign when the failed message does not carry it.
  • .../retry works on any channel (for example WhatsApp Web) and sends through the right path for the message’s channel. It accepts status failed, failed_connection, limit_exceeded or queued_retry.

A message whose status is not eligible, or (on retry-template) is not a template message, is a 400; a missing contact or message is a 404.

WhatsApp Business profile

Manage the profile contacts see on WhatsApp (about, address, description, email, websites, business category, logo), on both a managed connection and your own WhatsApp Business Account. Setting the photo takes two calls: POST /whatsapp-templates/profile/picture with a public fileUrl downloads the image, uploads it to WhatsApp and returns a handle in data. It does not set the photo by itself: pass that handle as profilePictureHandle to PUT /whatsapp-templates/profile. phoneNumber must be a number connected on your account, and every entry in websites must be a valid URL. The picture upload is a 400 when the number has no WhatsApp access token on file, and an unreachable or invalid fileUrl comes back as an error saying why the download failed.

Check a sender’s status

GET /whatsapp-templates/sender-status/{phoneNumber} checks (and refreshes) a connected WhatsApp number’s live sending status with the provider, to confirm it can actually send before you rely on it. data is ONLINE (sending normally), PENDING (still being verified) or DELETED (the provider no longer recognizes the sender: reconnect the number). A number with no WhatsApp business information on file is a 404.

Generate follow-up templates with AI

The platform can write an AI Agent’s WhatsApp follow-up templates for you (the nudges sent when a conversation goes quiet) from the Agent’s own instructions and goal. All generation endpoints use AI credits.

curl -X POST "https://api.dmchamp.com/v1/agents/ag7HkQ2ZpLxR3mNb/template-generation?apiKey=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "type": "all" }'

type is all (default, the whole set) or cold_only (only the messages for contacts who never replied). The target field tells you how it came back:

  • target: "agent" with 200: the usual case. The templates were written during the call; read them from the Agent’s follow_up_config (Get an Agent).
  • target: "campaign" with 202: the work was queued against the legacy campaign in campaign_id. Watch that campaign’s template_generation_status: status is processing, then completed or failed (with error, for example not enough credits); progress runs 0 to 100; current_template of total_templates counts up to 11 for an outgoing or combined campaign, 9 otherwise.

Generated templates show up in List templates and still need WhatsApp approval before they can be sent. cold_only needs an outgoing campaign and is a 409 on an Agent without one. The campaign-addressed form, POST /campaigns/{campaignId}/template-generation, still works but is deprecated with the rest of the Campaigns API.

The older generation endpoints are kept so existing integrations keep running; new code should use the job above. They need automatic follow-ups on the account and enough credits (a 400 names which is missing), and the campaign-addressed ones are a 403 for another account’s campaign.

  • .../campaign/{campaignId}/generate-async runs in the background (202), charges credits up front (skipped on an account that brings its own AI key) and reports progress in the same template_generation_status.
  • .../campaign/{campaignId}/generate-followups writes all nine follow-ups during the call, for a campaign created before automatic follow-ups existed or one that needs them rewritten.
  • .../agent/{agentId}/generate-followups does the same by Agent: target is "campaign" when written onto the Agent’s campaign, "agent" (with campaign_id: null) when the Agent has none and they were stored on the Agent.

Create or update a campaign’s live template

Deprecated. Part of the Campaigns API, which stops answering after 31 December 2026. For new work, submit a broadcast’s template with POST /broadcasts/{broadcastId}/template, or create a standalone template and select it on the broadcast.

POST and PUT /whatsapp-templates/campaign/{campaignId} create and edit a campaign’s opening template, scoped by path. Unlike Create a template, an edit here also re-submits the campaign’s follow-up drafts for review (on a WhatsApp API campaign), so the opening template and its follow-ups stay in sync. variables is required (an empty array if none). PUT on a campaign without a template is a 400; a campaign not on your account is a 404, and one belonging to another account you are not authorized for is a 403.

Templates API errors

A 404 usually means the resource does not exist or belongs to another account. A few endpoints (the campaign-scoped create and update, and sends to an existing contact) answer 403 instead when the campaign or contact belongs to someone else. Some responses also carry an error_code mirroring the HTTP status. The shared codes (400, 401, 403, 429, 500) and retry guidance are in Errors & Pagination.

Next steps