Skip to Content
Paycose Docs
Setup

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"

$WALLET is the API base, https://api.paycose.com/api/v1/app1/platform/wallet. app1 is 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.

The Service Accounts list

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

Naming a new service account

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

The new secret key, shown once

Each service account has a key pair:

KeyFormatUse
Secret keysk_test_ or sk_live_ + 43 charactersServer-side only. Authenticates every API request.
Publishable keypk_test_ or pk_live_ + 32 charactersClient-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 Test mode switch in the Dashboard

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

HeaderRequiredValue
AuthorizationAlwaysBearer followed by your secret key
X-CountryAlwaysThe two-letter code of the country you operate in, e.g. TH. It selects the country's configuration: currency, providers and balances.
Content-TypeRequests with a bodyapplication/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:

CodeHTTPMeaningWhat to do
E1213401No Authorization headerSend Authorization: Bearer <secret key>.
E1211401The key is invalid, rolled or deactivatedCheck the key, or roll a new one in the Dashboard.
E1200401Authentication is requiredSend a key.
E3105404No configuration for the X-Country you sentSend a country your account operates in.
E1300403The key's permissions do not cover this endpointGrant the permission on the service account.
E1304403Live mode needs a verified accountFinish account verification.
E1307403Dashboard-only or payer-only endpointDo this in the Dashboard, or let the payer's checkout call it.

On this page