# Create a payment link with the API (/payment-links-api)
> Make a one-time payment link for a fixed amount with your API key, send it to a shopper, and follow whether it is paid.
A payment link asks one shopper for one payment of a fixed amount. You make it with the API, send the
returned `url` to the shopper, and read the link to see whether it was paid. The shopper pays on the MPS
**checkout**, so you never handle a card.
The same links are also made on the MPS platform, without code: see [Send a payment link](/payment-links).
A **test key** (`mps_test_…`) makes test links: they charge nothing and you can pay them yourself. A
**live key** (`mps_live_…`) makes live links, which take real money into your balance. A partner's key
makes **test links only**: a live link is made by the merchant itself.
> **Server only.** The API cannot be called from a browser. The gateway answers no cross-origin (CORS) requests, and the API key must never reach a browser. Call it from your server.
> **Warning.** Landing on successUrl is not proof of payment. Verify the webhook signature, read the payment, and check its state, amount, currency, and reference before marking an order paid.
- An API key that holds the `payment-links:create` and `payment-links:read` scopes. A key issued from this release on holds them; for an older key, ask MPS to add them.
- For a live link: your merchant's shop name on the MPS platform, which the shopper sees on the checkout. A link without one is refused.
A link is **single use** and stays open for the number of days you choose, 10 by default and 90 at most.
It stops opening payments when it is **paid**, **canceled** or **expired**. Paid is final.
### Create the link [#create-a-payment-link]
```bash
# Make a link for EUR 19.95, open for 10 days
# Prerequisite: export MPS_API_KEY=mps_test_…
curl -sS --fail-with-body -X POST "https://gateway.mps-emi.com/api/payments/payment-links" \
-H "Authorization: Bearer $MPS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 1995, "reference": "INV-42", "expiresInDays": 10, "locale": "nl"}'
```
The gateway answers `201 Created` with the link in `data`. The `Location` header points at the link. Store
`id` with your invoice, and send the shopper `url`.
#### Request body [#request-body]
| Field | Type | Required | Description |
|---|---|---|---|
| `amount` | integer | Yes | Amount in euro cents, from `1` to `5000000`. `1995` = EUR 19.95. |
| `reference` | string | Yes | Your reference, shown to the shopper and in your list. Letters A-Z, digits, spaces and `. _ : / # + -`; at most 64 characters. |
| `expiresInDays` | integer | No | Days the link stays open, from `1` to `90`. Defaults to `10`. |
| `locale` | string | No | `en`, `nl` or `fr`: the language of the link page and the checkout. Without it, the shopper's browser decides. |
The merchant, the mode and the shop name come from your key. A body that names a `test` flag or a shop name
has them ignored.
### Send the link [#send-the-link]
Send the shopper `url`, by e-mail, chat, text message or as a QR code. It opens the checkout with your shop
name, the amount and your reference. The shopper can open the link more than once: while a payment is pending on
it, the link opens that same checkout, so it cannot be paid twice.
### Read the link [#read-a-payment-link]
```bash
# Read one link of your merchant
curl -sS --fail-with-body "https://gateway.mps-emi.com/api/payments/payment-links/k3Qz9aVbN2xR7wYc1dFgHw" \
-H "Authorization: Bearer $MPS_API_KEY"
```
To list your links, newest first, call `GET https://gateway.mps-emi.com/api/payments/payment-links` with the same
header. Read a link again until its `state` is no longer `open`.
### Cancel the link [#cancel-a-payment-link]
```bash
# Stop an open link opening payments
curl -sS --fail-with-body -X DELETE "https://gateway.mps-emi.com/api/payments/payment-links/k3Qz9aVbN2xR7wYc1dFgHw" \
-H "Authorization: Bearer $MPS_API_KEY"
```
A canceled link opens no new payment. A payment already on its checkout can still be paid, and then the link
reads `paid`: cancelling never turns a paid payment into anything else. Canceling a canceled link answers `204`
again.
## Response [#response]
A link in `data`:
| Field | Type | Description |
|---|---|---|
| `id` | string | The link's identifier. An opaque string: never parse it. |
| `url` | string | The address to send the shopper to. |
| `amount` | integer | The amount in euro cents. |
| `reference` | string | Your reference, as you sent it. |
| `state` | string | `open`, `paid`, `canceled` or `expired`. Paid is final. |
| `test` | boolean | `true` for a test link. |
| `createdAt` | string | When the link was made. |
| `expiresAt` | string | When the link stops opening payments. |
| `paidAt` | string or null | When the link was paid. |
| `canceledAt` | string or null | When the link was canceled. |
| `paymentReference` | string or null | The payment the link was paid by. |
| `payments` | array | Every payment the link opened, oldest first, each with its `paymentReference` and `state`. |
| `locale` | string or null | The language the link page opens in. |
```json title="201 Created"
{
"data": {
"id": "k3Qz9aVbN2xR7wYc1dFgHw",
"url": "https://pay.mps-emi.com/link/k3Qz9aVbN2xR7wYc1dFgHw",
"amount": 1995,
"reference": "INV-42",
"state": "open",
"test": true,
"createdAt": "2026-11-18T09:14:03Z",
"expiresAt": "2026-11-28T09:14:03Z",
"paidAt": null,
"canceledAt": null,
"paymentReference": null,
"payments": [],
"locale": "nl"
}
}
```
## Errors [#errors]
| Status | Code | Cause | Resolution |
|---|---|---|---|
| `400` | — | A field is out of range, or the reference is missing or has characters not allowed. The body names the field. | Fix the field the error names. |
| `401` | — | No API key, or an unknown one. | Send a valid key as `Authorization: Bearer`. |
| `403` | — | The key lacks the scope, or a partner's key sent no `x-wallet-number`. | Ask MPS for the scope, or name the merchant (see [Choosing the merchant](/authentication#choosing-the-merchant)). |
| `403` | `payment_link_live_partner` | A partner's key asked for a live link. | Make a test link, or have the merchant make the live link itself. |
| `404` | — | No such link for this merchant. | The same answer as for a link that does not exist. |
| `409` | `payment_link_unnamed` | The merchant has no shop name, which the shopper would see. | Ask MPS to set the shop name, then try again. |
| `409` | `payment_link_not_open` | The link is paid or expired, so it cannot be canceled. | Nothing to cancel. Make a new link if the shopper still needs to pay. |
| `429` | — | More than 100 requests a minute from this key. | Wait for the `Retry-After` seconds. |
## Related [#related]
- [Send a payment link](/payment-links): the same links, made on the MPS platform without code.
- [Accept a payment](/online-payments): the payment a link opens, and its states.
- [Webhooks](/webhooks): MPS's signed webhook when a payment is received.
- [Authentication](/authentication): API keys, scopes and the test and live modes.