POST /api/push/subscribe
Upsert de push subscription (por endpoint).
- Acesso: Membro da equipe
- 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`.
UPSERT ON CONFLICT (endpoint) — a subscription do browser expira no refresh do token FCM; duplicar rows inflaria fanout e manteria subs mortas ativas. Reseta disabled_at e failure_count no upsert.
Parâmetros
Sem parâmetros.
Corpo da requisição
application/json · Obrigatório
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
endpoint | string<uri> | sim | Endpoint FCM/APNs devolvido pelo pushManager.subscribe. |
keys | MessagingPushKeys | sim | |
keys.p256dh | string | sim | Base64url — chave pública ECDH do browser. |
keys.auth | string | sim | Base64url — secret auth do browser. |
user_agent | string | não | |
team_id | string<uuid> | null | não |
{
"endpoint": "https://example.test/",
"keys": {
"p256dh": "string",
"auth": "string"
},
"user_agent": "string",
"team_id": "00000000-0000-0000-0000-000000000000"
}Respostas
201
Subscription criada/renovada.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
id | string<uuid> | 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 |
403
Sem permissao (nao e owner/admin; token sem escopo; token de integracao em rota nao permitida)
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
429
Limite de requisições excedido.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
500
Erro interno. Tente de novo com backoff; reporte o X-Request-Id.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
503
VAPID não configurado.
| 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/push/subscribe' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"endpoint":"https://example.test/","keys":{"p256dh":"string","auth":"string"},"user_agent":"string","team_id":"00000000-0000-0000-0000-000000000000"}'Node.js
const res = await fetch("https://messaging-api.axuz.net/api/push/subscribe", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"endpoint": "https://example.test/",
"keys": {
"p256dh": "string",
"auth": "string"
},
"user_agent": "string",
"team_id": "00000000-0000-0000-0000-000000000000"
}),
});
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/push/subscribe",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"endpoint": "https://example.test/",
"keys": {
"p256dh": "string",
"auth": "string",
},
"user_agent": "string",
"team_id": "00000000-0000-0000-0000-000000000000",
},
timeout=30,
)
res.raise_for_status()
print(res.json())