Skip to content
viraj
Browse documentation

Core concepts

Authentication

API keys, scopes, rotation and how to keep secrets out of browsers.

API keys

Authenticate server-to-server requests with a bearer token. Keys are prefixed vk_test_ or vk_live_ and are shown exactly once when created.

Store keys in a secret manager. A key grants access to every location in its scope, so treat it like a database password.

bash
Authorization: Bearer vk_live_4f9c...

Scopes

Grant the smallest set of scopes that makes the integration work. Scopes are checked on every request and cannot be widened after the fact.

  • catalog:read, catalog:write — products, variants, price books.
  • orders:read, orders:write — checkout, returns, fulfilment.
  • inventory:read, inventory:write — stock, transfers, counts.
  • finance:read — journals and settlement. Read-only by design.
  • webhooks:manage — create and rotate endpoints and secrets.

Rotation

Create the replacement key, deploy it, then revoke the old key. Keys can coexist; revocation takes effect within seconds across every region.

If a key leaks, revoke first and investigate second. Every use is attributable in the audit log by key id.

Never ship a secret key to a browser

Secret keys are server-side credentials. For browser checkouts, create a short-lived session token on your server and pass only that token to the client.

ts
// server only
const session = await viraj.checkout.sessions.create({
  cartId: 'cart_82f1',
  successUrl: 'https://example.com/order/complete',
})

return Response.json({ clientSecret: session.client_secret })