# API reference

> How to call the TapPay API: authentication, versions, idempotency, request signing and the shape of responses and errors.

Source: https://docs.tappay.mn/reference/

## Base URL and version {#base-url}

Call the API over HTTPS at `https://api.tappay.mn`. Send the `TapPay-Version` header with a version date such as `2026-09-27` to keep the behavior you built against. If you leave it out, TapPay uses the latest version.

## Authentication {#authentication}

Send your key as `Authorization: Bearer YOUR_SECRET_KEY`. A [secret key](https://docs.tappay.mn/glossary.md#secret-key) belongs on your server and works for every operation its [scopes](https://docs.tappay.mn/glossary.md#scope) allow. A [publishable key](https://docs.tappay.mn/glossary.md#publishable-key) may be used in a browser and works only for the checkout script operations. [Sandbox](https://docs.tappay.mn/glossary.md#sandbox) and [production](https://docs.tappay.mn/glossary.md#production) keys are separate, and a sandbox key never touches real money.

## Idempotency {#idempotency}

Every POST request needs an `Idempotency-Key` header with a unique value, for example a UUID. Repeating a request with the same key returns the first result instead of doing the work again. Reusing a key with a different body is rejected with a 409 error.

## Request signing {#request-signing}

When request signing is enabled for your key, each request also carries `TapPay-Timestamp`, `TapPay-Nonce` and `TapPay-Signature`. The [signature](https://docs.tappay.mn/glossary.md#signature) is `v1=` plus the base64 HMAC-SHA256 of the canonical string `METHOD`, path with query, timestamp, nonce and the SHA-256 hex of the body, one per line. TapPay signs its webhooks the same way, as shown in the [webhooks guide](https://docs.tappay.mn/guides/webhooks.md#verify-the-signature).

## Responses {#responses}

A successful response has `success` set to true and the result in `data`. List operations return a page of results with `hasMore` and a cursor to continue. Money amounts are strings, and times are ISO 8601 in UTC.

## Errors {#errors}

A failed response has `success` set to false and an `error` object with a `code` such as `AUTH-058`, a readable `message`, a `messageKey` and a `traceId`. Quote the `traceId` when you contact support. Every operation page lists the [error codes](https://docs.tappay.mn/glossary.md#error-code) it can return.
