POST /api/sms/phones
Opt-in de um telefone e envio de OTP inline via Twilio.
- 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`.
Valida E.164; rate limit 3/h/user; UPSERT em user_phones — reenviar pro mesmo número refresha OTP; se Twilio configurado envia inline (sem fila) — falha vira 502.
Parâmetros
Sem parâmetros.
Corpo da requisição
application/json · Obrigatório
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
phone | string | sim | E.164 obrigatório ( |
{
"phone": "+15550001111"
}Respostas
201
Telefone cadastrado (OTP enviado inline se Twilio configurado).
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
id | string<uuid> | sim | |
phone | string | sim | |
verified_at | string<date-time> | null | não | |
verification_expires_at | string<date-time> | null | não | |
is_primary | boolean | sim | |
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
Twilio recusou o envio.
| 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/sms/phones' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"phone":"+15550001111"}'Node.js
const res = await fetch("https://messaging-api.axuz.net/api/sms/phones", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"phone": "+15550001111"
}),
});
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/sms/phones",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"phone": "+15550001111",
},
timeout=30,
)
res.raise_for_status()
print(res.json())