Axuz Developers

POST /teams/{teamId}/billing/payment-methods/attach

Stripe Elements — attach pm_* + mirror local

  • Access: Team admin
  • Service: https://api-billing.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`.

Finishes the Elements flow. Given a pm_* id confirmed on the client side, we attach it to the customer, mirror the card details into our local table, and optionally mark it as default (sets both our row flag + Stripe customer's invoice_settings.default_payment_method).

Parameters

NameInTypeRequiredDescription
teamIdpathstringyes

Request body

application/json · Required

NameTypeRequiredDescription
payment_method_idstringyes

Stripe pm_* id retornado pelo Elements

make_defaultbooleanno
{
  "payment_method_id": "string",
  "make_default": true
}

Responses

201

attached

NameTypeRequiredDescription
idstring<uuid>no
provider_method_idstringno
brandstringno
last4stringno
exp_monthintegerno
exp_yearintegerno
is_defaultbooleanno

400

input inválido

NameTypeRequiredDescription
errorstringyes

401

Sem credencial valida

NameTypeRequiredDescription
errorstringyes

403

Sem permissao (nao e owner/admin; token sem escopo; token de integracao em rota nao permitida)

NameTypeRequiredDescription
errorstringyes

429

Limite de requisições excedido.

NameTypeRequiredDescription
errorstringyes

500

erro interno

NameTypeRequiredDescription
errorstringyes

502

falha do Stripe

NameTypeRequiredDescription
errorstringyes

503

Stripe não configurado

NameTypeRequiredDescription
errorstringyes

Examples

"Try it" is turned off in this reference. Use the examples with your test credential.

curl

curl -sS -X POST 'https://api-billing.axuz.net/teams/TEAM_ID/billing/payment-methods/attach' \
  -H "Authorization: Bearer $AXUZ_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"payment_method_id":"string","make_default":true}'

Node.js

const res = await fetch("https://api-billing.axuz.net/teams/TEAM_ID/billing/payment-methods/attach", {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "payment_method_id": "string",
    "make_default": true
  }),
});
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/teams/TEAM_ID/billing/payment-methods/attach",
    headers={
        "Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
    },
    json={
        "payment_method_id": "string",
        "make_default": True,
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())