> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mitu.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mitu.ai/_mcp/server.

# Create a link

POST https://api.mitu.ai/v1/payment-links
Content-Type: application/json

Create a payment link.

Reference: https://docs.mitu.ai/api-reference/payment-links/create-payment-link

## Authentication

- `x-api-key` header (required) — Account API key used to authenticate server-side requests. Use the credentials issued for the same environment as the API base URL.

## Servers

- `https://api.mitu.ai` (Production, default)
- `https://sandbox-api.mitu.ai` (Sandbox)

## Request

### Headers

- `Idempotency-Key` (string, optional) — Unique key used to safely retry the same state-changing request.

### Body (application/json)

This endpoint expects a CreatePaymentLink.

- `type` (enum, optional, default: charge)
  - Allowed values: `charge`, `subscription`, `session`, `per_request`
- `amount` (double, optional) — Required for `charge` and `per_request`. `session` uses `session_max_deposit`; `subscription` derives it from the plan.
- `currency` (string, optional) — Required except for `subscription`, which takes it from the plan.
- `description` (string, optional)
- `reference` (string, optional) — Your own reference for this payment, such as an order or booking id. Returned with payment events so you can reconcile against a record your system already knows.
- `expires_at` (datetime, optional) — When the payment can no longer be completed.
- `payment_methods` (list of enum, optional) — The agent payment methods available for this payment.
  - Allowed values: `x402`, `mpp_crypto`, `mpp_spt`
- `metadata` (map from string to string, optional) — Free-form metadata returned with the payment. Do not store secrets or sensitive credentials here.
- `plan_id` (string, optional) — `subscription` only — a single plan id.
- `plan_ids` (list of string, optional) — `subscription` only — offer several plans for the payer to choose between.
- `allow_customer_choice` (boolean, optional, default: false) — `subscription` only — let the payer choose among `plan_ids`.
- `session_max_deposit` (double, optional) — `session` only — the most the payer can fund for the session.
- `session_expires_at` (datetime, optional) — `session` only.
- `endpoint_pattern` (string, optional) — `per_request` only — the API path the payment applies to.

## Response

### 201

Payment link created successfully.

- `message` (string, required)
- `data` (PaymentLink, required)

## Errors

### 400 Bad Request Error

The request is invalid and could not be processed.

- `message` (string, required) — Human-readable description of the error.

### 401 Unauthorized Error

Authentication failed because the API key is missing or invalid.

- `message` (string, required) — Human-readable description of the error.

### 403 Forbidden Error

The authenticated account is not allowed to perform this action.

- `message` (string, required) — Human-readable description of the error.

### 409 Conflict Error

This `Idempotency-Key` was already used with a different request.

- `message` (string, required) — Human-readable description of the error.

### 422 Unprocessable Entity Error

One or more request fields are invalid.

- `message` (string, required)
- `errors` (list of ValidationErrorDetail, required)

### 429 Too Many Requests Error

Too many requests were sent in a short period.

- `message` (string, required) — Human-readable description of the error.

### 500 Internal Server Error

An unexpected error occurred while processing the request.

- `message` (string, required) — Human-readable description of the error.

## Types

### PaymentLink

- `id` (string, optional)
- `type` (enum, optional)
  - Allowed values: `charge`, `subscription`, `session`, `per_request`
- `status` (enum, optional)
  - Allowed values: `pending`, `partial`, `active`, `settling`, `paid`, `settled`, `expired`, `cancelled`
- `amount` (string, optional) — Decimal amount sent as a string.
- `amount_paid` (string, optional) — How much of the amount has been paid so far.
- `currency` (string, optional)
- `description` (string, optional, nullable)
- `reference` (string, optional, nullable)
- `url` (PayUrl, optional) — The two ways to pay one resource. `checkout` is the page a person opens; `agent` is the 402-protected route an AI agent calls. They are not interchangeable — an agent given the checkout URL receives HTML instead of a payment challenge.
- `payment_methods` (list of enum, optional, nullable) — The agent payment methods available for this payment. `null` means no restriction — every method your account supports is available.
  - Allowed values: `x402`, `mpp_crypto`, `mpp_spt`
- `viewed_at` (datetime, optional, nullable) — When a payer first opened the link. `null` means nobody has opened it yet.
- `expires_at` (datetime, optional, nullable)
- `paid_at` (datetime, optional, nullable)
- `created_at` (datetime, optional)

### ValidationErrorDetail

- `field` (string, required) — Field that failed validation.
- `message` (string, required) — Description of the validation problem.

### PayUrl

The two ways to pay one resource. `checkout` is the page a person opens; `agent` is the 402-protected route an AI agent calls. They are not interchangeable — an agent given the checkout URL receives HTML instead of a payment challenge.

