Developer Docs

Authentication

API keys, bearer tokens, and secure request authentication.

BSync Public API uses API key authentication. There is no OAuth flow and no token issuance endpoint.

OpenAPI: ApiKeyAuth security scheme — /docs/api-reference

API Keys

API keys are created in the BSync Dashboard under Settings → API Keys. Each key is shown only once at creation.

PrefixEnvironmentUse
bsync_test_*Test (sandbox)Development and integration testing
bsync_live_*Live (production)Real payments

Test and live keys use the same API host (https://api.bsyncapp.com). The key prefix determines which environment your requests run in.

Authorization Header

Every authenticated request must include:

Authorization: Bearer {apiKey}

SDK (automatic):

import { BSync } from "@bsync/node-sdk";
 
const bsync = new BSync({ apiKey: "bsync_test_xxxxxxxx" });

curl:

curl https://api.bsyncapp.com/v1/payment-intents/pay_abc123 \
  -H "Authorization: Bearer bsync_test_xxxxxxxx"

Test vs Live

AspectTest (bsync_test_*)Live (bsync_live_*)
API hosthttps://api.bsyncapp.comhttps://api.bsyncapp.com
PaymentsSandbox — no real moneyReal Vodafone Cash transactions
WebhooksDelivered to your test endpointDelivered to your production endpoint
Data isolationTest payments onlyLive payments only

Using a test key against a live payment (or vice versa) returns 404 RESOURCE_NOT_FOUND (not ENVIRONMENT_MISMATCH) to avoid revealing whether a payment exists in another environment.

Key Rotation

  1. Create a new API key in the Dashboard.
  2. Update your server environment variable (BSYNC_API_KEY).
  3. Deploy the change.
  4. Revoke the old key once all services are updated.

Rotate keys periodically and immediately after any suspected compromise.

Key Revocation

Revoke keys in the Dashboard. Revoked keys return:

{
  "success": false,
  "error": {
    "code": "API_KEY_REVOKED",
    "type": "authentication_error",
    "message": "The provided API key has been revoked.",
    "requestId": "req_abc123",
    "details": {}
  }
}

HTTP status: 401

Security

  • Store API keys in environment variables or a secrets manager — never in source code or client-side code.
  • Use separate keys per service (checkout server, webhook processor, admin tools).
  • Grant least privilege: create keys with only the permissions each service needs.
  • Never expose keys in browser JavaScript, mobile apps, or public repositories.

See Security for the full security guide.

Error Codes

HTTPCodeTypeWhen
401MISSING_AUTHORIZATIONauthentication_errorNo Authorization header
401INVALID_AUTH_FORMATauthentication_errorHeader is not Bearer {key}
401INVALID_API_KEYauthentication_errorKey not found
401API_KEY_REVOKEDauthentication_errorKey was revoked
401API_KEY_EXPIREDauthentication_errorKey has expired
403TENANT_INACTIVEauthorization_errorMerchant account inactive
403INSUFFICIENT_PERMISSIONSauthorization_errorKey lacks permission
404RESOURCE_NOT_FOUNDresource_errorCross-environment access (test key on live payment, or vice versa)

SDK error classes: AuthenticationError (401), AuthorizationError (403).

Was this page helpful?

authentication

Command Palette

Search for a command to run...