Overview
Every request authenticates with a bearer token in the Authorization header. Integrations use API tokens: long-lived tokens that belong to an API application in your organization and carry a set of scopes. API tokens start with stl_sk_.
Each endpoint applies its own access rules. Endpoints that act on behalf of a signed-in person do not accept API tokens and respond with 401 or 403. Use GET /v1/auth/token-info to check what a token is and which scopes it has.
Creating an API Token
An organization Owner or Admin creates API applications and tokens with the API Tokens endpoints, signed in with their Stable account:
- Create an application with
POST /v1/organizations/{org_public_id}/applications, giving it a name and its scopes. - Create a token with
POST /v1/applications/{app_public_id}/tokens, giving it a name and an optional expiry date. - Copy the token from the response. The full token is shown only when it is created or rotated.
Creating, rotating and revoking tokens can ask the signed-in person to confirm with two-factor authentication first. See the API reference for the exact request and response fields.
Making Authenticated Requests
Send the token in the Authorization header:
curl https://api.stable.se/v1/auth/token-info \
-H "Authorization: Bearer stl_sk_your_api_token"
API Scopes
Scopes control what a token can access. Each scope has the form action:resource. Reading (GET) needs the read: scope; creating, changing and deleting need the write: scope. A write: scope includes the matching read: scope, so write:horses grants both. Role and resource permissions still apply on top of scopes.
| Read Scope | Write Scope | Description |
|---|---|---|
read:horses | write:horses | Horse profiles, health records, ownership |
read:bookings | write:bookings | Reservations and booking management |
read:invoices | write:invoices | Invoices and payment information |
read:organization | write:organization | Organization members and roles |
read:tasks | write:tasks | Task series, instances, and workflows |
read:calendar | write:calendar | Calendar events and scheduling |
read:training | write:training | Training programs and sessions |
read:pim | write:pim | Product catalog and inventory |
read:equipment | write:equipment | Equipment tracking |
read:documents | write:documents | Document storage and management |
read:expenses | write:expenses | Expense tracking |
read:locations | write:locations | Locations, stalls, paddocks |
read:consumables | write:consumables | Consumable supplies tracking |
read:messaging | write:messaging | Messaging and communications |
admin:* | -- | All of the scopes above |
Principle of Least Privilege
Only request the scopes your integration needs. You can create separate applications and tokens with different scopes for different purposes.
Error Responses
Missing Authentication
{
"status": "401 Unauthorized",
"message": "Authentication required",
"code": "unauthorized"
}
Insufficient Scopes
{
"status": "403 Forbidden",
"message": "Missing required scope: ReadHorses",
"code": "forbidden"
}
Invalid Token
A token that is unknown, expired or revoked gets a 401 with a reason:
{
"status": "401 Unauthorized",
"message": "Invalid API token",
"code": "UNAUTHORIZED",
"reason": "token_invalid"
}
Check the HTTP status first. Compare code without regard to case: both unauthorized and UNAUTHORIZED mean the request was not authenticated.
Token Security Best Practices
- Never commit tokens to source control
- Store tokens in environment variables or a secrets manager
- Rotate tokens periodically
- Use separate tokens for development and production
- Revoke tokens immediately if compromised
- Review when each token was last used