Pular para o conteúdo principal
Saia do zero a uma integração funcional com a Pagou em minutos, dando ao seu assistente de IA o contexto completo da API.

Arquivos disponíveis

A Pagou publica documentação legível por máquina seguindo o padrão aberto llms.txt:

/llms.txt

Índice conciso com títulos, descrições e links. Use para orientação rápida.

/llms-full.txt

Documentação completa em um único arquivo de texto. Use para contexto profundo e detalhado.

Configure seu assistente de IA

Carregue a documentação completa na sua conversa com um comando:
/fetch https://docs.pagou.ai/llms-full.txt
Alternativamente, cole o bloco de contexto rápido no início da conversa para uma opção mais leve.

Exemplos de prompts

Com o contexto carregado, experimente:
  • “Crie um endpoint Express que aceite pagamentos Pix usando o SDK da Pagou”
  • “Gere um fluxo completo de checkout Pix com confirmação por webhook”
  • “Mostre como criar um pagamento com cartão após receber o token do Payment Element”
  • “Implemente um fluxo de pagamento com cartão com tratamento de 3DS”
  • “Escreva um handler de webhook que processe eventos de pagamento e transferência da Pagou”
  • “Construa um serviço de ingestão de webhooks com deduplicação e processamento via fila”
  • “Implemente um fluxo de transferência Pix Out com tratamento de erros”
  • “Crie um job de reconciliação que verifica transferências pendentes”
  • “Mostre como implementar lógica de retry idempotente para transações Pagou”
  • “Configure o SDK TypeScript da Pagou com tratamento de erros adequado”

Bloco de contexto rápido

Copie e cole em qualquer assistente de IA. Cobre toda a superfície da API Pagou: endpoints, autenticação, status, webhooks, SDK e padrões de integração.
O bloco está em inglês porque LLMs processam instruções técnicas de forma mais confiável em inglês e a superfície da API (endpoints, headers, campos JSON) é em inglês.
# Pagou.ai Payment Gateway API

> Brazilian payment gateway. Pix collections, credit card payments (via Payment Element),
> Pix Out transfers (payouts), and webhooks through a REST API (v2).
> SDK: @pagouai/api-sdk (TypeScript/Node).

## Environments
- Sandbox: https://api-sandbox.pagou.ai
- Production: https://api.pagou.ai
- Docs: https://docs.pagou.ai

## Authentication
Pick one method for all requests:
- `Authorization: Bearer <token>` (recommended)
- `apiKey: <token>` header
- Basic Auth (username: `token`, password: `x`)

## Core Endpoints

### Transactions (payments)
- POST   /v2/transactions          — Create Pix or card payment
- GET    /v2/transactions          — List transactions
- GET    /v2/transactions/{id}     — Get transaction
- PUT    /v2/transactions/{id}/refund — Refund transaction

### Customers
- POST   /v2/customers             — Create customer
- GET    /v2/customers             — List customers
- GET    /v2/customers/{id}        — Get customer

### Transfers (payouts)
- POST   /v2/transfers             — Create Pix Out transfer
- GET    /v2/transfers             — List transfers
- GET    /v2/transfers/{id}        — Get transfer
- POST   /v2/transfers/{id}/cancel — Cancel transfer

## Create a Pix Payment

```bash
curl -X POST https://api-sandbox.pagou.ai/v2/transactions \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "external_ref": "order_1001",
    "amount": 1500,
    "currency": "BRL",
    "method": "pix",
    "notify_url": "https://merchant.example/webhooks/pagou",
    "buyer": {
      "name": "Ada Lovelace",
      "email": "ada@example.com",
      "document": { "type": "CPF", "number": "12345678901" }
    },
    "products": [{ "name": "Order", "price": 1500, "quantity": 1 }]
  }'
```

## Create a Card Payment
Use Payment Element (hosted iframe) for card input. Browser tokenizes the card,
then your backend calls POST /v2/transactions with the token:

```json
{
  "external_ref": "order_1002",
  "amount": 2490,
  "currency": "BRL",
  "method": "credit_card",
  "token": "pgct_token_from_browser",
  "installments": 1,
  "buyer": { ... },
  "products": [{ ... }]
}
```

## Create a Pix Out Transfer

```json
POST /v2/transfers
{
  "external_ref": "payout_9001",
  "amount": 1200,
  "currency": "BRL",
  "pix_key": "merchant@example.com",
  "recipient_name": "Ada Lovelace"
}
```

## Idempotency
Use `external_ref` as your stable idempotency key for creates.
Reuse the same value on retries for the same logical operation.
Conflicting duplicates return 409.

## Transaction Statuses
pending, processing, paid, captured, authorized, three_ds_required,
partially_paid, refunded, partially_refunded, canceled, expired,
refused, chargedback, processed, in_protest

Terminal: paid, captured, refunded, partially_refunded, canceled, expired, refused

## Transfer Statuses
created, pending, in_analysis, processing, transferred,
failed, rejected, canceled, unknown

Terminal: transferred, failed, rejected, canceled

## Webhook Events
Payment: transaction.created, transaction.pending, transaction.paid,
  transaction.cancelled, transaction.refunded, transaction.partially_refunded,
  transaction.chargedback, transaction.three_ds_required
Transfer: payout.created, payout.in_analysis, payout.processing,
  payout.transferred, payout.failed, payout.rejected, payout.canceled

## Webhook Envelopes

Payment envelope:
```json
{ "id": "...", "event": "transaction", "data": { "id": "tr_...", "event_type": "transaction.paid", "status": "paid", "amount": 1500 } }
```

Transfer envelope:
```json
{ "id": "evt_...", "type": "payout.transferred", "data": { "object": { "id": "po_...", "status": "paid", "amount": 10000 } } }
```

## TypeScript SDK

```ts
import { Client } from "@pagouai/api-sdk";

const client = new Client({
  apiKey: process.env.PAGOU_API_KEY,
  environment: "sandbox", // or "production"
});

// Create Pix payment
const tx = await client.transactions.create({
  external_ref: "order_1001",
  amount: 1500,
  currency: "BRL",
  method: "pix",
  buyer: { name: "Ada", email: "ada@example.com", document: { type: "CPF", number: "12345678901" } },
  products: [{ name: "Order", price: 1500, quantity: 1 }],
}, { idempotencyKey: "idem_order_1001" });

// Retrieve
const fetched = await client.transactions.retrieve("tr_123");

// List with auto-pagination
for await (const t of client.transactions.listAutoPagingIterator({ limit: 100 })) {
  console.log(t.id, t.status);
}

// Transfer
const transfer = await client.transfers.create({ external_ref: "po_001", amount: 1200, currency: "BRL", pix_key: "email@example.com" });
```

## Key Integration Patterns
- Acknowledge webhooks with 200 immediately, process async via queue
- Deduplicate by webhook event ID
- Reconcile with GET /v2/transactions/{id} or GET /v2/transfers/{id} when state is uncertain
- Store external_ref + Pagou resource ID + requestId
- Use notify_url (transactions) or postback_url (transfers) for per-request callbacks

## Error Handling
- 400: fix request — 401/403: fix credentials — 404: verify ID
- 409: reconcile with existing resource — 422: fix field validation
- 5xx: retry with backoff, then reconcile
- RFC 7807 problem+json errors with field-level detail

Próximos passos

Quickstart

Faça sua primeira chamada à API se ainda não começou.

SDK TypeScript

Documentação completa do SDK com exemplos reais.

Webhooks

Tratamento de eventos, envelopes e reconciliação.