# Cloud Accept API (/in-store/integration/cloud_accept_api)

<div className="bg-background relative h-auto w-full overflow-hidden rounded-lg border mt-8">
  
<FlickeringGrid squareSize={4} gridGap={6} maxOpacity={0.1} flickerChance={0.1} height={800} width={2000} />

  
<CloudAcceptDiagram />

</div>

The Cloud Accept API lets your electronic cash register (ECR) or POS backend start a payment on a Tapaya device
over the cloud. Your system never talks to the device directly: it sends a payment request to Tapaya, Tapaya
notifies the paired device, and the device shows the payment screen to the customer. Progress comes back to you
as webhooks, or you poll for it.

## Choose How to Pair Devices [#choose-how-to-pair-devices]

Every device you send payments to needs an `externalDeviceId`: the name your system uses for it, such as
`till-01`. Assign it in one of two ways:

<Cards>
<Component title="From your app" href="#assign-from-your-app" description="Your app assigns the externalDeviceId through the Accept SDK on the device." />

<Component title="QR code from the platform" href="#scan-a-qr-code" description="The merchant shows a QR code in the Tapaya Platform and scans it with the merchant app." />
</Cards>

## Before You Start [#before-you-start]

1. **Get your Server Secret Token** from the [API Keys page](https://platform.tapaya.com/api-keys/). You exchange
   it for a merchant-scoped access token below (see [Platform API authentication](/platform-api#authentication)).
2. **Register the merchant** and keep its `merchantToken`. See
   [Register a New Merchant](./backend_integration#register-a-new-merchant).
3. **Prepare each device** with the Tapaya app signed in for that merchant, so it can be paired and receive
   requests.

<Callout title="One token, one merchant" type="info">
Every Cloud Accept API call is scoped to exactly one merchant. To serve several merchants, exchange a separate
access token for each one.
</Callout>

<section id="cloud-accept-steps">
            <div className="fd-steps [&_h3]:fd-step">
                ### Pair a Device [#pair-a-device]

                Pairing assigns an `externalDeviceId` to a Tapaya device, so you can find it when listing devices
                and target it when starting a payment.

                
<Accordions type="multiple">
<Accordion title="Assign from your app" id="assign-from-your-app">
Your application calls an Accept SDK function on the device to assign its `externalDeviceId`. Use
                the same identifier in every Cloud Accept API call for that device.
</Accordion>

                
<Accordion title="Scan a QR code" id="scan-a-qr-code">
The merchant opens the pairing flow in the Tapaya Platform, which shows a QR code for the
                `externalDeviceId` to assign. The merchant scans it with the Tapaya merchant app on the target
                device, and the app completes pairing.
</Accordion>
</Accordions>

                ### Exchange an Access Token [#exchange-an-access-token]

                Exchange your Server Secret Token and the merchant's `merchantToken` for an access token with
                `POST /ecr/auth`. `merchantToken` is sent only here; every later call sends just
                `Authorization: Bearer <accessToken>`.

                
<CodeBlockTabs defaultValue="curl" groupId="cloud-accept-client" persist>
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

                
<CodeBlockTabsTrigger value="typescript">
TypeScript
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

                
<CodeBlockTab value="curl">
```bash
                curl -X 'POST' 'https://api.tapaya.com/ecr/auth' \
                -H 'Content-Type: application/json' \
                -H 'Authorization: Bearer REPLACE_ME' \
                -d '{
                        "merchantToken": "unique_merchant_id_from_your_db"
                    }'
                ```
</CodeBlockTab>

                
<CodeBlockTab value="typescript">
```typescript
                const res = await fetch('https://api.tapaya.com/ecr/auth', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        Authorization: `Bearer ${process.env.TAPAYA_SECRET_TOKEN}`,
                    },
                    body: JSON.stringify({ merchantToken: 'unique_merchant_id_from_your_db' }),
                });
                const { accessToken, expiresAt } = await res.json();
                ```
</CodeBlockTab>
</CodeBlockTabs>

                ```json title="200 OK"
                {
                    "accessToken": "...",
                    "tokenType": "Bearer",
                    "expiresAt": "2026-01-13T16:30:59Z"
                }
                ```

                | Code | Description |
                |------|-------------|
                | `401` | Invalid or expired API token. |
                | `403` | Access to the merchant is not permitted. |

                **Renew before `expiresAt`.** Call `POST /ecr/auth/refresh` with the current, still-valid
                `accessToken` in the `Authorization` header. It returns the same body with a new token; store it
                and use it from then on.

                
<CodeBlockTabs defaultValue="curl" groupId="cloud-accept-client" persist>
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

                
<CodeBlockTabsTrigger value="typescript">
TypeScript
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

                
<CodeBlockTab value="curl">
```bash
                curl -X 'POST' 'https://api.tapaya.com/ecr/auth/refresh' \
                -H 'Authorization: Bearer ACCESS_TOKEN'
                ```
</CodeBlockTab>

                
<CodeBlockTab value="typescript">
```typescript
                const res = await fetch('https://api.tapaya.com/ecr/auth/refresh', {
                    method: 'POST',
                    headers: { Authorization: `Bearer ${accessToken}` },
                });
                const renewed = await res.json(); // { accessToken, tokenType, expiresAt }
                ```
</CodeBlockTab>
</CodeBlockTabs>

                | Code | Description |
                |------|-------------|
                | `401` | The access token is invalid, expired, or revoked. Exchange a new one with `POST /ecr/auth`. |
                | `403` | You no longer have access to the merchant. No new token is issued. |

                ### Find a Ready Device [#find-a-ready-device]

                List the merchant's devices with `GET /ecr/devices`. Add `?connected=true` to leave out
                disconnected devices, or fetch one device with `GET /ecr/devices/{externalDeviceId}`.

                
<CodeBlockTabs defaultValue="curl" groupId="cloud-accept-client" persist>
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

                
<CodeBlockTabsTrigger value="typescript">
TypeScript
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

                
<CodeBlockTab value="curl">
```bash
                curl 'https://api.tapaya.com/ecr/devices/till-01' \
                -H 'Authorization: Bearer ACCESS_TOKEN'
                ```
</CodeBlockTab>

                
<CodeBlockTab value="typescript">
```typescript
                const res = await fetch('https://api.tapaya.com/ecr/devices/till-01', {
                    headers: { Authorization: `Bearer ${accessToken}` },
                });
                const device = await res.json();
                const canPay = device.availability === 'ready';
                ```
</CodeBlockTab>
</CodeBlockTabs>

                ```json title="200 OK"
                {
                    "externalDeviceId": "till-01",
                    "name": "Front counter",
                    "connected": true,
                    "availability": "ready",
                    "lastSeenAt": "2026-01-13T16:30:59Z",
                    "updatedAt": "2026-01-13T16:30:59Z"
                }
                ```

                Send payments only to a device whose `availability` is `ready`. The list is a snapshot:
                availability is checked again when you submit, so a `ready` device can still turn a request
                down. See [Device availability](#device-availability).

                ### Submit a Payment Request [#submit-a-payment-request]

                Send the amount to a device with `POST /ecr/payment-requests`. Tapaya stores the request and
                notifies the device, which shows the payment screen.

                
<CodeBlockTabs defaultValue="curl" groupId="cloud-accept-client" persist>
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

                
<CodeBlockTabsTrigger value="typescript">
TypeScript
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

                
<CodeBlockTab value="curl">
```bash
                curl -X 'POST' 'https://api.tapaya.com/ecr/payment-requests' \
                -H 'Content-Type: application/json' \
                -H 'Authorization: Bearer ACCESS_TOKEN' \
                -H 'Idempotency-Key: order-1042-attempt-1' \
                -d '{
                        "externalDeviceId": "till-01",
                        "amount": 12500,
                        "tipAmount": 500,
                        "currency": "CZK"
                    }'
                ```
</CodeBlockTab>

                
<CodeBlockTab value="typescript">
```typescript
                const res = await fetch('https://api.tapaya.com/ecr/payment-requests', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        Authorization: `Bearer ${accessToken}`,
                        'Idempotency-Key': 'order-1042-attempt-1',
                    },
                    body: JSON.stringify({
                        externalDeviceId: 'till-01',
                        amount: 12500, // 125.00 Kč
                        tipAmount: 500, // 5.00 Kč
                        currency: 'CZK',
                    }),
                });
                const { requestId } = await res.json(); // 202 Accepted
                ```
</CodeBlockTab>
</CodeBlockTabs>

                **Parameters:**

                | Field | Type | Required | Description |
                |-------|------|----------|-------------|
                | `externalDeviceId` | `string` | ✓ | The paired device that should show the payment. |
                | `amount` | `integer` | ✓ | Amount in the currency's smallest unit (`12500` is 125.00 Kč). |
                | `tipAmount` | `integer` | | Tip in the currency's smallest unit. |
                | `currency` | `string` | ✓ | ISO 4217 currency code. |
                | `paymentToken` | `string` | | An existing payment to attach the request to. |

                ```json title="202 Accepted"
                {
                    "requestId": "...",
                    "status": "pending",
                    "paymentToken": null,
                    "expiresAt": "2026-01-13T16:30:59Z"
                }
                ```

                
<Callout title="202 is not a payment result" type="warn">
`202 Accepted` means Tapaya has stored the request. It does not mean the device has seen it
                or that the customer has paid. Anything that fails later reaches you as a status change.
</Callout>

                **Make retries safe.** The `Idempotency-Key` header is required. Reusing a key with the same body
                returns the original request instead of starting a second payment; reusing it with a different
                body returns `409 idempotency_conflict`. Tie the key to the sale and attempt, as in
                `order-1042-attempt-1`.

                ### Track the Result [#track-the-result]

                Follow the request through its [statuses](#request-statuses) with webhooks, or poll
                `GET /ecr/payment-requests/{requestId}`. Once it reaches `payment_created`, the response carries
                the `paymentToken`, and `payment.updated` events report the payment's own progress.

                To receive webhooks, register your HTTPS endpoint with `POST /ecr/webhook-subscriptions`, or set the
                callback URL and event types for the merchant in the Tapaya Platform.

                
<CodeBlockTabs defaultValue="curl" groupId="cloud-accept-client" persist>
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

                
<CodeBlockTabsTrigger value="typescript">
TypeScript
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

                
<CodeBlockTab value="curl">
```bash
                curl -X 'POST' 'https://api.tapaya.com/ecr/webhook-subscriptions' \
                -H 'Content-Type: application/json' \
                -H 'Authorization: Bearer ACCESS_TOKEN' \
                -d '{
                        "url": "https://integrator.example.com/webhooks/tapaya",
                        "events": ["payment_request.updated", "payment.updated"]
                    }'
                ```
</CodeBlockTab>

                
<CodeBlockTab value="typescript">
```typescript
                const res = await fetch('https://api.tapaya.com/ecr/webhook-subscriptions', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        Authorization: `Bearer ${accessToken}`,
                    },
                    body: JSON.stringify({
                        url: 'https://integrator.example.com/webhooks/tapaya',
                        events: ['payment_request.updated', 'payment.updated'],
                    }),
                });
                const { subscriptionId, signingSecret } = await res.json(); // 201 Created
                ```
</CodeBlockTab>
</CodeBlockTabs>

                ```json title="201 Created"
                {
                    "subscriptionId": "...",
                    "url": "https://integrator.example.com/webhooks/tapaya",
                    "events": ["payment_request.updated", "payment.updated"],
                    "signingSecret": "..."
                }
                ```

                
<Callout title="Store the signing secret" type="warn">
`signingSecret` is returned only when the subscription is created. Store it securely; you
                need it to verify the signature of incoming webhooks.
</Callout>

                A subscription belongs to the integrator and merchant, not to an access token, so it survives
                token renewal. Answer each event with a `2xx` once you've accepted it.

                
<Callout title="Verify before you close the sale" type="error">
Webhooks are notifications, not proof of payment, and one can arrive late or not at all. Never
                close a sale on a webhook alone:

                - **When a webhook arrives,** confirm the final result through the API, for example with
                  [Retrieve Payment Details](/platform-api/reporting#retrieve-payment-details).
                - **When no webhook arrives** within a timeout that suits your checkout flow, and no later
                  than the request's `expiresAt`, call `GET /ecr/payment-requests/{requestId}` to read its
                  current status, then confirm the payment through the API as above.
</Callout>

            </div>
</section>

## Reference [#reference]

Look up endpoints, statuses, errors, and webhook events.

<Accordions type="multiple">
<Accordion title="Endpoints" id="endpoints">
| Method | Endpoint | Description |
|---|---|---|
| `POST` | `/ecr/auth` | Exchanges your API token and a `merchantToken` for an access token. |
| `POST` | `/ecr/auth/refresh` | Renews a still-valid access token. |
| `GET` | `/ecr/devices` | Lists the merchant's devices. Optional `connected=true` filter. |
| `GET` | `/ecr/devices/{externalDeviceId}` | Returns one device and its current availability. |
| `POST` | `/ecr/payment-requests` | Stores a payment request and notifies the device. Requires `Idempotency-Key`. |
| `GET` | `/ecr/payment-requests/{requestId}` | Returns the request status, any rejection reason, and the `paymentToken`. |
| `POST` | `/ecr/webhook-subscriptions` | Registers an HTTPS URL and event types. Returns the signing secret once. |
| `GET` | `/ecr/webhook-subscriptions` | Lists your subscriptions for the merchant, without signing secrets. |
| `DELETE` | `/ecr/webhook-subscriptions/{subscriptionId}` | Removes a subscription. |
</Accordion>

<Accordion title="Device availability" id="device-availability">
Both device endpoints return `externalDeviceId`, `name`, `connected`, `availability`, `lastSeenAt`, and
`updatedAt`.

| Value | Description |
|---|---|
| `ready` | Connected, and able to receive and display a request. |
| `busy` | Processing a payment, or holding an active request. |
| `unavailable` | Disconnected, without a valid session, or unable to show the payment screen. |
</Accordion>

<Accordion title="Request statuses" id="request-statuses">
| Status | Description |
|---|---|
| `pending` | Stored and waiting for the device to accept it. |
| `acknowledged` | The device has received it; the payment may not exist yet. |
| `payment_created` | A payment and its `paymentToken` exist. Track further progress on the payment. |
| `rejected` | The device or Tapaya turned the request down. |
</Accordion>

<Accordion title="Errors" id="errors">
| Code | Reason | Description |
|---|---|---|
| `403` / `404` | Object unavailable | You lack permission, or the object does not exist. |
| `409` | `device_busy` | The device already has an active request or payment. |
| `409` | `device_unavailable` | The device is connected but not ready. |
| `409` | `idempotency_conflict` | The key was already used with a different body. |
| `503` | `device_offline` | The device is not connected. |

Amount and currency validation errors follow the same conventions as the rest of the
[Platform API](/platform-api).
</Accordion>

<Accordion title="Webhook events" id="webhook-events">
| Event | Sent when | `data` contents |
|---|---|---|
| `device.connected` | A device opens a new live connection. | `externalDeviceId`, `connected`, `availability`, `lastSeenAt` |
| `device.disconnected` | The connection closes or the liveness check times out. | `externalDeviceId`, `connected`, `availability`, `lastSeenAt` |
| `device.availability_changed` | Availability moves between `ready`, `busy`, and `unavailable`. | `externalDeviceId`, `availability`, optional `reason` |
| `payment_request.updated` | The request is stored, acknowledged, rejected, expires, or gets a payment. | `requestId`, `externalDeviceId`, `status`, `paymentToken`, `reference`, `reason`, `expiresAt` |
| `payment.updated` | The payment's status changes. | `paymentToken`, `requestId`, `externalDeviceId`, `status`, `reference`, `amount`, `currency`, optional `receiptUrl` |

Every event arrives as an HTTP `POST` in the same envelope:

```json
{
    "eventId": "...",
    "type": "payment_request.updated",
    "occurredAt": "2026-01-13T16:30:59Z",
    "data": {
        "requestId": "...",
        "externalDeviceId": "till-01",
        "status": "acknowledged",
        "paymentToken": null,
        "reference": "ORDER-1042",
        "reason": null,
        "expiresAt": "2026-01-13T16:30:59Z"
    }
}
```
</Accordion>
</Accordions>