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"
}Enviar plantilla
Envía una plantilla de proveedor de WhatsApp a una conversación existente, como un único mensaje que leen todos los contactos de WhatsApp de la conversación. El remitente es la API key, que Bridge muestra con su nombre de remitente. Para iniciar una conversación con una plantilla, usa POST /bridge/api/v1/workspaces/{workspaceId}/conversations con onboardingTemplates.
La conversación debe estar activa, no atendida por un Agente y tener un contacto de WhatsApp. Envía la plantilla por template.id, aprobada para la línea y el idioma de cada contacto de WhatsApp, con template.parameters indexados como los devuelve GET /bridge/api/v1/workspaces/{workspaceId}/templates/{templateId}.
Una plantilla de marketing o de utilidad se rechaza mientras un contacto de la conversación está dentro del periodo de espera promocional del workspace: 409 BRIDGE_CONVERSATION_0406, con la espera en segundos en Retry-After. También abre una conversación que aún no tiene plantilla inicial. El encabezado Idempotency-Key es obligatorio y se conserva 24 horas: la misma clave con el mismo envío responde 201 con Idempotent-Replayed: true y no vuelve a enviar nada. Un 201 significa que Bridge guardó el mensaje para enviarlo; consulta Respuestas, errores y reintentos.
Todos los códigos de error 4xx aparecen en las respuestas. Qué hacer con cada uno: Envía una plantilla a una conversación existente.
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"
}Autorizaciones
Encabezados
Obligatorio. Una clave que eliges para cada envío, de 1 a 255 caracteres, como el id de operación de tu sistema. Envía la misma clave para reintentar ese envío: durante 24 horas Bridge responde con el mensaje que guardó la primera solicitud en lugar de enviar de nuevo.
1 - 255"erp-order-981-shipped"
Parámetros de ruta
Cuerpo
Respuesta
Bridge guardó el mensaje para enviarlo, o lo hizo una solicitud anterior con la misma Idempotency-Key. Consulta Respuestas y reintentos.
El mensaje que Bridge guardó para enviar la plantilla a la conversación.
¿Esta página le ayudó?

