Asaas Checkout
Create and integrate an Asaas-hosted payment page with Pix, card, subscriptions, installments, callbacks, and Webhooks.
Create a payment page hosted by Asaas to sell products, services, subscriptions, or installment plans without building your own checkout screen.
When to use Asaas Checkout
Use Asaas Checkout when your application already has a purchase flow, but you want to direct the payer to a page hosted by Asaas to complete the payment.
This model is suitable for:
- selling on e-commerce and SaaS platforms;
- accepting Pix and card in a single flow;
- creating one-off, installment, or recurring charges;
- reducing the implementation effort of the payment interface;
- redirecting the payer back to your site upon completion, cancellation, or expiration of the checkout;
- using payment splits when the sale needs to distribute amounts between accounts.
Key concepts
| Concept | What it means | When to configure |
|---|---|---|
billingTypes | Payment methods available at checkout. Accepted values: CREDIT_CARD and PIX. | Configure at least one payment method. |
chargeTypes | Type of charge the checkout will create. Accepted values: DETACHED, RECURRENT, and INSTALLMENT. | Use DETACHED for a one-off sale, RECURRENT for a subscription, or INSTALLMENT for installment payments. |
minutesToExpire | Checkout expiration time, in minutes. Minimum: 10. Maximum: 1440. | Set this when the offer, reservation, or order has a validity period. |
items | Products or services displayed on the checkout page. | Send name, quantity, value, and a Base64 image to present the sale to the payer. |
customerData | Payer data used to pre-fill the checkout. | Send this when your application already knows the customer and wants to reduce steps in the payment flow. |
callback | Redirect URLs after success, cancellation, or expiration. | Configure this to return the payer to your site. |
externalReference | Checkout identifier in your system. Maximum: 200 characters. | Use this to relate the checkout to an internal order, cart, or contract. |
subscription | Subscription data. | Required when chargeTypes includes RECURRENT. |
installment | Installment data. | Send this when chargeTypes includes INSTALLMENT. |
splits | Rules for splitting the amount between accounts. | Use this when the sale needs to automatically distribute amounts. |
Integration flow
- Create the order in your system and generate an internal identifier.
- Send a request to create the checkout with payment methods, charge type, items, customer data, and callback URLs.
- Store the
id,link,status, andexternalReferencereturned by the API. - Redirect the payer to the checkout
link. - Wait for the payer's action. Creating the checkout does not confirm payment.
- Receive Webhook events to update the financial status in your system.
- Use the
externalReferenceto reconcile the received event with the original order.
Order created in your system
↓
Create Checkout on Asaas
↓
Receive Checkout link
↓
Redirect payer
↓
Payer completes, cancels, or lets it expire
↓
Webhook reports the result
↓
System updates the orderThe callback URL improves the payer's navigation experience, but it does not replace Webhooks. Use Webhooks to confirm financial events asynchronously.
Example: creating a one-off checkout
Use this example to create a checkout with Pix and credit card for a one-off sale.
curl --request POST \
--url https://api-sandbox.asaas.com/v3/checkouts \
--header 'accept: application/json' \
--header 'access_token: $ASAAS_API_KEY' \
--header 'content-type: application/json' \
--data '{
"billingTypes": ["PIX", "CREDIT_CARD"],
"chargeTypes": ["DETACHED"],
"minutesToExpire": 60,
"externalReference": "order-1001",
"callback": {
"successUrl": "https://example.com/asaas/checkout/success",
"cancelUrl": "https://example.com/asaas/checkout/cancel",
"expiredUrl": "https://example.com/asaas/checkout/expired"
},
"items": [
{
"externalReference": "product-001",
"name": "T-shirt",
"description": "Cotton t-shirt",
"quantity": 2,
"value": 100,
"imageBase64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII="
}
],
"customerData": {
"name": "John Doe",
"cpfCnpj": "24971563792",
"email": "[email protected]",
"phone": "4738010919"
}
}'Successful response:
{
"id": "131ca662-56c8-4479-b5b3-fd61a413fce7",
"link": "https://sandbox.asaas.com/checkoutSession/show/131ca662-56c8-4479-b5b3-fd61a413fce7",
"status": "ACTIVE",
"billingTypes": ["PIX", "CREDIT_CARD"],
"chargeTypes": ["DETACHED"],
"minutesToExpire": 60,
"externalReference": "order-1001"
}After receiving this response, save the checkout id and redirect the payer to the link.
Important rules and behaviors
- Send at least one value in
billingTypesand at least one value inchargeTypes. - Configure
subscriptionwhen usingRECURRENT. - Configure
installmentwhen usingINSTALLMENT;maxInstallmentCountaccepts values from1to21. - Use
minutesToExpirebetween10and1440minutes. - Creating the checkout returns a payment page, not a financial confirmation.
- The checkout can be
ACTIVE,CANCELED,EXPIRED, orPAID. - Pix and card payments may have different confirmation timelines and behaviors.
- Webhooks use at least once delivery (the same event may arrive more than once). Implement idempotency using the event identifier.
Error handling
The API may reject checkout creation when there is invalid data or incorrect authentication.
| Status | When it occurs | How to handle |
|---|---|---|
400 Bad Request | The payload does not comply with the checkout rules, such as missing required fields or incompatible combinations. | Display an operational message, log the final payload sent, and fix the fields indicated in errors. |
401 Unauthorized | The key provided in access_token is invalid. | Check the account key and the environment used in the request. |
Validation error example:
{
"errors": [
{
"code": "error_code",
"description": "Error description"
}
]
}Invalid authentication example:
{
"errors": [
{
"code": "invalid_access_token",
"description": "The provided API key is invalid"
}
]
}Implementation best practices
- Save the
externalReferencealong with the order to reconcile events, reports, and support. - Log the final payload sent to the API in a secure environment to facilitate diagnosis of
400errors. - Do not mark the order as paid based solely on the redirect to
successUrl. - Process Webhooks idempotently to avoid duplication on resent events.
- Set an expiration time compatible with the payer's journey.
- Test in Sandbox first before releasing the checkout to production.
Related content
Updated 16 days ago
