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

# Create a Payment Session

{% hint style="info" %}
**New endpoint available**

**`POST /v1/user/payments`** is now the recommended way to create onramp sessions.&#x20;

The previous endpoint **`POST /v1/user/onramp/get_url`** remains available but for new integrations should use **`POST /v1/user/payments`**.
{% endhint %}

## Create a payment session

> Creates a payment session. ON\_RAMP returns a hosted widget link; OFF\_RAMP is accepted in the contract but returns 501 in Phase 1. country and currency\_id are always mandatory. For ON\_RAMP, amount, fiat\_currency and redirect\_url are also mandatory and are locked into the hosted widget. custom\_wallet\_address requires the merchant's allow\_custom\_external\_wallet flag.

```json
{"openapi":"3.0.0","info":{"title":"pay.io payment gateway","version":"1.0"},"servers":[{"url":"https://gateway.stage.pay.io","variables":{}}],"paths":{"/v1/user/payments":{"post":{"callbacks":{},"description":"Creates a payment session. ON_RAMP returns a hosted widget link; OFF_RAMP is accepted in the contract but returns 501 in Phase 1. country and currency_id are always mandatory. For ON_RAMP, amount, fiat_currency and redirect_url are also mandatory and are locked into the hosted widget. custom_wallet_address requires the merchant's allow_custom_external_wallet flag.","operationId":"HubwalletPaymentGatewayWeb.Controller.Merchant.Default.payment_sessions","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment_Session_Request"}}},"description":"Payment session attributes","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Payment_Session_Response"}}},"description":"Created payment session"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error_Response"}}},"description":"Custom wallet not allowed for merchant"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Validation_Error_Response"}}},"description":"Validation error"},"501":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error_Response"}}},"description":"Payment type not available in Phase 1"}},"summary":"Create a payment session","tags":["user"]}}},"components":{"schemas":{"Payment_Session_Request":{"description":"Request to create a payment session (ON_RAMP today; OFF_RAMP returns 501)","properties":{"amount":{"description":"Required for ON_RAMP; locked in the widget.","format":"decimal","type":"string"},"country":{"description":"ISO 3166-1 alpha-2 country code. REQUIRED — no default.","type":"string"},"currency_id":{"description":"Target currency id.","format":"uuid","type":"string"},"custom_wallet_address":{"description":"Self-custody destination. Only honoured when the merchant flag is on.","type":"string"},"fiat_currency":{"description":"ISO 4217 fiat currency (3-letter). Required for ON_RAMP; locked in the widget.","type":"string"},"metadata":{"description":"Free-form merchant metadata.","type":"object"},"payment_type":{"description":"ON_RAMP returns a hosted widget link. OFF_RAMP is accepted but returns 501 in Phase 1.","enum":["ON_RAMP","OFF_RAMP"],"type":"string"},"redirect_url":{"description":"URL the hosted widget redirects the user to on completion. Required for ON_RAMP; must start with http:// or https://.","type":"string"},"session_reference":{"description":"Merchant's own id for this session; echoed back in webhooks.","type":"string"},"theme":{"default":"dark","description":"Widget theme. Optional; defaults to dark.","enum":["light","dark"],"type":"string"},"user_reference_id":{"description":"Merchant's stable player id. Required unless custom_wallet_address is supplied.","type":"string"}},"required":["payment_type","country","currency_id"],"title":"Payment_Session_Request","type":"object"},"Payment_Session_Response":{"description":"A created payment session","properties":{"correlation_key":{"description":"Server-generated key, also the provider's externalSessionId.","type":"string"},"expires_at":{"description":"Link expiry. Null until a self-imposed TTL is introduced.","format":"date-time","nullable":true,"type":"string"},"link":{"description":"Provider-hosted URL the user is sent to.","type":"string"}},"required":["link","correlation_key"],"title":"Payment_Session_Response","type":"object"},"Error_Response":{"description":"Error response format","properties":{"error":{"description":"Error flag, always true","type":"boolean"},"message":{"description":"Error message describing what went wrong","type":"string"},"request_id":{"description":"Request correlation ID for tracking and debugging","type":"string"},"status":{"description":"Transaction status when a transaction was created before the error (e.g. `\"failed\"` for a withdrawal that was submitted but failed)","nullable":true,"type":"string"},"transaction_uuid":{"description":"Database transaction UUID (only present when a transaction exists)","format":"uuid","nullable":true,"type":"string"}},"required":["error","message","request_id"],"title":"Error_Response","type":"object"},"Validation_Error_Response":{"description":"Validation error response format","properties":{"error":{"description":"Error message","type":"string"},"errors":{"additionalProperties":{"items":{"type":"string"},"type":"array"},"description":"Field-specific validation errors","type":"object"}},"required":["error","errors"],"title":"Validation_Error_Response","type":"object"}}}}
```


---

# 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.pay.io/api-reference/user-payment-api/create-a-payment-session.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.
