curl --request POST \
--url https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"template": {
"id": "4061e74e-f6fe-4072-a760-3aec0b64f7a6",
"parameters": {
"delivery_date": "3 de octubre",
"order_number": "A-10492"
},
"media": {
"type": "IMAGE",
"mediaId": "9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10",
"url": "https://cdn.example.com/promo/spring-sale.png"
}
}
}
'import requests
url = "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template"
payload = { "template": {
"id": "4061e74e-f6fe-4072-a760-3aec0b64f7a6",
"parameters": {
"delivery_date": "3 de octubre",
"order_number": "A-10492"
},
"media": {
"type": "IMAGE",
"mediaId": "9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10",
"url": "https://cdn.example.com/promo/spring-sale.png"
}
} }
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
template: {
id: '4061e74e-f6fe-4072-a760-3aec0b64f7a6',
parameters: {delivery_date: '3 de octubre', order_number: 'A-10492'},
media: {
type: 'IMAGE',
mediaId: '9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10',
url: 'https://cdn.example.com/promo/spring-sale.png'
}
}
})
};
fetch('https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template' => [
'id' => '4061e74e-f6fe-4072-a760-3aec0b64f7a6',
'parameters' => [
'delivery_date' => '3 de octubre',
'order_number' => 'A-10492'
],
'media' => [
'type' => 'IMAGE',
'mediaId' => '9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10',
'url' => 'https://cdn.example.com/promo/spring-sale.png'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template"
payload := strings.NewReader("{\n \"template\": {\n \"id\": \"4061e74e-f6fe-4072-a760-3aec0b64f7a6\",\n \"parameters\": {\n \"delivery_date\": \"3 de octubre\",\n \"order_number\": \"A-10492\"\n },\n \"media\": {\n \"type\": \"IMAGE\",\n \"mediaId\": \"9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10\",\n \"url\": \"https://cdn.example.com/promo/spring-sale.png\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"template\": {\n \"id\": \"4061e74e-f6fe-4072-a760-3aec0b64f7a6\",\n \"parameters\": {\n \"delivery_date\": \"3 de octubre\",\n \"order_number\": \"A-10492\"\n },\n \"media\": {\n \"type\": \"IMAGE\",\n \"mediaId\": \"9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10\",\n \"url\": \"https://cdn.example.com/promo/spring-sale.png\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template\": {\n \"id\": \"4061e74e-f6fe-4072-a760-3aec0b64f7a6\",\n \"parameters\": {\n \"delivery_date\": \"3 de octubre\",\n \"order_number\": \"A-10492\"\n },\n \"media\": {\n \"type\": \"IMAGE\",\n \"mediaId\": \"9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10\",\n \"url\": \"https://cdn.example.com/promo/spring-sale.png\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"conversationId": "7d4a1f2e-3b5c-4d6e-8f9a-0b1c2d3e4f5a",
"messageId": "b6cf1c4a-2b1e-4e63-8f3e-0f9d1a2a1234",
"templateId": "4061e74e-f6fe-4072-a760-3aec0b64f7a6",
"templateName": "order_shipped_promo"
}Send a template
Send one WhatsApp provider template into an existing conversation, as one message read by every WhatsApp Contact of
the conversation. The sender is the API key, shown in Bridge with its sender name. To start a conversation with a
template, use POST /bridge/api/v1/workspaces/{workspaceId}/conversations with onboardingTemplates.
The conversation must be active, not handled by an Agent, and have a WhatsApp Contact. Send the template by
template.id, approved for the line and language of every WhatsApp Contact, with template.parameters keyed as
GET /bridge/api/v1/workspaces/{workspaceId}/templates/{templateId} returns them.
A marketing or utility template is refused while a Contact of the conversation is inside the workspace’s promotional
cooldown: 409 BRIDGE_CONVERSATION_0406, with the wait in seconds in Retry-After. It also opens a conversation that
has no opening template yet. The Idempotency-Key header is required and kept for 24 hours: the same key with the
same send answers 201 with Idempotent-Replayed: true and sends nothing again. A 201 means Bridge stored the message
for sending; see Responses and retries.
Every 4xx error code is listed under the responses. What to do for each one: Send a template.
curl --request POST \
--url https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"template": {
"id": "4061e74e-f6fe-4072-a760-3aec0b64f7a6",
"parameters": {
"delivery_date": "3 de octubre",
"order_number": "A-10492"
},
"media": {
"type": "IMAGE",
"mediaId": "9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10",
"url": "https://cdn.example.com/promo/spring-sale.png"
}
}
}
'import requests
url = "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template"
payload = { "template": {
"id": "4061e74e-f6fe-4072-a760-3aec0b64f7a6",
"parameters": {
"delivery_date": "3 de octubre",
"order_number": "A-10492"
},
"media": {
"type": "IMAGE",
"mediaId": "9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10",
"url": "https://cdn.example.com/promo/spring-sale.png"
}
} }
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
template: {
id: '4061e74e-f6fe-4072-a760-3aec0b64f7a6',
parameters: {delivery_date: '3 de octubre', order_number: 'A-10492'},
media: {
type: 'IMAGE',
mediaId: '9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10',
url: 'https://cdn.example.com/promo/spring-sale.png'
}
}
})
};
fetch('https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template' => [
'id' => '4061e74e-f6fe-4072-a760-3aec0b64f7a6',
'parameters' => [
'delivery_date' => '3 de octubre',
'order_number' => 'A-10492'
],
'media' => [
'type' => 'IMAGE',
'mediaId' => '9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10',
'url' => 'https://cdn.example.com/promo/spring-sale.png'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template"
payload := strings.NewReader("{\n \"template\": {\n \"id\": \"4061e74e-f6fe-4072-a760-3aec0b64f7a6\",\n \"parameters\": {\n \"delivery_date\": \"3 de octubre\",\n \"order_number\": \"A-10492\"\n },\n \"media\": {\n \"type\": \"IMAGE\",\n \"mediaId\": \"9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10\",\n \"url\": \"https://cdn.example.com/promo/spring-sale.png\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"template\": {\n \"id\": \"4061e74e-f6fe-4072-a760-3aec0b64f7a6\",\n \"parameters\": {\n \"delivery_date\": \"3 de octubre\",\n \"order_number\": \"A-10492\"\n },\n \"media\": {\n \"type\": \"IMAGE\",\n \"mediaId\": \"9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10\",\n \"url\": \"https://cdn.example.com/promo/spring-sale.png\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-connect-us.bridge.new/bridge/api/v1/workspaces/{workspaceId}/conversations/{conversationId}/send-template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template\": {\n \"id\": \"4061e74e-f6fe-4072-a760-3aec0b64f7a6\",\n \"parameters\": {\n \"delivery_date\": \"3 de octubre\",\n \"order_number\": \"A-10492\"\n },\n \"media\": {\n \"type\": \"IMAGE\",\n \"mediaId\": \"9b2f6a52-1f3c-4a53-8f58-3c6a2e7d1b10\",\n \"url\": \"https://cdn.example.com/promo/spring-sale.png\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"conversationId": "7d4a1f2e-3b5c-4d6e-8f9a-0b1c2d3e4f5a",
"messageId": "b6cf1c4a-2b1e-4e63-8f3e-0f9d1a2a1234",
"templateId": "4061e74e-f6fe-4072-a760-3aec0b64f7a6",
"templateName": "order_shipped_promo"
}Headers
Required. A key you choose for each send, 1 to 255 characters, such as your system's operation id. Send the same key to retry that send: for 24 hours Bridge answers with the message the first request stored instead of sending again.
1 - 255"erp-order-981-shipped"
Path Parameters
Body
Response
Bridge stored the message for sending, or an earlier request with the same Idempotency-Key did. See Responses and retries.
The message Bridge stored for sending the template into the conversation.
Was this page helpful?

