Ir al contenido

Authentication

Esta página aún no está disponible en tu idioma.

Resource requests to the BenchKey API require an API key. API access requires the Business plan and must be enabled for your environment. An authorized workspace administrator creates keys in Settings and can set an expiry or revoke them. The service metadata, health, and OpenAPI endpoints do not require a key.

Every key begins with a prefix that identifies its mode:

PrefixModeWhen to use
bk_live_LiveProduction requests that affect real data
bk_test_Test labelLabels an integration key; accesses the same workspace data as a live key

A live key looks like:

bk_live_42_kvWz9nP3mRqTs7uYeBfGhDjLa0123456789ABCD

A test label does not create a sandbox. Both key prefixes access the tenant encoded in the key. Writes with a bk_test_ key can change that workspace’s real records and trigger its normal side effects. Use a separate workspace with fictional data for development, and confirm its identity with GET /api/v1/me before writing.

  1. Go to Settings → API keys in BenchKey.
  2. Click Create key.
  3. Enter a Name (e.g., My Integration), choose the Environment label, and set Expiration.
  4. Choose the Scopes your integration needs, only grant what you actually use, then select Create key.
  5. Copy the key immediately. For security, the full secret is shown only once.

If you lose a key, revoke it and create a new one.

Pass your API key as a Bearer token in the Authorization header:

Authorization: Bearer bk_live_42_kvWz9nP3mRqTs7uYeBfGhDjLa0123456789ABCD
Terminal window
curl https://app.benchkey.com/api/v1/me \
-H "Authorization: Bearer bk_live_42_kvWz9nP3mRqTs7uYeBfGhDjLa0123456789ABCD"
const res = await fetch("https://app.benchkey.com/api/v1/me", {
headers: {
Authorization: "Bearer bk_live_42_kvWz9nP3mRqTs7uYeBfGhDjLa0123456789ABCD",
},
});
const data = await res.json();

Each API key carries a set of scopes that limit what it can do. A scope takes the form <resource>.<read|write>, read grants list/retrieve, write grants create/update/delete and action endpoints. Every endpoint’s reference page states the scope it requires.

The full catalog:

ScopesCovers
account.read / account.writeAccount profile
appointments.read / appointments.writeAppointments, including slots
assets.read / assets.writeAssets (customer devices)
billing.read / billing.writeBilling (your BenchKey subscription)
canned_responses.read / canned_responses.writeCanned responses
customers.read / customers.writeCustomers
estimates.read / estimates.writeEstimates
files.readFiles (read-only)
inventory.read / inventory.writeInventory stock levels
invoices.read / invoices.writeInvoices
leads.read / leads.writeLeads, plus the lead status registry
locations.read / locations.writeLocations
memberships.read / memberships.writeMemberships plans and enrollments
messages.read / messages.writeMessages and conversations
notifications.read / notifications.writeNotifications
payments.read / payments.writePayments
products.read / products.writeProducts
purchase_orders.read / purchase_orders.writePurchase orders
reports.readReports (read-only)
reviews.read / reviews.writeReviews
services.read / services.writeServices
settings.read / settings.writeSettings
shipments.read / shipments.writeShipments
store_credit.readStore credit (read-only)
tags.read / tags.writeTags
tax.read / tax.writeTax classes
team.read / team.writeRoles discovery, plus team-member profile/role updates
tickets.read / tickets.writeTickets, plus the status catalog and queues
timeclock.read / timeclock.writeTimeclock shifts and payroll
users.read / users.writeUsers (team roster)
vendors.read / vendors.writeVendors
warranty.read / warranty.writeWarranty claims
webhooks.read / webhooks.write / webhooks.manageWebhooks, manage additionally allows rotating signing secrets

If a request is made with a key that lacks the required scope, the API returns 403 Forbidden with error code insufficient_scope. Note that webhook subscriptions are additionally scope-gated by the read scope of each event family they subscribe to.

Use a dedicated development workspace and a key with only the scopes needed for the task. Changing a key’s prefix does not change its data destination. Before a production cutover, verify the tenant returned by GET /api/v1/me and the granted scopes.

The response’s BenchKey-Version identifies the API implementation in both modes; sending the header does not select an older implementation.

  • Never expose keys client-side. API keys carry your shop’s full permissions for the scopes they hold. Never embed them in browser JavaScript, mobile apps, or public repositories.
  • Use the minimum scopes needed. Create separate keys for separate integrations, each with only the scopes it requires. This limits blast radius if a key is compromised.
  • Rotate keys periodically. Revoke old keys from Settings and issue new ones. The API will return 401 Unauthorized for revoked keys immediately, no propagation delay.
  • Store keys in environment variables. Never hardcode them in source files.
.env
BENCHKEY_API_KEY=bk_live_42_kvWz9nP3mRqTs7uYeBfGhDjLa0123456789ABCD
const apiKey = process.env.BENCHKEY_API_KEY;

Even with a valid key, requests are blocked when your account has a billing or suspension problem:

HTTP statusError codeMeaning
402billing_subscription_requiredThe tenant’s subscription is inactive (past-due, canceled, or no active plan). details includes billing_required, reason, subscription_status, and current_period_end. Restore billing to resume API access.
503tenant_suspendedThe account has been administratively suspended. API access is unavailable until the account is reinstated.

These errors fire after authentication succeeds, the key itself is valid.

HTTP statusError codeMeaning
401unauthorizedKey is missing, malformed, or revoked
402billing_subscription_requiredSubscription inactive, see Account status
403insufficient_scopeKey lacks the required scope for this endpoint
503tenant_suspendedAccount suspended, see Account status

See Errors for the full error envelope format.

Estado del sistema