Skip to Content

Authentication

Authenticate requests with a secret API key.

Every request to /v1/* carries an API key in the Authorization header:

Authorization: Bearer cp_live_xxx

Managing keys

Create keys in the merchant console under API 密钥 (API keys). Each merchant can have up to 3 keys, so you can rotate without downtime: create a new key, deploy it, then delete the old one.

  • The full key is shown once, when it is created. Afterwards only its first characters are visible.
  • Deleting a key takes effect immediately. Requests with it fail with 401 UNAUTHORIZED.
  • The console shows how many requests each key has made and when it was last used.
  • Every order records the key that created it.

Keeping keys secret

An API key can create orders and read every order of your account. Keep it on your server:

  • Load it from an environment variable or a secret manager. Don't commit it to source control.
  • Never send it to a browser or ship it in a mobile app.
  • If a key leaks, delete it in the console and create a new one.

Errors

StatusCodeMeaning
401UNAUTHORIZEDThe header is missing, or the key is invalid or deleted.
409MERCHANT_DISABLEDYour merchant account is disabled. Contact us.

On this page