Creating a Payment Session
Follow these steps to construct your request, call the API, and handle the response.Step 1: Construct the Request Body
Create a JSON object with the payment details. At a minimum, you must includecustomer, amount_total, currency, and line_items. The table below describes all the required fields for creating a payment session:
| Field | Type | Required | Description |
|---|---|---|---|
| customer | object | Yes | Object containing customer details (first_name, last_name, email). |
| amount_total | number | Yes | Total charge amount. |
| currency | string | Yes | Currency code (e.g., “MXN”). |
| line_items | array | Yes | Array of objects detailing the items in the cart (name, quantity, unit_price). |
| return_url | string | Conditional | Required if success_url is not set. Fallback redirect URL. |
| success_url | string | No | Redirect URL after successful payment. |
| external_id | string | No | Your unique identifier for the order (e.g., order ID). |
| expires_at | integer | No | Unix timestamp (seconds). Must be 30 min to 24h in future. Default 24h. |
| ui_config | object | No | Optional. An object to override the default UI settings for this session. |
Step 2: Call the API Endpoint
Send a POST request to the Create a Payment Session endpoint for your environment, including your API key as a Token in the Authorization header. This example demonstrates how to create a payment session using cURL or Node.js:Step 3: Handle the Response
If successful, Tonder returns a 201 status and the session object. The two most important fields areid (the session ID) and url (the redirect URL). Here’s an example of a successful response:
What’s Next
Now that you have created a payment session, here are the next steps:- Set up webhooks to receive real-time payment status notifications.
- Learn how to manually check payment status for reconciliation and troubleshooting.
- See the UI Configuration Fields reference for all available
ui_configcustomization options.

