BchainPayBchainPay

Authentication

BchainPay uses bearer API keys. Include your key in the Authorization header on every request:

curl https://api.bchainpay.com/v1/payment-intents \
  -H "Authorization: Bearer $BCHAINPAY_API_KEY"

Mutating endpoints (POST, PUT, PATCH) also require Content-Type: application/json and an Idempotency-Key header — see Idempotency.

Key types

FieldTypeRequiredDescription
sk_live_…SecretoptionalProduction key. Full read/write access to the live merchant account.
sk_sb_…SecretoptionalSandbox key. Full read/write access to the sandbox merchant account. Use this for development and testing.
pk_live_…PublicoptionalProduction public key. Read-only. Safe to use in client-side code — cannot create or modify resources.

Obtaining keys

  1. Sign in to the BchainPay dashboard.
  2. Navigate to Settings → API Keys.
  3. Select the environment — Production or Sandbox.
  4. Click Create key and copy the value immediately. The full key is only shown once.

Rotating keys

Rotate keys without downtime using this procedure:

  1. Issue a new key in the dashboard (Settings → API Keys → Create key).
  2. Deploy the new key to your servers alongside the old one.
  3. Cut over traffic to the new key.
  4. Revoke the old key from the dashboard.

Revocations take effect immediately. Do not revoke the old key until all in-flight requests have completed.

Required headers

Every API request needs the Authorization header. POST requests need two additional headers:

HeaderRequired onExample
AuthorizationAll requestsBearer sk_live_abc123…
Content-TypePOST, PUT, PATCHapplication/json
Idempotency-KeyPOST, PUT, PATCH550e8400-e29b-41d4-a716-446655440000

Auth errors

StatusCodeMeaning
401missing_authorizationAuthorization header is absent or missing the Bearer prefix.
401invalid_api_keyAPI key is not found, malformed, or revoked.
403forbiddenKey does not have permission for this operation (e.g., a pk_live_ key on a write endpoint).
429rate_limitedPer-merchant rate limit exceeded. Retry with exponential backoff.

A 401 response returns:

{
  "error": {
    "code": "invalid_api_key",
    "message": "Invalid API key"
  },
  "request_id": "req_7f2a91bc4e3d"
}
Last updated Edit on GitHub