Building
Templates and consent
# Templates and consent
A template is a WhatsApp message with set wording that Meta approves before you can send it. You need one in two cases:
1. To message a customer who has never written to you.
2. To message a customer whose last message is more than 24 hours old.
Instagram has no templates.
## Listing templates
`GET /v1/templates` returns the number's approved templates, each with its `name`, `language`, `category`, `parameters` and `body`.
```javascript Node.js
import { Airbox } from "@airboxhq/api";
const client = new Airbox(process.env.AIRBOX_API_KEY);
const { data, error } = await client.templates.list();
if (error) {
throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}
console.log(data);
```
```php PHP
<?php
require __DIR__.'/vendor/autoload.php';
$client = new Airbox\Client(getenv('AIRBOX_API_KEY'));
$data = $client->templates->list();
print_r($data);
```
```python Python
import os
from airboxhq import Airbox
client = Airbox(api_key=os.environ["AIRBOX_API_KEY"])
data = client.templates.list()
print(data)
```
```go Go
package main
import (
"context"
"fmt"
"os"
"github.com/airboxhq/airbox-go"
)
func main() {
client := airbox.NewClient(os.Getenv("AIRBOX_API_KEY"))
data, err := client.Templates.List(context.Background())
if err != nil {
panic(err)
}
fmt.Println(data)
}
```
```csharp .NET
using Airbox;
var client = new AirboxClient(Environment.GetEnvironmentVariable("AIRBOX_API_KEY"));
var data = await client.Templates.ListAsync();
Console.WriteLine(data);
```
```rust Rust
use airboxhq::Airbox;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Airbox::new(std::env::var("AIRBOX_API_KEY")?);
let data = client.templates().list().await?;
println!("{data:#?}");
Ok(())
}
```
```bash cURL
curl -X GET https://crm.fintelligence.kz/api/v1/templates \
-H "Authorization: Bearer YOUR_API_KEY"
```
## Sending one
Name the template and its language, and give a value for each placeholder in `parameters`, in their order. A template with named placeholders takes an object by name instead. Values are strings, up to 100 of them, each up to 1,024 characters.
```javascript Node.js
import { Airbox } from "@airboxhq/api";
const client = new Airbox(process.env.AIRBOX_API_KEY);
const { data, error } = await client.templates.send("order_ready", {
to: "+77011234567",
language: "ru",
parameters: [
"Asel",
"1042",
],
}, { idempotencyKey: "order-1042-reminder" });
if (error) {
throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}
console.log(data);
```
```php PHP
<?php
require __DIR__.'/vendor/autoload.php';
$client = new Airbox\Client(getenv('AIRBOX_API_KEY'));
$data = $client->templates->send('order_ready', [
'to' => '+77011234567',
'language' => 'ru',
'parameters' => [
'Asel',
'1042',
],
], ['idempotency_key' => 'order-1042-reminder']);
print_r($data);
```
```python Python
import os
from airboxhq import Airbox
client = Airbox(api_key=os.environ["AIRBOX_API_KEY"])
data = client.templates.send(
"order_ready",
to="+77011234567",
language="ru",
parameters=[
"Asel",
"1042",
],
idempotency_key="order-1042-reminder",
)
print(data)
```
```go Go
package main
import (
"context"
"fmt"
"os"
"github.com/airboxhq/airbox-go"
)
func main() {
client := airbox.NewClient(os.Getenv("AIRBOX_API_KEY"))
data, err := client.Templates.Send(context.Background(), "order_ready", airbox.SendTemplateParams{
To: "+77011234567",
Language: "ru",
Parameters: []string{"Asel", "1042"},
}, airbox.WithIdempotencyKey("order-1042-reminder"))
if err != nil {
panic(err)
}
fmt.Println(data)
}
```
```csharp .NET
using Airbox;
var client = new AirboxClient(Environment.GetEnvironmentVariable("AIRBOX_API_KEY"));
var data = await client.Templates.SendAsync(
"order_ready",
new SendTemplateParams
{
To = "+77011234567",
Language = "ru",
Parameters = new List<string> { "Asel", "1042" },
},
new RequestOptions { IdempotencyKey = "order-1042-reminder" });
Console.WriteLine(data);
```
```rust Rust
use airboxhq::Airbox;
use airboxhq::models::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Airbox::new(std::env::var("AIRBOX_API_KEY")?);
let data = client
.templates()
.send(
"order_ready",
SendTemplate {
to: "+77011234567".into(),
language: "ru".into(),
parameters: Some(vec!["Asel", "1042"].into()),
..Default::default()
},
)
.idempotency_key("order-1042-reminder")
.await?;
println!("{data:#?}");
Ok(())
}
```
```bash cURL
curl -X POST https://crm.fintelligence.kz/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order-1042-reminder" \
-H "Content-Type: application/json" \
-d '{
"to": "+77011234567",
"channel": "whatsapp",
"type": "template",
"template": {
"name": "order_ready",
"language": "ru",
"parameters": [
"Asel",
"1042"
]
}
}'
```
A missing or empty value gets `422 template_parameters`, and a name or language Meta has not approved gets `422 template_not_found`.
## Recording consent
Consent is a WhatsApp matter, as only WhatsApp lets you write first. Before a template goes to a number that has never written to the workspace, record that the customer agreed to hear from you. Without it the response is `422 no_consent`.
```javascript Node.js
import { Airbox } from "@airboxhq/api";
const client = new Airbox(process.env.AIRBOX_API_KEY);
const { data, error } = await client.contacts.grantConsent("+77011234567");
if (error) {
throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}
console.log(data);
```
```php PHP
<?php
require __DIR__.'/vendor/autoload.php';
$client = new Airbox\Client(getenv('AIRBOX_API_KEY'));
$data = $client->contacts->grantConsent('+77011234567');
print_r($data);
```
```python Python
import os
from airboxhq import Airbox
client = Airbox(api_key=os.environ["AIRBOX_API_KEY"])
data = client.contacts.grant_consent("+77011234567")
print(data)
```
```go Go
package main
import (
"context"
"fmt"
"os"
"github.com/airboxhq/airbox-go"
)
func main() {
client := airbox.NewClient(os.Getenv("AIRBOX_API_KEY"))
data, err := client.Contacts.GrantConsent(context.Background(), "+77011234567")
if err != nil {
panic(err)
}
fmt.Println(data)
}
```
```csharp .NET
using Airbox;
var client = new AirboxClient(Environment.GetEnvironmentVariable("AIRBOX_API_KEY"));
var data = await client.Contacts.GrantConsentAsync("+77011234567");
Console.WriteLine(data);
```
```rust Rust
use airboxhq::Airbox;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Airbox::new(std::env::var("AIRBOX_API_KEY")?);
let data = client.contacts().grant_consent("+77011234567").await?;
println!("{data:#?}");
Ok(())
}
```
```bash cURL
curl -X POST https://crm.fintelligence.kz/api/v1/contacts/%2B77011234567/consent \
-H "Authorization: Bearer YOUR_API_KEY"
```
When the customer changes their mind, `DELETE /v1/contacts/{phone}/consent` withdraws it. A customer who asked not to be written to gets `422 opted_out` when you write first.
## New customers a day
Meta limits how many new customers a number writes to first in a rolling 24 hours, from 50 to 100,000 by the number's tier. `limits.new_customers_per_day` in `GET /v1/channels` shows the number now, and a send beyond it gets `422 messaging_limit`. Answers to customers who wrote in the last 24 hours do not count.
Updated 4 December 2026
A template is a WhatsApp message with set wording that Meta approves before you can send it. You need one in two cases:
- To message a customer who has never written to you.
- To message a customer whose last message is more than 24 hours old.
Instagram has no templates.
Listing templates
GET /v1/templates returns the number's approved templates, each with its name, language, category, parameters and body.
import { Airbox } from "@airboxhq/api";
const client = new Airbox(process.env.AIRBOX_API_KEY);
const { data, error } = await client.templates.list();
if (error) {
throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}
console.log(data);
Sending one
Name the template and its language, and give a value for each placeholder in parameters, in their order. A template with named placeholders takes an object by name instead. Values are strings, up to 100 of them, each up to 1,024 characters.
import { Airbox } from "@airboxhq/api";
const client = new Airbox(process.env.AIRBOX_API_KEY);
const { data, error } = await client.templates.send("order_ready", {
to: "+77011234567",
language: "ru",
parameters: [
"Asel",
"1042",
],
}, { idempotencyKey: "order-1042-reminder" });
if (error) {
throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}
console.log(data);
A missing or empty value gets 422 template_parameters, and a name or language Meta has not approved gets 422 template_not_found.
Recording consent
Consent is a WhatsApp matter, as only WhatsApp lets you write first. Before a template goes to a number that has never written to the workspace, record that the customer agreed to hear from you. Without it the response is 422 no_consent.
import { Airbox } from "@airboxhq/api";
const client = new Airbox(process.env.AIRBOX_API_KEY);
const { data, error } = await client.contacts.grantConsent("+77011234567");
if (error) {
throw new Error(`${error.code}: ${error.message} (${error.requestId})`);
}
console.log(data);
When the customer changes their mind, DELETE /v1/contacts/{phone}/consent withdraws it. A customer who asked not to be written to gets 422 opted_out when you write first.
New customers a day
Meta limits how many new customers a number writes to first in a rolling 24 hours, from 50 to 100,000 by the number's tier. limits.new_customers_per_day in GET /v1/channels shows the number now, and a send beyond it gets 422 messaging_limit. Answers to customers who wrote in the last 24 hours do not count.