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

> Endpoint to create a review on behalf of a customer who purchased a product

<RequestExample>
  ```bash Request Example theme={null}
  curl --request POST 'https://api.mayar.id/hl/v2/reviews/create' \
  --header 'Authorization: Bearer Paste-Your-API-Key-Here' \
  --data-raw '{
      "paymentLinkId": "e2b3f5d5-0c62-47ba-8a01-6c1c209e0f77",
      "customerEmail": "budi.santoso@example.com",
      "rating": 5,
      "message": "Materinya jelas dan mudah dipahami, terima kasih!",
      "contentReview": [
          {
              "id": "d4e5f6a7-b8c9-4012-d345-6789abcdef01",
              "type": "image"
          }
      ]
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response Example 200 theme={null}
  {
      "statusCode": 200,
      "messages": "success",
      "data": {
          "id": "11f4d767-4d88-41ff-8777-06564d906fe7",
          "rating": 5,
          "message": "Materinya jelas dan mudah dipahami, terima kasih!",
          "paymentLinkId": "e2b3f5d5-0c62-47ba-8a01-6c1c209e0f77",
          "customerId": "22eb6224-c20a-4bc2-9b99-13b21e7048c6",
          "userId": "348e083d-315a-4e5c-96b1-5a2a98c48413",
          "status": "ACTIVE",
          "createdAt": 1767063610103,
          "updatedAt": 1767063610103
      }
  }
  ```
</ResponseExample>

Endpoint:

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

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

## Authorization

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

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

## Request Body

<ParamField body="paymentLinkId" type="string" required>
  ID of the payment link / product being reviewed. 3–100 characters.
</ParamField>

<ParamField body="customerEmail" type="string" required>
  Email of the customer leaving the review. Must be a valid email (5–100 characters) belonging to a
  customer who has paid for the product.
</ParamField>

<ParamField body="rating" type="number" required>
  Rating value. Integer between 1 and 5.
</ParamField>

<ParamField body="message" type="string">
  Optional review message. 1–2000 characters.
</ParamField>

<ParamField body="contentReview" type="array of object">
  Optional list of media attachments (images and/or videos). Maximum 10 entries.
</ParamField>

<ParamField body="contentReview.id" type="string">
  Identifier of the uploaded file to attach.
</ParamField>

<ParamField body="contentReview.type" type="string">
  Media type of the attachment. One of `image` or `video`.
</ParamField>

<ParamField body="contentReview.multipleFileId" type="string">
  Identifier of the underlying file record, when applicable.
</ParamField>

## Response

Successful Response

### Main Structure (Root)

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

<ResponseField name="messages" type="string">
  Status message that describes the status code. `"success"` on success, `"failed"` when the
  request body fails validation.
</ResponseField>

<ResponseField name="data" type="object">
  The created review record. When `messages` is `"failed"`, this holds the validation detail
  instead.
</ResponseField>

### data Structure (Object)

<ResponseField name="id" type="string">
  Unique review ID.
</ResponseField>

<ResponseField name="rating" type="number">
  Rating value submitted by the customer.
</ResponseField>

<ResponseField name="message" type="string">
  Review message submitted by the customer.
</ResponseField>

<ResponseField name="paymentLinkId" type="string">
  Payment link ID associated with the review.
</ResponseField>

<ResponseField name="customerId" type="string">
  Unique customer identifier associated with the review.
</ResponseField>

<ResponseField name="userId" type="string">
  Unique user ID associated with the payment link owner.
</ResponseField>

<ResponseField name="status" type="string">
  Current review status. New reviews are created with status `ACTIVE`.
</ResponseField>

<ResponseField name="createdAt" type="number">
  Unix timestamp in milliseconds indicating when the review was created.
</ResponseField>

<ResponseField name="updatedAt" type="number">
  Unix timestamp in milliseconds indicating when the review was last updated.
</ResponseField>

## Errors

<ResponseField name="200 Validation Failed" type="object">
  Returned with `messages` set to `"failed"` and `data` holding the validation detail when the
  request body is invalid.
</ResponseField>

<ResponseField name="404 Not Found" type="object">
  Returned with `messages` set to `"Produk tidak ditemukan"` when the product does not exist or is
  not owned by the authenticated merchant.
</ResponseField>

<ResponseField name="403 Forbidden" type="object">
  Returned with `messages` set to `"Anda belum pernah membeli produk ini"` when the customer has no
  paid transaction for the product.
</ResponseField>

<ResponseField name="409 Conflict" type="object">
  Returned with `messages` set to `"Anda sudah memberikan ulasan untuk produk ini, jika ingin
      mengedit ulasan, silahkan gunakan fitur edit ulasan"` when the customer has already reviewed the
  product.
</ResponseField>

<ResponseField name="500 Server Error" type="object">
  Returned with `messages` set to `"Gagal menambahkan ulasan"` or `"Terjadi kesalahan saat
      menambahkan ulasan"` when the review cannot be saved.
</ResponseField>
