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
| Name | In | Type | Required | Description |
|---|---|---|---|---|
teamId | path | string | yes |
Request body
application/json · Required
| Name | Type | Required | Description |
|---|---|---|---|
payment_method_id | string | yes | Stripe pm_* id retornado pelo Elements |
make_default | boolean | no |
{
"payment_method_id": "string",
"make_default": true
}Responses
201
attached
| Name | Type | Required | Description |
|---|---|---|---|
id | string<uuid> | no | |
provider_method_id | string | no | |
brand | string | no | |
last4 | string | no | |
exp_month | integer | no | |
exp_year | integer | no | |
is_default | boolean | no |
400
input inválido
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
401
Sem credencial valida
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
403
Sem permissao (nao e owner/admin; token sem escopo; token de integracao em rota nao permitida)
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
429
Limite de requisições excedido.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
500
erro interno
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
502
falha do Stripe
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
503
Stripe não configurado
| 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://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())