> 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="https://docs.txn.io/api-basics/supported-currencies.md">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>. At most 30 days after creation.</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="https://docs.txn.io/api-basics/supported-currencies.md">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="https://docs.txn.io/api-basics/supported-currencies.md">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="https://docs.txn.io/payment-links/payment-links-concept.md">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",
      "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": [
    {
      "status": 422,
      "title": "Duplicate reference",
      "code": "reference_duplicate",
      "detail": "Reference docs-pl-payment-1793374122 is already in use"
    }
  ]
}
```

The `reference` is already used by an invoice, or by a payout that has not expired.
{% endtab %}

{% tab title="HTTP 422" %}

```json
{
  "errors": [
    {
      "status": 422,
      "title": "Invalid attribute",
      "code": "payment_link_invalid",
      "detail": "Reference has already been taken",
      "source": {
        "pointer": "/data/attributes/externalId"
      }
    }
  ]
}
```

Another payment link already uses the same `reference`.
{% endtab %}

{% tab title="HTTP 422" %}

```json
{
  "errors": [
    {
      "status": 422,
      "title": "Expiration time is too long",
      "code": "expires_at_too_long",
      "detail": "Expiration time is too long, maximum 30 days",
      "source": {
        "pointer": "/data/attributes/expiresAt"
      }
    }
  ]
}
```

`expires_at` is more than 30 days after creation.
{% endtab %}

{% tab title="HTTP 422" %}

```json
{
  "errors": [
    {
      "status": 422,
      "title": "Unsupported pay currency",
      "code": "unsupported_pay_currency",
      "detail": "Pay currencies must be cryptocurrencies"
    }
  ]
}
```

A code in `payCurrencies` is not a cryptocurrency.
{% 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.txn.io/payment-links/creating-payment-link.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
