POST /teams/{teamId}/billing/invoices/{invoiceId}/apply-coupon
Aplica cupom em fatura open/draft (Fase 99)
- 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`.
Exposes ApplyCouponToInvoice via POST /teams/:teamId/billing/invoices/:invoiceId/apply-coupon. Body: {"code": "SUMMER20"}. Maps ApplyCouponError codes to HTTP status: not_found → 404, expired/exhausted → 410, wrong_scope → 400, already_applied → 409, invoice_not_open → 409, invoice_not_found → 404.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
teamId | path | string | yes | |
invoiceId | path | string | yes |
Request body
application/json · Required
| Name | Type | Required | Description |
|---|---|---|---|
code | string | yes |
{
"code": "string"
}Responses
200
cupom aplicado
| Name | Type | Required | Description |
|---|---|---|---|
invoice_id | string<uuid> | no | |
coupon_id | string<uuid> | no | |
subtotal_cents | integer | no | |
discount_cents | integer | no | |
total_cents | integer | no |
400
input inválido
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
401
Sem credencial valida
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
403
fatura não é do time
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
404
recurso não encontrado
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
409
already_applied / invoice_not_open
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
410
expired / exhausted
| 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 |
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/invoices/INVOICE_ID/apply-coupon' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code":"string"}'Node.js
const res = await fetch("https://api-billing.axuz.net/teams/TEAM_ID/billing/invoices/INVOICE_ID/apply-coupon", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"code": "string"
}),
});
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/invoices/INVOICE_ID/apply-coupon",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"code": "string",
},
timeout=30,
)
res.raise_for_status()
print(res.json())