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

# Spend Customer Credit

> This endpoint is used to spend a specified amount of credit from a member’s account on particular membership tier on membership credit product.

<RequestExample>
  ```bash Request Example theme={null}
  curl --request POST 'https://api.mayar.id/credit/v1/credit/customer/spend' \
  --header 'Authorization: Bearer Paste-Your-API-Key-Here' \
  --data '{
      "customerId": "9de4b4b4-525c-4ee0-ac9c-b29c3e10fe55",
      "productId": "40f26fbe-f4d8-4693-975f-e6d105d291e6",
      "amount": 10
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response Example 200 theme={null}
  {
      "statusCode": 200,
      "message": "Successfully spent 10. MAIN: 10, ADD_ON: 0"
  }
  ```
</ResponseExample>

Endpoint:

<CodeGroup>
  ```Production Production theme={null}
  https://api.mayar.id/credit/v1/credit/customer/spend
  ```

  ```Sandbox Sandbox theme={null}
  https://api.mayar.club/credit/v1/credit/customer/spend
  ```
</CodeGroup>

## Authorization

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

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

## Request Body

<ParamField query="customerId" path="customerId" type="string">
  The unique identifier of the member whose credit will be spent.
</ParamField>

<ParamField query="productId" path="productId" type="string" required>
  The unique identifier of the product associated with the credit.
</ParamField>

<ParamField query="amount" path="amount" type="integer" required>
  The amount of credit to deduct (positive integer).
</ParamField>

## Response

Successful Response

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

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