> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyspend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a payment link

` POST /payment-links `

Create a payment link

## Servers

- ` https://platform-api.anyspend.com/api/v1 ` — Current server

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` apiKeyBearer `: ` http `

  - HTTP scheme: ` bearer `

  - API key passed as Bearer token. Keys start with `asp_`.

### Alternative 2

- ` apiKeyHeader `: ` apiKey `

  - Credential: ` X-API-Key ` in ` header `

  - API key passed via X-API-Key header.

## Parameters

### ` Idempotency-Key ` (header, optional)

Unique key for idempotent requests (24h TTL)

- ` value `: type ` string `

## Request body (required)

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` name `, ` token_address `, ` chain_id `, ` recipient_address `

  - ` name `: type ` string `

    - maxLength: ` 100 `

  - ` description `: type ` string `

    - maxLength: ` 500 `

  - ` amount `: type ` string `

  - ` token_address `: type ` string `

  - ` chain_id `: type ` integer `

  - ` recipient_address `: type ` string `

  - ` items `: type ` array `

    - ` array item `: type ` object `

      - ` name `: type ` string `

      - ` amount `: type ` string `

      - ` quantity `: type ` integer `

  - ` form_schema `: type ` object `

  - ` shipping_options `: type ` array `

  - ` branding `: type ` object `

  - ` max_uses `: type ` integer `

  - ` expires_at `: type ` integer `

  - ` return_url `: type ` string `

  - ` fee_on_top `: type ` boolean `

## Responses

### ` 201 ` — Payment link created

## Request examples

### cURL

```curl
curl -X POST 'https://platform-api.anyspend.com/api/v1/payment-links' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "description": "string",
  "amount": "string",
  "token_address": "string",
  "chain_id": 0,
  "recipient_address": "string",
  "items": [
    {
      "name": "string",
      "amount": "string",
      "quantity": 0
    }
  ],
  "form_schema": {},
  "shipping_options": [],
  "branding": {},
  "max_uses": 0,
  "expires_at": 0,
  "return_url": "string",
  "fee_on_top": true
}'
```

### JavaScript

```javascript
const response = await fetch('https://platform-api.anyspend.com/api/v1/payment-links', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "name": "string",
    "description": "string",
    "amount": "string",
    "token_address": "string",
    "chain_id": 0,
    "recipient_address": "string",
    "items": [
      {
        "name": "string",
        "amount": "string",
        "quantity": 0
      }
    ],
    "form_schema": {},
    "shipping_options": [],
    "branding": {},
    "max_uses": 0,
    "expires_at": 0,
    "return_url": "string",
    "fee_on_top": true
  })
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://platform-api.anyspend.com/api/v1/payment-links', headers=headers, json={
  "name": "string",
  "description": "string",
  "amount": "string",
  "token_address": "string",
  "chain_id": 0,
  "recipient_address": "string",
  "items": [
    {
      "name": "string",
      "amount": "string",
      "quantity": 0
    }
  ],
  "form_schema": {},
  "shipping_options": [],
  "branding": {},
  "max_uses": 0,
  "expires_at": 0,
  "return_url": "string",
  "fee_on_top": true
})
print(response.json())
```