> For the complete documentation index, see [llms.txt](https://docs.txn.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.txn.io/payment-links/creating-payment-link.md).

# Creating payment link

<mark style="color:green;">`POST`</mark> `/api/public/v1/payment_links`

Creates a payment link and returns a hosted page URL to redirect your end user to. The end user selects a cryptocurrency and network on the hosted page; Txn then creates the child invoice or payout automatically.

**Headers**

| Name          | Value                      |
| ------------- | -------------------------- |
| Content-Type  | `application/vnd.api+json` |
| Authorization | `Bearer <api_key>`         |

**Request Body**

<table><thead><tr><th>Name</th><th width="100">Type</th><th width="105">Required</th><th>Description</th></tr></thead><tbody><tr><td>data.type</td><td>string</td><td>Yes</td><td>Can only be <code>payment_links</code>.</td></tr><tr><td>data.attributes.amount</td><td>string</td><td>Yes</td><td>Payment amount to display to the end user.</td></tr><tr><td>data.attributes.currency</td><td>string</td><td>Yes</td><td>Display currency of the payment amount shown to the end user. Accepts any supported currency code — fiat or cryptocurrency. If <code>currency</code> is a display fiat currency (one that cannot be used directly as a settlement or funding account), <code>accountCurrency</code> must also be provided. See <a href="/pages/SA7q0b6VrvXO3W09TQfS">Supported Currencies</a>.</td></tr><tr><td>data.attributes.paymentType</td><td>string</td><td>Yes</td><td><code>Invoice</code> or <code>Payout</code>.</td></tr><tr><td>data.attributes.expires_at</td><td>string</td><td>Yes</td><td>ISO 8601 timestamp of when the payment link should expire, e.g. <code>2026-06-01T23:00:00.000Z</code>.</td></tr><tr><td>data.attributes.accountCurrency</td><td>string</td><td>No</td><td>Merchant account currency for settlement (invoice payment links) or funding (payout payment links). Equivalent to <code>targetCurrency</code> on invoices and <code>chargeCurrency</code> on payouts. Must be a tradable fiat or cryptocurrency — display fiat currencies are not accepted. If omitted, defaults to <code>currency</code>, which must then itself be a tradable fiat or cryptocurrency. See <a href="/pages/SA7q0b6VrvXO3W09TQfS">Supported Currencies</a>.</td></tr><tr><td>data.attributes.paymentMethods</td><td>array</td><td>No</td><td>Payment methods available on the hosted page. <code>on_chain</code> generates a deposit address for a direct on-chain transfer. <code>binance_pay</code> generates Binance Pay instructions. <code>nft</code> generates NFT purchase instructions. Defaults to <code>["on_chain"]</code>.</td></tr><tr><td>data.attributes.payCurrencies[]</td><td>array</td><td>No</td><td>Restrict which cryptocurrencies the end user can choose from on the hosted page. If omitted, all supported options are shown. See <a href="/pages/SA7q0b6VrvXO3W09TQfS">Supported Currencies</a>.</td></tr><tr><td>data.attributes.reference</td><td>string</td><td>No</td><td>Your internal correlation key for this payment link. Must be unique per payment link.</td></tr><tr><td>data.attributes.successRedirectUrl</td><td>string</td><td>No</td><td>Invoice payment links only. URL to redirect the end user to after successful payment.</td></tr><tr><td>data.attributes.unsuccessRedirectUrl</td><td>string</td><td>No</td><td>Invoice payment links only. URL to redirect the end user to if the invoice expires, is cancelled, or rejected.</td></tr></tbody></table>

**cURL**

```bash
curl -X "POST" "https://api.sandbox.txn.io/api/public/v1/payment_links" \
     -H 'Content-Type: application/vnd.api+json' \
     -H 'Authorization: Bearer <api_key>' \
     -d $'{
  "data": {
    "type": "payment_links",
    "attributes": {
      "amount": "100",
      "currency": "EUR",
      "accountCurrency": "EUR",
      "reference": "8c40d8b6-ccdf-4861-a6d6-6c3125ce3f31",
      "expires_at": "2026-06-01T23:00:00.000Z",
      "paymentType": "Invoice",
      "paymentMethods": ["on_chain"],
      "payCurrencies": ["USDT", "BTC"],
      "successRedirectUrl": "https://example.com/success",
      "unsuccessRedirectUrl": "https://example.com/fail"
    }
  }
}'
```

**Response Body**

<table><thead><tr><th>Name</th><th width="97">Type</th><th>Description</th></tr></thead><tbody><tr><td>data.id</td><td>string</td><td>Payment link ID.</td></tr><tr><td>data.type</td><td>string</td><td>Always <code>paymentLinks</code>.</td></tr><tr><td>data.attributes.amount</td><td>string</td><td>Payment amount displayed to the end user.</td></tr><tr><td>data.attributes.currency</td><td>string</td><td>Currency of the payment amount.</td></tr><tr><td>data.attributes.accountCurrency</td><td>string</td><td>Merchant account currency used for settlement or funding.</td></tr><tr><td>data.attributes.network</td><td>string</td><td>Network code selected by the end user on the hosted page. <code>null</code> until a selection is made.</td></tr><tr><td>data.attributes.networkName</td><td>string</td><td>Human-readable network name. <code>null</code> until the end user selects a network.</td></tr><tr><td>data.attributes.reference</td><td>string</td><td>Your internal correlation key, as set at creation.</td></tr><tr><td>data.attributes.hostedPageUrl</td><td>string</td><td>URL of the Txn-hosted page to redirect your end user to.</td></tr><tr><td>data.attributes.status</td><td>string</td><td>Payment link status. See <a href="/pages/2XgPefwnfLqZ7rf7y1ai">Payment Links Concept</a>.</td></tr><tr><td>data.attributes.approvalStatus</td><td>string</td><td>Approval workflow status for payout payment links subject to an approval rule. <code>null</code> otherwise.</td></tr><tr><td>data.attributes.expiresAt</td><td>string</td><td>ISO 8601 timestamp of when the payment link expires.</td></tr><tr><td>data.attributes.createdAt</td><td>string</td><td>ISO 8601 timestamp of when the payment link was created.</td></tr><tr><td>data.attributes.paymentType</td><td>string</td><td><code>Invoice</code> or <code>Payout</code>.</td></tr><tr><td>data.attributes.paymentMethods[]</td><td>array</td><td>Payment methods available on the hosted page.</td></tr><tr><td>data.attributes.successRedirectUrl</td><td>string</td><td>Success redirect URL. <code>null</code> if not set.</td></tr><tr><td>data.attributes.unsuccessRedirectUrl</td><td>string</td><td>Unsuccessful redirect URL. <code>null</code> if not set.</td></tr><tr><td>data.relationships.target.data</td><td>object</td><td>ID and type of the child invoice or payout. <code>null</code> until the end user selects a cryptocurrency on the hosted page.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="HTTP 201" %}

