> ## 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.

# Add Customer Credit

> Endpoint for merchants to top-up (add) credit to a customer's add-on wallet.

<RequestExample>
  ```bash Request Example theme={null}
  curl --request POST 'https://api.mayar.id/hl/v2/credit/customer/add-credit' \
  --header 'Authorization: Bearer Paste-Your-API-Key-Here' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "customerId": "a1b2c3d4-e5f6-4789-a012-3456789abcde",
      "productId": "7c9d2e1f-4a5b-4c6d-8e9f-0a1b2c3d4e5f",
      "amount": 50000
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response Example 200 theme={null}
  {
      "statusCode": 200,
      "messages": "success",
      "data": {
          "customerNewBalance": 150000
      }
  }
  ```
</ResponseExample>

Endpoint:

<CodeGroup>
  ```Production Production theme={null}
  https://api.mayar.id/hl/v2/credit/customer/add-credit
  ```

  ```Sandbox Sandbox theme={null}
  https://api.mayar.club/hl/v2/credit/customer/add-credit
  ```
</CodeGroup>

## Authorization

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

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

## Request Body

<ParamField body="customerId" type="string" required>
  The unique identifier of the customer to add credit to.
</ParamField>

<ParamField body="productId" type="string" required>
  The unique identifier of the credit-based or membership product.
</ParamField>

<ParamField body="membershipTierId" type="string">
  The unique identifier of the membership tier (required when the product is a membership product with multiple tiers).
</ParamField>

<ParamField body="amount" type="integer" required>
  The amount of credit to add to the customer's add-on wallet. Must be a positive integer.
</ParamField>

## Response

Successful Response

### Main Structure (Root)

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

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

<ResponseField name="data" type="object">
  The top-up result object.
</ResponseField>

<ResponseField name="data.customerNewBalance" type="integer">
  The customer's updated total balance after the top-up.
</ResponseField>

## Errors

<ResponseField name="400 Validation Error" type="object">
  Returned when required fields are missing or the amount is invalid.
</ResponseField>

<ResponseField name="400 Unauthorized" type="object">
  Returned when the API key does not have access to the specified product.
</ResponseField>
