Axuz Developers

POST /api/sms/phones/{id}/primary

Promove telefone verified a primary.

  • 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`.

Promove um telefone verificado a primary do user.

Motivo: user com múltiplos telefones precisa decidir qual recebe notify SMS por default; atomicidade garante que sempre existe no máximo um primary. Comportamento: parse UUID; TX pgx; SELECT verified_at do target — 404 se não pertence ao user, 400 se não verificado; UPDATE is_primary=FALSE em todos telefones do user, depois UPDATE is_primary=TRUE no target; commit; devolve Phone atualizado via loadPhone.

Entradas: URLParam id.

Retorno: 200 Phone; 400/404/500.

Parameters

NameInTypeRequiredDescription
idpathstringyes

Request body

Corpo JSON. O schema detalhado deste endpoint ainda não está tipado na spec; veja a descrição da operação.

application/json

NameTypeRequiredDescription
(corpo)objectno
{}

Responses

200

Promoted.

NameTypeRequiredDescription
idstring<uuid>yes
phonestringyes
verified_atstring<date-time> | nullno
verification_expires_atstring<date-time> | nullno
is_primarybooleanyes
created_atstring<date-time>yes

400

bad id / phone_not_verified.

NameTypeRequiredDescription
errorstringyes

401

Falta cookie/bearer ou X-Axuz-Internal.

NameTypeRequiredDescription
errorstringyes

404

Recurso não existe (ou não pertence ao user).

NameTypeRequiredDescription
errorstringyes

429

Limite de requisições excedido.

NameTypeRequiredDescription
errorstringyes

500

Erro interno. Tente de novo com backoff; reporte o X-Request-Id.

NameTypeRequiredDescription
errorstringyes

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/ID/primary' \
  -H "Authorization: Bearer $AXUZ_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

Node.js

const res = await fetch("https://messaging-api.axuz.net/api/sms/phones/ID/primary", {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
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/ID/primary",
    headers={
        "Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
    },
    json={},
    timeout=30,
)
res.raise_for_status()
print(res.json())