Get started
Authentication
Authenticate every request with a secret key. The key prefix chooses test or live.
Every developer API request carries your secret key as a bearer token.
Authenticated request
curl https://middleware.test.nextcba.com/api/v1/pg/v1/balance \
-H "Authorization: Bearer sk_test_your_key"Test and live keys
There is one base URL. The prefix on the key is the mode. A live key works only after live access is approved for the merchant.
| Key | Starts with | Money |
|---|---|---|
| Test | sk_test_ | Fake. Simulate to mark a payment paid. |
| Live | sk_live_ | Real, after live access is approved. |
Both keys are sent to https://middleware.test.nextcba.com/api/v1/pg/v1. The random part is 40 letters or digits: sk_test_ or sk_live_ followed by exactly 40 characters.
If you also send X-CSwitch-Pg-Environment, it must match the key. test with an sk_live_ key, or the reverse, is 400 with code PG_ENVIRONMENT_MISMATCH. You can leave the header off. The developer API reads the prefix.
Keeping keys safe
- Keep secret keys on your server. Never put them in a mobile app, a web page or a public repository.
- Store them in environment variables, not in code.
- The secret is shown once, when you create the key. After that the dashboard shows a masked key.
- Revoke a key in the dashboard if you think it has leaked. You can keep up to 10 active keys per environment.
CarefulA live secret key can take real payments. Treat it like the password to your merchant account.