POST /api/whatsapp/subscribe
Opt-in WhatsApp — envia OTP via template `axuz_otp`.
- Acesso: Login
- Serviço:
https://messaging-api.axuz.net
Autenticação aceita
sessionCookie— Sessão plena Axuz (cookie de sessão da casa). Sessão restrita é 403 enrollment_required.bearerSession— JWT de acesso da sessão em `Authorization: Bearer`.
WhatsApp Cloud exige template pré-aprovado; sem creds a subscription nem é criada (503). Rate limit compartilhado com SMS (3/h/user).
Parâmetros
Sem parâmetros.
Corpo da requisição
application/json · Obrigatório
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
phone | string | sim |
{
"phone": "+5511999998888"
}Respostas
201
Subscription criada (OTP enviado).
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
id | string<uuid> | sim | |
phone_e164 | string | sim | |
verified_at | string<date-time> | null | não | |
opted_in_at | string<date-time> | null | não | |
verification_expires_at | string<date-time> | null | não | |
created_at | string<date-time> | sim |
400
Body inválido ou parâmetro fora do esperado.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
401
Falta cookie/bearer ou X-Axuz-Internal.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
429
Rate limit por user excedido.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
500
Falha inesperada no server.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
502
Meta recusou o envio (rollback do OTP na row).
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
503
WHATSAPP_TOKEN/PHONE_ID não configurados.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
Exemplos
O "Try it" está desligado nesta referência. Use os exemplos com a sua credencial de teste.
curl
curl -sS -X POST 'https://messaging-api.axuz.net/api/whatsapp/subscribe' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"phone":"+5511999998888"}'Node.js
const res = await fetch("https://messaging-api.axuz.net/api/whatsapp/subscribe", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"phone": "+5511999998888"
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());Python
import os
import requests
res = requests.request(
"POST",
"https://messaging-api.axuz.net/api/whatsapp/subscribe",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"phone": "+5511999998888",
},
timeout=30,
)
res.raise_for_status()
print(res.json())