***

title: Create and share a payment link
icon: up-to-bracket
published: true
---------------------

For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.payroc.com/essentials-guides/payment-links/llms.txt. For full documentation content, see https://docs.payroc.com/essentials-guides/payment-links/llms-full.txt.

Use our Payment Links feature to create a payment link that the merchant can email to customers to pay for goods and services. The request to create a payment link contains the following settings for the payment link:

* **type** - Indicates whether the link can be used only once or if it can be used multiple times.
* **authType** - Indicates whether the transaction is a sale or a pre-authorization.
* **paymentMethod** - Indicates the payment methods that the merchant accepts.
* **charge** - Indicates whether the merchant or customer enters the amount for the transaction.

When the gateway creates the link, it returns the paymentLinkId that you use in the request to share the payment link.

## Integration steps

**Step 1.** Create a payment link. <br />
**Step 2.** Share a payment link.

## Before you begin

### Bearer tokens

Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps:

1. Include your API key in the x-api-key parameter in the header of a POST request.
2. Send your request to [https://identity.payroc.com/authorize](https://identity.payroc.com/authorize).

<Note>
  **Note:** You need to generate a new Bearer token before the previous Bearer token expires.
</Note>

#### Example request

```sh
curl --location --request POST  'https://identity.payroc.com/authorize' --header 'x-api-key: <api key>'
```

#### Example response

If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.

```json
{
  "access_token": "eyJhbGc....adQssw5c",
  "expires_in": 3600,
  "scope": "service_a service_b",
  "token_type": "Bearer"
}
```

### Headers

To create the header of each GET request, you must include the following parameters:

* **Content-Type:** Include application/json as the value for this parameter.
* **Authorization:** Include your Bearer token in this parameter.

```sh
curl
  -H "Content-Type: application/json"
  -H "Authorization: <Bearer token>"
```

To create the header of each POST request, you must include the following parameters:

* **Content-Type:** Include application/json as the value for this parameter.
* **Authorization:** Include your Bearer token in this parameter.
* **Idempotency-Key:** Include a UUID v4 to make the request idempotent.

```sh
curl
  -H "Content-Type: application/json"
  -H "Authorization: <Bearer token>"
  -H "Idempotency-Key: <UUID v4>"
```

### Errors

If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors).

## Step 1. Create a payment link

To create a payment link, send a POST request to our Processing Terminals endpoint.

| Endpoint   | Prefix     | URL                                                                                                                                                                                  |
| :--------- | :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Test       | `api.uat.` | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId}/payment-links](https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId}/payment-links) |
| Production | `api.`     | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId}/payment-links](https://api.payroc.com/v1/processing-terminals/\{processingTerminalId}/payment-links)         |

### Request parameters

To create the body of your request, use the following parameters:

<EndpointSchemaSnippet endpoint="POST /processing-terminals/{processingTerminalId}/payment-links" selector="request.body" />

### Example request

<EndpointRequestSnippet endpoint="POST /processing-terminals/{processingTerminalId}/payment-links" />

### Response fields

If your request is successful, our gateway returns a paymentLinkId. Save the paymentLinkId so that you can include it in the request to share the link.
The response contains the following fields:

<EndpointSchemaSnippet endpoint="POST /processing-terminals/{processingTerminalId}/payment-links" selector="response.body" />

### Example response

<EndpointResponseSnippet endpoint="POST /processing-terminals/{processingTerminalId}/payment-links" example="createdPaymentLink" />

## Step 2. Share a payment link

To share a payment link, send a POST request to our Payment Links endpoint that includes the paymentLinkId of the link you want to share.

| Endpoint   | Prefix     | URL                                                                                                                                                        |
| :--------- | :--------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Test       | `api.uat.` | [https://api.uat.payroc.com/v1/payment-links/\{paymentLinkId}/sharing-events](https://api.uat.payroc.com/v1/payment-links/\{paymentLinkId}/sharing-events) |
| Production | `api.`     | [https://api.payroc.com/v1/payment-links/\{paymentLinkId}/sharing-events](https://api.payroc.com/v1/payment-links/\{paymentLinkId}/sharing-events)         |

### Request parameters

To create the body of your request, use the following parameters:

<EndpointSchemaSnippet endpoint="POST /payment-links/{paymentLinkId}/sharing-events" selector="request.body" />

### Example request

<EndpointRequestSnippet endpoint="POST /payment-links/{paymentLinkId}/sharing-events" />

### Response fields

If your request is successful, our gateway shares the payment link with the recipients.
The response contains the following fields:

<EndpointSchemaSnippet endpoint="POST /payment-links/{paymentLinkId}/sharing-events" selector="response.body" />

### Example response

<EndpointResponseSnippet endpoint="POST /payment-links/{paymentLinkId}/sharing-events" example="paymentLinkShareEvent" />