Criar fatura
curl --request POST \
--url https://api.upag.io/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer": {},
"items": [
{}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer: {}, items: [{}]})
};
fetch('https://api.upag.io/v1/invoices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.upag.io/v1/invoices';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer: {}, items: [{}]})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Faturas
Criar fatura
Cria uma fatura a partir de preços, como rascunho ou já aberta
POST
https://api.upag.io
/
v1
/
invoices
Criar fatura
curl --request POST \
--url https://api.upag.io/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer": {},
"items": [
{}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer: {}, items: [{}]})
};
fetch('https://api.upag.io/v1/invoices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.upag.io/v1/invoices';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customer: {}, items: [{}]})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Cria uma fatura para um cliente a partir de preços. Sem
Veja Erros para o formato.
open, ela nasce como draft e você ainda pode mexer nos itens; com open: true, já nasce open e pronta para pagar.
Permissão: invoice.write. Apenas chave secreta (sk_…).
Os exemplos usam o sandbox (
https://api.upag.dev/v1). Em produção use https://api.upag.io/v1 com sk_live_….Endpoint
curl -X POST https://api.upag.dev/v1/invoices \
-H "Authorization: Bearer sk_test_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"customer": "8c1f0a26-5d3b-4f1e-9c72-1a4e6b9d0f83",
"description": "Consultoria de setembro",
"dueDate": "2026-10-20T00:00:00.000Z",
"items": [
{ "price": "3a7e9c14-6b2d-4f85-9e10-5c8d2a7b4f61", "quantity": 2 }
],
"open": true
}'
import { Upag } from 'upag';
const upag = new Upag('sk_test_your_api_key');
const invoice = await upag.invoices.create({
customer: '8c1f0a26-5d3b-4f1e-9c72-1a4e6b9d0f83',
description: 'Consultoria de setembro',
dueDate: '2026-10-20T00:00:00.000Z',
items: [{ price: '3a7e9c14-6b2d-4f85-9e10-5c8d2a7b4f61', quantity: 2 }],
open: true,
});
Parâmetros
array
required
Pelo menos um item. Todos os preços precisam estar na mesma moeda, que passa a ser a da fatura.
price(obrigatório): UUID do preço.quantity(obrigatório): inteiro ≥ 1.
amount e o name do item são copiados do preço neste momento; mudar o preço depois não altera a fatura.string | null
Até 500 caracteres.
string | null
Vencimento em ISO 8601.
Resposta
201 Created
Response
{
"id": "5b0e8d3a-9c71-4e26-a8f4-1d7c3b6e9a02",
"customer": "8c1f0a26-5d3b-4f1e-9c72-1a4e6b9d0f83",
"paymentMethod": null,
"subscription": null,
"status": "open",
"currency": "brl",
"description": "Consultoria de setembro",
"amountDue": 9900,
"amountPaid": 0,
"attemptCount": 0,
"dueDate": "2026-10-20T00:00:00.000Z",
"paidAt": null,
"items": [
{
"id": "e4a1c7f8-2b95-4d03-8e6a-9f1b5d0c3a74",
"product": "7d2b5e90-1c34-4a68-b9f7-0e3a6c8d1f25",
"price": "3a7e9c14-6b2d-4f85-9e10-5c8d2a7b4f61",
"name": "Plano mensal",
"amount": 4950,
"quantity": 2,
"totalAmount": 9900
}
],
"discounts": [],
"payments": [],
"createdAt": "2026-10-07T19:00:00.000Z",
"updatedAt": "2026-10-07T19:00:00.000Z"
}
Erros
| Status | Código | Quando |
|---|---|---|
404 | CUSTOMER_NOT_FOUND | O cliente não existe na conta |
404 | PRICE_NOT_FOUND / PRODUCT_NOT_FOUND | O preço, ou o produto dele, não existe na conta |
400 | INVOICE_CURRENCY_MISMATCH | Os preços têm moedas diferentes |
422 | VALIDATION_FAILED | items vazio, UUID inválido, quantity < 1 etc. |