---
updatedAt: 2026-03-02T12:04:02.000Z
agentTools:
  projectIndex: https://docs.moneyhubenterprise.com/llms.txt
---

# Create a Pay Link

In this guide, we will walk you through the process of creating a pay link using the `/pay-links` endpoint of our API. The pay links for the pay link widget must be generated via our API. Below, we'll provide a detailed description of each required property and step-by-step actions for making the request.

# Introduction

A pay link is a unique URL that allows users to make payments seamlessly via the [Pay Link Widget](https://docs.moneyhubenterprise.com/docs/create-and-configure-pay-link-widget). By creating a pay link, you provide an easy way for others to transfer money to a specified account. This document guides you through the necessary steps to create a pay link using the MoneyHub API.

# Prerequisites

## General Requirements

Ensure you have the following setup before proceeding:

* You have an Admin Portal [User](https://docs.moneyhubenterprise.com/docs/admin-portal-sign-up)
* You have created an API [Client](https://docs.moneyhubenterprise.com/docs/create-a-client) with `pay_link:create` and `pay_link:read` scopes enabled.
* You have created a [Pay Link Widget](https://docs.moneyhubenterprise.com/docs/create-and-configure-single-payment-widget)  in the Admin Portal
* You have installed the [moneyhub-api-client](https://docs.moneyhubenterprise.com/docs/create-a-client#using-the-nodejs-moneyhub-api-library) library (optional)

## Obtain Access Token

Before creating a pay link, you need to obtain an access token. Follow our [authentication guide](https://docs.moneyhubenterprise.com/docs/authentication#authenticating-on-the-token-endpoint) to get a client credentials token and make sure you set it with the `pay_link:create` scope.

**Note:** If you also wish to access the pay links later on, include `pay_link:read` scope as well.

## Obtain `payeeId`

To create a pay link, you will need a `payeeId`. You can create a payee programmatically using the [Payee Management API](https://docs.moneyhubenterprise.com/docs/payee-management).

**Note:** If you do not have a `payeeId`, you can optionally pass in payee details directly when creating the pay link (described below).

# Create a Pay Link

With the `access_token` and `payeeId` obtained, you can now create a pay link using the `/pay-links` endpoint.

## Request

### Endpoint

```markdown
POST <https://identity.moneyhub.co.uk/pay-links>
```

### Headers

```Text Markdown
Content-Type: application/json  
Authorization: Bearer YOUR_ACCESS_TOKEN
```

### Body

```Text JSON
{  
  "widgetId": "b6393c9b-2f9f-4a12-a3b0-da8b0d3c6f8a",  
  "payeeId": "a5c2394d-f1bb-4f8f-98fb-65cf2c4d087c", 
  "reference": "invoice-001",  
  "amount": 1500,  
  "endToEndId": "INV-2024-001",  
  "useOnce": true,  
  "expiresAt": "2021-02-01T11:08:45.574Z"  
}
```

**Properties**

| Name         | Description                                                       |
| :----------- | :---------------------------------------------------------------- |
| `widgetId`   | A unique identifier for the pay link widget.                      |
| `payeeId`    | A unique identifier for the payee.                                |
| `reference`  | A reference string for the transaction.                           |
| `amount`     | The amount for the payment in minor units.                        |
| `endToEndId` | A unique identifier for tracking the transaction end-to-end.      |
| `useOnce`    | A boolean indicating whether the pay link can only be used once.  |
| `expiresAt`  | The expiration date and time for the pay link in ISO 8601 format. |

> 📘 Optionally Pass in Payee Details Directly
>
> If you do not have an existing `payeeId` created via our API, you can pass in payee details instead and we will create a new payee. This approach can be useful for testing but is not recommended for ongoing use.
>
> ```Text JSON
> {  
>   "widgetId": "b6393c9b-2f9f-4a12-a3b0-da8b0d3c6f8a",  
>   "payee": {
>       "accountNumber": "88888888",
>       "sortCode": "666666",
>       "name": "Jane Smith",
>     },
>   "reference": "invoice-001",  
>   "amount": 1500,  
>   "endToEndId": "INV-2024-001",  
>   "useOnce": true,  
>   "expiresAt": "2021-02-01T11:08:45.574Z"  
> }
> ```

###  Example using cURL

```node
curl -X POST '<https://identity.moneyhub.co.uk/pay-links'>  
-H 'Content-Type: application/json'  
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'  
-d '{  
  "widgetId": "b6393c9b-2f9f-4a12-a3b0-da8b0d3c6f8a",  
  "payeeId": "a5c2394d-f1bb-4f8f-98fb-65cf2c4d087c",  
  "reference": "invoice-001",  
  "amount": 1500,  
  "endToEndId": "INV-2024-001",  
  "useOnce": true,  
  "expiresAt": "2021-02-01T11:08:45.574Z"  
}'
```

### Example using `moneyhub-api-client`

```node
const payLinkData = await moneyhub.addPayLink({
  widgetId: "b6393c9b-2f9f-4a12-a3b0-da8b0d3c6f8a",
  payeeId: "a5c2394d-f1bb-4f8f-98fb-65cf2c4d087c",
  reference: "invoice-001",
  amount: 1500,
  endToEndId: "INV-2024-001",
  useOnce: true,
  expiresAt: "2021-02-01T11:08:45.574Z"
});
```

## Response

A successful response will contain details of the newly created pay link:

```node
{  
  "id": "6db2f995-6a8d-4929-aafb-1989b2d5f72b",  
  "widgetId": "b6393c9b-2f9f-4a12-a3b0-da8b0d3c6f8a",  
  "payeeId": "a5c2394d-f1bb-4f8f-98fb-65cf2c4d087c",  
  "reference": "invoice-001",  
  "amount": 1500,  
  "endToEndId": "INV-2024-001",  
  "useOnce": true,  
  "expiresAt": "2021-02-01T11:08:45.574Z",  
  "createdAt": "2021-01-01T12:00:00.000Z",  
  "updatedAt": "2021-01-01T12:00:00.000Z"  
}
```

# Using the Pay Link

To use the pay link, add the `payLinkId` to your widget parameters upon initialisation. For demo purposes, you can visit:

```markdown
https://identity.moneyhub.co.uk/widget-pages/PAY_LINK_WIDGET_ID#payLinkId=PAY_LINK_ID
```

For further details on initialising the widget, refer to the [General Widget Configuration](https://docs.moneyhubenterprise.com/docs/creating-and-managing-widgets) section.

With a pay link widget, you can then visit:

```markdown
BASE_URL/widget-pages/PAY_LINK_WIDGET_ID#payLinkId=PAY_LINK_ID
```

This allows users to easily make payments as per the created link details. Ensure you store these details securely for future reference and usage.