> ## Documentation Index
> Fetch the complete documentation index at: https://fortal-pay.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkouts

> Crie uma página de pagamento hospedada e redirecione o pagador.

`POST /checkouts` cria uma página de pagamento da FortalPay e requer uma API key `FULL_ACCESS`.

## Corpo mínimo

Somente `items` é obrigatório. Cada item precisa do `id` de um produto ativo e de uma `quantity` maior ou igual a `1`.

```bash theme={null}
curl --request POST 'https://api-sandbox.fortalpay.tech/v1/checkouts' \
  --header 'Authorization: ApiKey <full_access_api_key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "items": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "quantity": 1
      }
    ]
  }'
```

Nesse fluxo, o checkout retorna com status `WAITING_CUSTOMER` e coleta os dados do pagador na página hospedada.

## Corpo completo

```json theme={null}
{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "quantity": 1
    }
  ],
  "coupons": [
    "9b49b454-235f-44ae-82e8-ff46bcf75df1"
  ],
  "paymentMethods": ["PIX"],
  "customerId": "6f84d2b5-a612-4e67-8af5-69f98de980f5",
  "completionUrl": "https://seusite.com/sucesso",
  "returnUrl": "https://seusite.com/voltar",
  "externalId": "pedido-45891",
  "metadata": {
    "origem": "mobile"
  }
}
```

Quando `customerId` é informado, ele deve pertencer ao lojista. O FortalPay associa o cliente à cobrança, gera o pagamento e retorna o checkout com status `PENDING_PAYMENT`.

Resposta

```json theme={null}
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "status": "PENDING_PAYMENT",
    "total": 10000,
    "availablePaymentMethods": ["PIX"],
    "checkoutUrl": "https://pay.fortalpay.com.br/pay/3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "completionUrl": "https://seusite.com/sucesso",
    "returnUrl": "https://seusite.com/voltar",
    "externalId": "pedido-45891",
    "metadata": {
      "origem": "mobile"
    },
    "customer": {
      "name": "Maria Silva",
      "email": "maria@email.com",
      "document": "***.***.***-25",
      "phone": "85999999999"
    },
    "items": [
      {
        "productName": "Produto de exemplo",
        "unitPrice": 10000,
        "quantity": 1,
        "total": 10000
      }
    ]
  },
  "success": true,
  "error": null
}
```

Os valores `total`, `unitPrice` e `items[].total` são expressos em centavos. Redirecione o pagador para `data.checkoutUrl`.
