Crea una plantilla y la envía a Meta para aprobación
curl --request POST \
--url https://api-v2.sofiachat.com/api/v1/templates \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"integrationId": 12,
"name": "recordatorio_cita",
"language": "es_MX",
"category": "UTILITY",
"bodyText": "Hola {{nombre}}, tu cita es el {{fecha}}.",
"bodyExamples": {
"nombre": "Juan",
"fecha": "3 de agosto"
},
"footerText": "Equipo de Sofia Chat",
"buttons": [
{
"type": "URL",
"text": "Confirmar cita",
"url": "https://sofiachat.com/citas"
}
]
}
'import requests
url = "https://api-v2.sofiachat.com/api/v1/templates"
payload = {
"integrationId": 12,
"name": "recordatorio_cita",
"language": "es_MX",
"category": "UTILITY",
"bodyText": "Hola {{nombre}}, tu cita es el {{fecha}}.",
"bodyExamples": {
"nombre": "Juan",
"fecha": "3 de agosto"
},
"footerText": "Equipo de Sofia Chat",
"buttons": [
{
"type": "URL",
"text": "Confirmar cita",
"url": "https://sofiachat.com/citas"
}
]
}
headers = {
"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: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
integrationId: 12,
name: 'recordatorio_cita',
language: 'es_MX',
category: 'UTILITY',
bodyText: 'Hola {{nombre}}, tu cita es el {{fecha}}.',
bodyExamples: {nombre: 'Juan', fecha: '3 de agosto'},
footerText: 'Equipo de Sofia Chat',
buttons: [{type: 'URL', text: 'Confirmar cita', url: 'https://sofiachat.com/citas'}]
})
};
fetch('https://api-v2.sofiachat.com/api/v1/templates', 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-v2.sofiachat.com/api/v1/templates",
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([
'integrationId' => 12,
'name' => 'recordatorio_cita',
'language' => 'es_MX',
'category' => 'UTILITY',
'bodyText' => 'Hola {{nombre}}, tu cita es el {{fecha}}.',
'bodyExamples' => [
'nombre' => 'Juan',
'fecha' => '3 de agosto'
],
'footerText' => 'Equipo de Sofia Chat',
'buttons' => [
[
'type' => 'URL',
'text' => 'Confirmar cita',
'url' => 'https://sofiachat.com/citas'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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-v2.sofiachat.com/api/v1/templates"
payload := strings.NewReader("{\n \"integrationId\": 12,\n \"name\": \"recordatorio_cita\",\n \"language\": \"es_MX\",\n \"category\": \"UTILITY\",\n \"bodyText\": \"Hola {{nombre}}, tu cita es el {{fecha}}.\",\n \"bodyExamples\": {\n \"nombre\": \"Juan\",\n \"fecha\": \"3 de agosto\"\n },\n \"footerText\": \"Equipo de Sofia Chat\",\n \"buttons\": [\n {\n \"type\": \"URL\",\n \"text\": \"Confirmar cita\",\n \"url\": \"https://sofiachat.com/citas\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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-v2.sofiachat.com/api/v1/templates")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"integrationId\": 12,\n \"name\": \"recordatorio_cita\",\n \"language\": \"es_MX\",\n \"category\": \"UTILITY\",\n \"bodyText\": \"Hola {{nombre}}, tu cita es el {{fecha}}.\",\n \"bodyExamples\": {\n \"nombre\": \"Juan\",\n \"fecha\": \"3 de agosto\"\n },\n \"footerText\": \"Equipo de Sofia Chat\",\n \"buttons\": [\n {\n \"type\": \"URL\",\n \"text\": \"Confirmar cita\",\n \"url\": \"https://sofiachat.com/citas\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.sofiachat.com/api/v1/templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"integrationId\": 12,\n \"name\": \"recordatorio_cita\",\n \"language\": \"es_MX\",\n \"category\": \"UTILITY\",\n \"bodyText\": \"Hola {{nombre}}, tu cita es el {{fecha}}.\",\n \"bodyExamples\": {\n \"nombre\": \"Juan\",\n \"fecha\": \"3 de agosto\"\n },\n \"footerText\": \"Equipo de Sofia Chat\",\n \"buttons\": [\n {\n \"type\": \"URL\",\n \"text\": \"Confirmar cita\",\n \"url\": \"https://sofiachat.com/citas\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyPlantillas
Crea una plantilla y la envía a Meta para aprobación
POST
/
templates
Crea una plantilla y la envía a Meta para aprobación
curl --request POST \
--url https://api-v2.sofiachat.com/api/v1/templates \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"integrationId": 12,
"name": "recordatorio_cita",
"language": "es_MX",
"category": "UTILITY",
"bodyText": "Hola {{nombre}}, tu cita es el {{fecha}}.",
"bodyExamples": {
"nombre": "Juan",
"fecha": "3 de agosto"
},
"footerText": "Equipo de Sofia Chat",
"buttons": [
{
"type": "URL",
"text": "Confirmar cita",
"url": "https://sofiachat.com/citas"
}
]
}
'import requests
url = "https://api-v2.sofiachat.com/api/v1/templates"
payload = {
"integrationId": 12,
"name": "recordatorio_cita",
"language": "es_MX",
"category": "UTILITY",
"bodyText": "Hola {{nombre}}, tu cita es el {{fecha}}.",
"bodyExamples": {
"nombre": "Juan",
"fecha": "3 de agosto"
},
"footerText": "Equipo de Sofia Chat",
"buttons": [
{
"type": "URL",
"text": "Confirmar cita",
"url": "https://sofiachat.com/citas"
}
]
}
headers = {
"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: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
integrationId: 12,
name: 'recordatorio_cita',
language: 'es_MX',
category: 'UTILITY',
bodyText: 'Hola {{nombre}}, tu cita es el {{fecha}}.',
bodyExamples: {nombre: 'Juan', fecha: '3 de agosto'},
footerText: 'Equipo de Sofia Chat',
buttons: [{type: 'URL', text: 'Confirmar cita', url: 'https://sofiachat.com/citas'}]
})
};
fetch('https://api-v2.sofiachat.com/api/v1/templates', 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-v2.sofiachat.com/api/v1/templates",
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([
'integrationId' => 12,
'name' => 'recordatorio_cita',
'language' => 'es_MX',
'category' => 'UTILITY',
'bodyText' => 'Hola {{nombre}}, tu cita es el {{fecha}}.',
'bodyExamples' => [
'nombre' => 'Juan',
'fecha' => '3 de agosto'
],
'footerText' => 'Equipo de Sofia Chat',
'buttons' => [
[
'type' => 'URL',
'text' => 'Confirmar cita',
'url' => 'https://sofiachat.com/citas'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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-v2.sofiachat.com/api/v1/templates"
payload := strings.NewReader("{\n \"integrationId\": 12,\n \"name\": \"recordatorio_cita\",\n \"language\": \"es_MX\",\n \"category\": \"UTILITY\",\n \"bodyText\": \"Hola {{nombre}}, tu cita es el {{fecha}}.\",\n \"bodyExamples\": {\n \"nombre\": \"Juan\",\n \"fecha\": \"3 de agosto\"\n },\n \"footerText\": \"Equipo de Sofia Chat\",\n \"buttons\": [\n {\n \"type\": \"URL\",\n \"text\": \"Confirmar cita\",\n \"url\": \"https://sofiachat.com/citas\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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-v2.sofiachat.com/api/v1/templates")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"integrationId\": 12,\n \"name\": \"recordatorio_cita\",\n \"language\": \"es_MX\",\n \"category\": \"UTILITY\",\n \"bodyText\": \"Hola {{nombre}}, tu cita es el {{fecha}}.\",\n \"bodyExamples\": {\n \"nombre\": \"Juan\",\n \"fecha\": \"3 de agosto\"\n },\n \"footerText\": \"Equipo de Sofia Chat\",\n \"buttons\": [\n {\n \"type\": \"URL\",\n \"text\": \"Confirmar cita\",\n \"url\": \"https://sofiachat.com/citas\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.sofiachat.com/api/v1/templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"integrationId\": 12,\n \"name\": \"recordatorio_cita\",\n \"language\": \"es_MX\",\n \"category\": \"UTILITY\",\n \"bodyText\": \"Hola {{nombre}}, tu cita es el {{fecha}}.\",\n \"bodyExamples\": {\n \"nombre\": \"Juan\",\n \"fecha\": \"3 de agosto\"\n },\n \"footerText\": \"Equipo de Sofia Chat\",\n \"buttons\": [\n {\n \"type\": \"URL\",\n \"text\": \"Confirmar cita\",\n \"url\": \"https://sofiachat.com/citas\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Body
application/json
ID de la integración de WhatsApp dueña de la plantilla
Example:
12
Nombre de la plantilla (se normaliza a minúsculas y guiones bajos)
Example:
"recordatorio_cita"
Código de idioma de Meta
Example:
"es_MX"
Categoría de Meta
Available options:
UTILITY, MARKETING, AUTHENTICATION Example:
"UTILITY"
Texto del cuerpo con placeholders con nombre
Example:
"Hola {{nombre}}, tu cita es el {{fecha}}."
Ejemplo por cada placeholder del cuerpo
Example:
{ "nombre": "Juan", "fecha": "3 de agosto" }
Pie de página (máx 60 caracteres, sin placeholders)
Example:
"Equipo de Sofia Chat"
Botones de la plantilla (máx 10)
Show child attributes
Show child attributes
Response
201 - undefined