```json
{
  "data": {
    "id": "46df1a5c-a478-427f-a988-a2dacb235d6b",
    "type": "paymentLinks",
    "attributes": {
      "amount": "100.00",
      "currency": "EUR",
      "accountCurrency": "EUR",
      "network": null,
      "networkName": null,
      "reference": "8c40d8b6-ccdf-4861-a6d6-6c3125ce3f31",
      "hostedPageUrl": "https://sandbox.txn.io/redirect?payment_link_id=46df1a5c-a478-427f-a988-a2dacb235d6b&request_type=payment_link_hosted_page&zone=eu",
      "status": "created",
      "approvalStatus": null,
      "expiresAt": "2026-06-01T23:00:00.000Z",
      "createdAt": "2026-05-17T10:07:24.199Z",
      "paymentType": "Invoice",
      "successRedirectUrl": "https://example.com/success",
      "unsuccessRedirectUrl": "https://example.com/fail",
      "paymentMethods": [
        "on_chain"
      ]
    },
    "relationships": {
      "target": {
        "data": null
      }
    }
  },
  "meta": {},
  "jsonapi": {
    "version": "1.0"
  }
}
```

{% endtab %}

{% tab title="HTTP 422" %}

```json
{
  "errors": [
    {
      "title": "Reference duplicate",
      "detail": "8c40d8b6-ccdf-4861-a6d6-6c3125ce3f31",
      "code": "reference_duplicate"
    }
  ]
}
```

Duplicate reference.
{% endtab %}

{% tab title="HTTP 422" %}

```json
{
  "errors": [
    {
      "status": 422,
      "title": "Unsupported pay currency",
      "code": "unsupported_pay_currency",
      "detail": ""
    }
  ]
}
```

Currency code in `payCurrencies` is not supported.
{% 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.txn.io/payment-links/creating-payment-link.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.
