Skip to main content

Authentication

The Roboticks API supports multiple authentication methods for different use cases.

Authentication Methods

MethodUse CaseToken Type
JWT TokenWeb app, short-lived sessionsBearer token
API KeyCI/CD, automation, long-lived accessAPI key

API Key Authentication

API keys are recommended for automation and CI/CD pipelines.

Creating an API Key

  1. Go to Settings > API Keys in the Roboticks web app
  2. Click Create API Key
  3. Enter a descriptive name
  4. Copy the key (it won’t be shown again)

Using API Keys

Include the API key in the Authorization header:
curl -H "Authorization: Bearer rbtk_xxxxxxxxxxxxxxxx" \
     https://api.roboticks.io/api/v1/organizations/acme/devices
Or use the X-API-Key header:
curl -H "X-API-Key: rbtk_xxxxxxxxxxxxxxxx" \
     https://api.roboticks.io/api/v1/organizations/acme/devices

API Key Permissions

API keys inherit the permissions of the user who created them. Keys can access:
  • Organizations the user belongs to
  • Projects the user has access to
  • Resources within those projects

API Key Best Practices

Never commit API keys to version control or share them in plain text.
  • Use environment variables in CI/CD
  • Rotate keys regularly (at least quarterly)
  • Use descriptive names to track usage
  • Delete unused keys promptly
  • Create separate keys for different systems

JWT Token Authentication

JWT tokens are used by the web app and CLI for interactive sessions.

Obtaining a Token

Use the CLI login flow:
rbtk login
Or authenticate via the API:
POST /api/v1/auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "your-password"
}
Response:
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "bearer",
  "expires_in": 3600
}

Using JWT Tokens

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
     https://api.roboticks.io/api/v1/organizations/acme/devices

Token Refresh

Tokens expire after 1 hour. Refresh before expiration:
POST /api/v1/auth/refresh
Authorization: Bearer YOUR_CURRENT_TOKEN

Organization and Project Context

Most API endpoints require organization and project context in the URL:
/api/v1/organizations/{org_slug}/projects/{project_slug}/devices
Example:
GET /api/v1/organizations/acme/projects/warehouse/devices

Rate Limiting

Rate limits are applied per API key or user:
Response HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRemaining requests
X-RateLimit-ResetUnix timestamp when limit resets
When rate limited, you’ll receive a 429 response:
{
  "detail": "Rate limit exceeded. Try again in 60 seconds.",
  "retry_after": 60
}

Error Handling

401 Unauthorized

Token is missing, invalid, or expired:
{
  "detail": "Could not validate credentials"
}
Solution: Check your token or API key, refresh if expired.

403 Forbidden

Valid credentials but insufficient permissions:
{
  "detail": "Not enough permissions"
}
Solution: Verify you have access to the requested resource.

Code Examples

import requests

API_KEY = "rbtk_xxxxxxxxxxxxxxxx"
BASE_URL = "https://api.roboticks.io/api/v1"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# List devices
response = requests.get(
    f"{BASE_URL}/organizations/acme/projects/warehouse/devices",
    headers=headers
)
devices = response.json()

Next Steps

Fleet API

Manage devices with the Fleet API