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

# Create Payment Link

> Endpoint used to create a generic payment link product

<RequestExample>
  ```bash Request Example theme={null}
  curl --request POST 'https://api.mayar.id/hl/v2/products/payment-link/create' \
  --header 'Authorization: Bearer Paste-Your-API-Key-Here' \
  --data-raw '{
          "name": "Jasa Buat Website Kece",
          "description": "Untuk testing API",
          "amount": 150000,
          "redirectUrl": "https://example.com/thank-you",
          "notes": "catatan opsional",
          "expiredAt": "2026-06-15T12:00:00.000Z"
      }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response Example 200 theme={null}
  {
      "statusCode": 200,
      "messages": "success",
      "data": {
          "id": "21d84338-b46d-42d7-9b49-d402520407a5",
          "link": "https://testingmayar.myr.id/pl/Jasa-Buat-Website-Kece"
      }
  }
  ```
</ResponseExample>

Endpoint:

<CodeGroup>
  ```Production Production theme={null}
  https://api.mayar.id/hl/v2/products/payment-link/create
  ```

  ```Sandbox Sandbox theme={null}
  https://api.mayar.club/hl/v2/products/payment-link/create
  ```
</CodeGroup>

<Note>
  This endpoint shares the same handler and request body as
  [Create Product](/api-reference-v2/genericlink/create)
  (`POST /products/create`). Both create a `generic_link` product.
</Note>

## Authorization

<ResponseField name="Authorization" type="string" required>
  Example:

  `Authorization | Bearer Paste-Your-API-Key-Here`
</ResponseField>

## Request Body

<ParamField path="name" type="string" required>
  Generic payment link product name.
</ParamField>

<ParamField path="amount" type="integer">
  Product price amount.
</ParamField>

<ParamField path="description" type="string">
  Generic payment link product description.
</ParamField>

<ParamField path="redirectUrl" type="string">
  URL where the customer will be redirected after completing payment.
</ParamField>

<ParamField path="coverImage" type="string">
  Cover image for the product.
</ParamField>

<ParamField path="expiredAt" type="string | datetime">
  Payment link expiration date in ISO 8601 format.
</ParamField>

<ParamField path="limit" type="integer">
  Maximum purchase limit.
</ParamField>

<ParamField path="notes" type="string">
  Additional notes for the payment link.
</ParamField>

<ParamField path="tax" type="integer">
  Tax amount applied to the product.
</ParamField>

## Response

Successful Response

### Main Structure (Root)

<ResponseField name="statusCode" type="integer">
  Status code from API.
</ResponseField>

<ResponseField name="messages" type="string">
  Status message that describes the status code.
</ResponseField>

<ResponseField name="data" type="object">
  The created generic payment link product data.
</ResponseField>

### data Structure (Object)

<ResponseField name="data.id" type="string">
  Unique identifier of the generic payment link product.
</ResponseField>

<ResponseField name="data.link" type="string">
  Public URL of the created generic payment link product.
</ResponseField>

### Errors

<ResponseField name="400 Bad Request" type="object">
  Returned when the request body fails validation:
  `{ "statusCode": 400, "messages": "Validation Error" }`.
</ResponseField>

<ResponseField name="409 Conflict" type="object">
  Returned when a product with the same identifier already exists:
  `{ "statusCode": 409, "messages": "already exist" }`.
</ResponseField>