- `checkout` (string, required) — The hosted checkout a person opens.
- `agent` (string, required) — The route an AI agent pays programmatically.

## Examples

**Request**

```json
{
  "type": "charge",
  "amount": 25,
  "currency": "USD",
  "description": "Two large pizzas",
  "reference": "ORDER-8841",
  "expires_at": "2026-09-30T23:59:59.000Z",
  "payment_methods": [
    "x402",
    "mpp_crypto"
  ],
  "metadata": {
    "order_id": "8841"
  }
}
```

**Response**

```json
{
  "message": "Payment link retrieved successfully",
  "data": {
    "id": "pay_n8d7piu1yc6h",
    "type": "charge",
    "status": "pending",
    "amount": "25.00",
    "amount_paid": "0.00",
    "currency": "USD",
    "description": "Two large pizzas",
    "reference": "ORDER-8841",
    "url": {
      "checkout": "https://mitu.ai/pay/pay_n8d7piu1yc6h",
      "agent": "https://api.mitu.ai/pay/pay_n8d7piu1yc6h"
    },
    "payment_methods": [
      "x402",
      "mpp_crypto"
    ],
    "viewed_at": "2026-09-11T15:02:11.004Z",
    "expires_at": "2026-09-30T23:59:59.000Z",
    "paid_at": null,
    "created_at": "2026-09-11T15:00:34.915Z"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.mitu.ai/v1/payment-links"

payload = {
    "type": "charge",
    "amount": 25,
    "currency": "USD",
    "description": "Two large pizzas",
    "reference": "ORDER-8841",
    "expires_at": "2026-09-30T23:59:59.000Z",
    "payment_methods": ["x402", "mpp_crypto"],
    "metadata": { "order_id": "8841" }
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.mitu.ai/v1/payment-links';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"type":"charge","amount":25,"currency":"USD","description":"Two large pizzas","reference":"ORDER-8841","expires_at":"2026-09-30T23:59:59.000Z","payment_methods":["x402","mpp_crypto"],"metadata":{"order_id":"8841"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mitu.ai/v1/payment-links"

	payload := strings.NewReader("{\n  \"type\": \"charge\",\n  \"amount\": 25,\n  \"currency\": \"USD\",\n  \"description\": \"Two large pizzas\",\n  \"reference\": \"ORDER-8841\",\n  \"expires_at\": \"2026-09-30T23:59:59.000Z\",\n  \"payment_methods\": [\n    \"x402\",\n    \"mpp_crypto\"\n  ],\n  \"metadata\": {\n    \"order_id\": \"8841\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.mitu.ai/v1/payment-links")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"type\": \"charge\",\n  \"amount\": 25,\n  \"currency\": \"USD\",\n  \"description\": \"Two large pizzas\",\n  \"reference\": \"ORDER-8841\",\n  \"expires_at\": \"2026-09-30T23:59:59.000Z\",\n  \"payment_methods\": [\n    \"x402\",\n    \"mpp_crypto\"\n  ],\n  \"metadata\": {\n    \"order_id\": \"8841\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mitu.ai/v1/payment-links")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": \"charge\",\n  \"amount\": 25,\n  \"currency\": \"USD\",\n  \"description\": \"Two large pizzas\",\n  \"reference\": \"ORDER-8841\",\n  \"expires_at\": \"2026-09-30T23:59:59.000Z\",\n  \"payment_methods\": [\n    \"x402\",\n    \"mpp_crypto\"\n  ],\n  \"metadata\": {\n    \"order_id\": \"8841\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mitu.ai/v1/payment-links', [
  'body' => '{
  "type": "charge",
  "amount": 25,
  "currency": "USD",
  "description": "Two large pizzas",
  "reference": "ORDER-8841",
  "expires_at": "2026-09-30T23:59:59.000Z",
  "payment_methods": [
    "x402",
    "mpp_crypto"
  ],
  "metadata": {
    "order_id": "8841"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.mitu.ai/v1/payment-links");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"type\": \"charge\",\n  \"amount\": 25,\n  \"currency\": \"USD\",\n  \"description\": \"Two large pizzas\",\n  \"reference\": \"ORDER-8841\",\n  \"expires_at\": \"2026-09-30T23:59:59.000Z\",\n  \"payment_methods\": [\n    \"x402\",\n    \"mpp_crypto\"\n  ],\n  \"metadata\": {\n    \"order_id\": \"8841\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "type": "charge",
  "amount": 25,
  "currency": "USD",
  "description": "Two large pizzas",
  "reference": "ORDER-8841",
  "expires_at": "2026-09-30T23:59:59.000Z",
  "payment_methods": ["x402", "mpp_crypto"],
  "metadata": ["order_id": "8841"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.mitu.ai/v1/payment-links")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```