> For the complete documentation index, see [llms.txt](https://docs.commercelayer.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.commercelayer.io/core-api-reference/2026-05/payment_sessions/create.md).

# Create a payment session

How to create a payment session via API

To [create](https://docs.commercelayer.io/core/creating-resources) a new payment session, send a `POST` request to the `/api/2026-05/payment_sessions` endpoint, passing the resource arguments in the request body.

## Request

**POST** <https://yourdomain.commercelayer.io/api/2026-05/payment\\_sessions>

### Arguments

| Body Parameter                     | Type      | Required                                                                     |
| ---------------------------------- | --------- | ---------------------------------------------------------------------------- |
| **type**                           | `string`  | Required                                                                     |
| attributes.**amount\_cents**       | `integer` | Optional, default to the payment link amount or the order outstanding amount |
| attributes.**currency\_code**      | `string`  | Optional, default to the payment link or order currency code                 |
| attributes.**gift\_card\_code**    | `string`  | Optional, but when linked to a paymentsettinggiftcard                        |
| attributes.**token**               | `string`  | Optional                                                                     |
| attributes.**options**             | `object`  | Optional                                                                     |
| attributes.**vaulting**            | `boolean` | Optional, default is 'false'                                                 |
| attributes.**client\_data**        | `object`  | Optional                                                                     |
| attributes.**\_internal\_version** | `string`  | Optional                                                                     |
| attributes.**expires\_at**         | `string`  | Optional, default depends on the payment setting                             |
| attributes.**reference**           | `string`  | Optional                                                                     |
| attributes.**reference\_origin**   | `string`  | Optional                                                                     |
| attributes.**metadata**            | `object`  | Optional                                                                     |
| relationships.**order**            | `object`  | Optional                                                                     |
| relationships.**payment\_setting** | `object`  | Required                                                                     |
| relationships.**payment\_wallet**  | `object`  | Optional                                                                     |

### Example

{% tabs %}
{% tab title="Request" %}
The following request creates a new payment session:

```shell
curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/2026-05/payment_sessions' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "payment_sessions",
    "relationships": {
      "payment_setting": {
        "data": {
          "type": "payment_settings",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `201 Created` status code, returning the created resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "payment_sessions",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN"
    },
    "attributes": {
      "status": "unpaid",
      "amount_cents": 1000,
      "amount_float": 10.0,
      "formatted_amount": "€10,00",
      "capture_balance_cents": 1000,
      "capture_balance_float": 10.0,
      "formatted_capture_balance": "€10,00",
      "refund_balance_cents": 1000,
      "refund_balance_float": 10.0,
      "formatted_refund_balance": "€10,00",
      "percentage_amount_cents": 50.0,
      "currency_code": "USD",
      "gift_card_code": "cc92c23e-967e-48b2-a323-59add603301f",
      "token": "my-order-ref-123",
      "options": {
        "statement_descriptor": "MY SHOP"
      },
      "vaulting": true,
      "client_data": {},
      "request_data": {},
      "response_data": {},
      "additional_request_data": {},
      "additional_response_data": {},
      "payment_instrument": {
        "issuer": "cl bank",
        "card_type": "visa"
      },
      "expires_at": "2018-01-01T12:00:00.000Z",
      "balance_exceeded_at": "2018-01-01T12:00:00.000Z",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "order": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/order",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/order"
        }
      },
      "payment_setting": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_setting",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_setting"
        }
      },
      "payment_wallet": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_wallet",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_wallet"
        }
      },
      "payment_transactions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_transactions",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_transactions"
        }
      },
      "payment_authorization": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_authorization",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_authorization"
        }
      },
      "payment_void": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_void",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_void"
        }
      },
      "payment_captures": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_captures",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_captures"
        }
      },
      "payment_refunds": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/payment_refunds",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/payment_refunds"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/attachments"
        }
      },
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/events"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/2026-05/payment_sessions/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "created_with_version": "2026-05"
    }
  },
  "meta": {
    "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74",
    "api_versions": [
      "2026-05"
    ]
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.commercelayer.io/core-api-reference/2026-05/payment_sessions/create.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
