POST /api/sms/phones
Opt-in de um telefone e envio de OTP inline via Twilio.
- Access: Signed in
- Service:
https://messaging-api.axuz.net
Accepted authentication
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.
Parameters
No parameters.
Request body
application/json · Required
| Name | Type | Required | Description |
|---|---|---|---|
phone | string | yes | E.164 obrigatório ( |
{
"phone": "+15550001111"
}Responses
201
Telefone cadastrado (OTP enviado inline se Twilio configurado).
| Name | Type | Required | Description |
|---|---|---|---|
id | string<uuid> | yes | |
phone | string | yes | |
verified_at | string<date-time> | null | no | |
verification_expires_at | string<date-time> | null | no | |
is_primary | boolean | yes | |
created_at | string<date-time> | yes |
400
Body inválido ou parâmetro fora do esperado.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
401
Falta cookie/bearer ou X-Axuz-Internal.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
429
Rate limit por user excedido.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
500
Falha inesperada no server.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
502
Twilio recusou o envio.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
Examples
"Try it" is turned off in this reference. Use the examples with your test credential.
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())