---
title: "Register Apple SK2 purchase"
method: POST
path: "/purchases"
---

# Register Apple SK2 purchase

`POST /purchases`

Use this endpoint to register a purchase made via Apple StoreKit2 to initiate an asynchronous  synchronization process. This process involves verifying the purchase with Apple and updating the user's entitlement status in Cleeng's system. <br><br> Due to the time required for Apple's verification, this operation is asynchronous. Upon successful registration, the API will return a `202` `Accepted` status with a unique `synchronizationId` in the response body. <br><br> The `cleengCustomerId` is used to identify the user in Cleeng's system and associate the purchase with their account. <br><br> **Important:** Only one synchronization process can be active for a given `transactionId` at a time. If a new request is made for the same `transactionId` while a previous synchronization is still in progress, a `409` `Conflict` error will be returned.    <br><br>Please note that **this endpoint can be authorized with a publisher (X-Publisher-Token) or JWT (Bearer) token**. Depending on how you integrate with Cleeng (directly or through middleware), use either a <<glossary:JWT>> or X-Publisher-Token header authorization. <br> <br> <span style="color:green">**Please use JWT (Bearer) token to try out the endpoint in the API console in this documentation**.</span>

You can then use the following methods to check the status of the synchronization process:

* **Polling:** Use the `/purchases/synchronizations/{synchronizationId}` endpoint to periodically retrieve the status. This endpoint provides a concise response with the essential status information.
* **Webhooks:** Subscribe to the `inappPurchaseSyncResult` webhook to receive real-time updates on the synchronization status. The webhook payload (`WebhookSynchronizationStatus`) includes detailed information about the synchronization, including the `synchronizationId`, transaction details (`transactionId`, `cleengCustomerId`, `originalTransactionId`), `accessGranted`, `offerId`, and `result`.

You can choose to use either the polling mechanism, the webhook, or both, depending on your needs.

# Errors

| HTTP Status Code | Error Code         | Message                                                         |
| :--------------- | :----------------- | :-------------------------------------------------------------- |
| 400              | REQ0001            | Invalid body                                                    |
| 400              | REQ0004            | Invalid headers                                                 |
| 409              | SK2C0101           | The resource is temporarily locked due to a concurrent request. |
| 422              | SK2C0100           | Unable to find customer                                         |
| 500              | SK2C0004           | StoreKit2 integration not activated                             |
| 500              | SXXXX (X - number) | Internal Server Error                                           |

## Headers

- `Authorization` string
- `X-Publisher-Token` string
- `Correlation-Id` string
- `X-Publisher-Id` integer, required
- `X-App-Version` string
- `X-Device-Id` string
- `X-Device-Type` string
- `X-User-Action` string

## Request body

- object
  - `cleengCustomerId` integer, required — Cleeng's unique identifier for the customer who made the purchase.
  - `transactionId` string, required — Apple's unique transaction identifier for the purchase. This ID is used to verify the purchase with Apple and track its status in Cleeng's system.
  - `ipAddress` string — IP address of the customer who made the purchase. This information will be stored in the user's profile as the IP address of their latest activity. Accepted: IPv4, IPv6. <br><br> The parameter **is required** in backend intergrations (with middleware) to ensure the correct customer IP address (address of their latest activity) is stored

## Response `202`

202

## Other responses

- `400` — 400
- `409` — 409
- `422` — 422
- `500` — 500

---

[API](https://skmtc.net/cleeng/apis/mediastore-api.md) · [All operations](https://skmtc.net/cleeng/apis/mediastore-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cleeng/mediastore-api/versions/00cbfe7998a4/schema)
