Authentication
Authenticate API requests with a secret key â test or live mode, the X-Country header, key formats and authentication errors.
Your server talks to the PaymentGateway API with a secret key. Send it as a bearer token on every request, together with the country you operate in:
curl "$WALLET/payment_intents" \
-H "Authorization: Bearer ${SECRET_KEY}" \
-H "X-Country: TH"
$WALLETis the API base,https://api.paycose.com/api/v1/app1/platform/wallet.app1is a fixed path segment, not your application id â the key already identifies your account. See the Quick guide.
Keys
You create keys in the Dashboard under Developer â Service Accounts â New Key.
Open Developer â Service Accounts. Each row is one key pair; the secret key is never listed.

Choose New Key and give the service account a name you will recognise, such as the server that uses it.

Copy the secret key now: this is the only time it is shown.

Each service account has a key pair:
| Key | Format | Use |
|---|---|---|
| Secret key | sk_test_ or sk_live_ + 43 characters | Server-side only. Authenticates every API request. |
| Publishable key | pk_test_ or pk_live_ + 32 characters | Client-side, for the Checkout SDK only. It cannot call the API on its own. |
The secret key is shown once, when it is created. Store it in your secret manager straight away. If it is lost or leaked, use Roll secret key on the service account: a new key is issued and the old one stops working.
Never put a secret key in browser or mobile code, a repository or a log.
Test and live mode
The key decides the mode: a sk_test_ key works with test data and a sk_live_
key with live data. In the Dashboard, the Test mode switch chooses which keys and data you see.

The two modes are stored separately, so a test key can never move
real money. Every object carries livemode so you can confirm which one you
reached:
{ "id": "pi_9b2fâŚ", "object": "payment_intent", "livemode": false }A live key needs a verified account.
Required headers
| Header | Required | Value |
|---|---|---|
Authorization | Always | Bearer followed by your secret key |
X-Country | Always | The two-letter code of the country you operate in, e.g. TH. It selects the country's configuration: currency, providers and balances. |
Content-Type | Requests with a body | application/json |
What a secret key can call
A secret key reaches the merchant API: payments, refunds, customers, products
and prices, invoices, quotes, subscriptions, payouts, webhooks and
the rest of the API reference. Managing team members, roles, keys and
provider credentials stays in the Dashboard; a secret key calling one of those
endpoints gets E1307. A secret key also gets E1307 on the payer-only /onetime/*
routes that hosted checkout and payment links call with the payer's session; they are
not part of the API. The test helpers under /internal/test/ work only in test mode;
a sk_live_ key gets 403 with E1305.
Authentication errors
Errors come back in the standard error body:
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
E1213 | 401 | No Authorization header | Send Authorization: Bearer <secret key>. |
E1211 | 401 | The key is invalid, rolled or deactivated | Check the key, or roll a new one in the Dashboard. |
E1200 | 401 | Authentication is required | Send a key. |
E3105 | 404 | No configuration for the X-Country you sent | Send a country your account operates in. |
E1300 | 403 | The key's permissions do not cover this endpoint | Grant the permission on the service account. |
E1304 | 403 | Live mode needs a verified account | Finish account verification. |
E1307 | 403 | Dashboard-only or payer-only endpoint | Do this in the Dashboard, or let the payer's checkout call it. |
Crypto payments (x402)
Accept USDC on Base for x402 machine payments. Paycose gives you deposit addresses and holds the USDC; you record each payment, and refunds and payouts go out on-chain.
Core concepts
The resource model, identifiers, livemode, pagination, idempotency, the API version, expand, and multi-tenancy basics every integrator should know.