POST /v1/teams/{teamId}/billing/subscriptions
Checkout Fase 91 (attach+create numa call)
- Acesso: Admin da equipe
- Serviço:
https://api-billing.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`.
Is the Fase 91 "checkout" endpoint. Two flows collapse into this handler:
1. Team has no active subscription AND no payment method — the UI first opens the AddPaymentMethodModal, attaches via the Stripe endpoints above, then POSTs here with the fresh pm_id. We persist it as a payment_methods row (mirroring teamAttachStripePaymentMethod) and create the subscription. 2. Team already has a payment method — UI just POSTs {plan_id, billing_cycle[, payment_method_id]}. We skip the card dance and go straight to subscription creation.
Payload: {plan_id, billing_cycle, payment_method_id?}. The handler reuses teamUpgradeSubscription's logic for the create step so both endpoints stay behaviourally identical at the "add subscription" seam.
Parâmetros
| Nome | Em | Tipo | Obrigatório | Descrição |
|---|---|---|---|---|
teamId | path | string | sim |
Corpo da requisição
application/json · Obrigatório
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
plan_id | string<uuid> | sim | |
billing_cycle | string | não | enum: |
payment_method_id | string<uuid> | não | UUID de payment_methods (não Stripe pm_*) |
{
"plan_id": "00000000-0000-0000-0000-000000000000",
"billing_cycle": "monthly",
"payment_method_id": "00000000-0000-0000-0000-000000000000"
}Respostas
200
upgrade em vez de create
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
ok | boolean | não | |
id | string<uuid> | não | |
mode | string | não | enum: |
proration | BillingProrationResult | não | |
proration.change_kind | string | não | enum: |
proration.credit_cents | integer | não | |
proration.charge_cents | integer | não | |
proration.net_cents | integer | não | |
proration.invoice_id | string<uuid> | null | não | |
proration.proration_item_id | string<uuid> | não |
201
subscription criada
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
ok | boolean | não | |
id | string<uuid> | não | |
mode | string | não | enum: |
400
input inválido
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
401
Sem credencial valida
| 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
| 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://api-billing.axuz.net/v1/teams/TEAM_ID/billing/subscriptions' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"plan_id":"00000000-0000-0000-0000-000000000000","billing_cycle":"monthly","payment_method_id":"00000000-0000-0000-0000-000000000000"}'Node.js
const res = await fetch("https://api-billing.axuz.net/v1/teams/TEAM_ID/billing/subscriptions", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"plan_id": "00000000-0000-0000-0000-000000000000",
"billing_cycle": "monthly",
"payment_method_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://api-billing.axuz.net/v1/teams/TEAM_ID/billing/subscriptions",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"plan_id": "00000000-0000-0000-0000-000000000000",
"billing_cycle": "monthly",
"payment_method_id": "00000000-0000-0000-0000-000000000000",
},
timeout=30,
)
res.raise_for_status()
print(res.json())