Skip to main content

Authentication

The sajn API uses API keys to authenticate requests. All API requests must include your API key in the Authorization header.

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:
curl https://app.sajn.se/api/v1/documents \
  -H "Authorization: Bearer YOUR_API_KEY"

Example with Different Languages

const axios = require('axios');

const response = await axios.get('https://app.sajn.se/api/v1/documents', {
  headers: {
    'Authorization': `Bearer ${process.env.SAJN_API_KEY}`
  }
});

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:
{
  "message": "Invalid or missing API key"
}
Common authentication errors:
ErrorDescription
401 UnauthorizedAPI key is missing, invalid, or expired
403 ForbiddenAPI key doesn’t have permission for this resource

Rate Limiting

API requests are rate limited per API key:
  • 100 requests per minute
  • 1000 requests per hour
Rate limit information is included in response headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
When you exceed the rate limit, you’ll receive a 429 Too Many Requests response.
I