Skip to main content

Authentication

This page covers API keys — the right credential for a server integration against your own sajn account. Every request carries the key in the Authorization header. The API also accepts OAuth 2.0 bearer tokens, which is how integrations that connect to many sajn customers’ accounts authenticate. If you are not sure which applies to you, read Choosing an authentication method first — it takes a minute and saves rebuilding later.
An API key is bound to a single workspace, chosen when you create it. You never send a workspace id with your requests. Call GET /api/v1/me to confirm which workspace and organization a key points at.

Getting Your API Key

  1. Log in to your sajn account at app.sajn.se
  2. Navigate to Organization Settings > API Keys
  3. Click Create API Key
  4. Copy your API key and store it securely
Never share your API key or commit it to version control. Treat it like a password.

Making Authenticated Requests

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

Example with Different Languages

API Key Security Best Practices

Store API keys in environment variables or secure credential management systems, never in code.
Rotate your API keys periodically to minimize the impact of potential compromises.
Use different API keys for development, staging, and production environments.
Regularly review API key usage in your sajn dashboard to detect unauthorized access.

Error Responses

If authentication fails, you’ll receive a 401 Unauthorized response:
Common authentication errors:

Rate Limiting

API requests are rate limited per organization, with limits that scale with your plan. There is a per-minute burst limit and a rolling 24-hour volume limit; higher plans get higher limits. Read your current limits from the response headers rather than hard-coding them — they’re included on every response:
When you exceed either limit you’ll receive a 429 Too Many Requests response with a Retry-After header. Clients should back off and retry after the indicated delay. If you consistently hit your limits, upgrade your plan for higher throughput.