> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.sevalla.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This is the Sevalla REST API reference. Base URL: https://api.sevalla.com/v3. Authenticate with an API key in the Authorization header as a Bearer token.
> The OpenAPI spec is at https://api.sevalla.com/v3/openapi.json. Concepts and dashboard guides are at https://docs.sevalla.com (index: https://docs.sevalla.com/llms.txt).
> To act on a Sevalla account from an AI agent, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md) or the Sevalla CLI (https://api-docs.sevalla.com/v3/cli.md).

# Authentication

> Authenticate Sevalla API requests with an API key sent as a bearer token, check what a key can do, and fix 401 and 403 responses.

Every request to the Sevalla API is authenticated with an API key, sent in the `Authorization` header as a bearer token. The key belongs to one company, and the request can only act on that company's services, with the permissions set on the key.

| Property | Value |
| - | - |
| Header | `Authorization: Bearer <API key>` |
| Key format | `svl_` followed by 64 hexadecimal characters |
| Scope | One company: the company the key was created in |
| Permissions | Checked on every request, so a change to the key applies to the next request |
| Transport | HTTPS. A plain `http://` request gets a `301` redirect to `https://`. |

## Create an API key

In the Sevalla dashboard, under **Tools**, click **API keys**, then click **Create API key**. Choose a predefined role (**Company viewer** is enough to read) or custom capabilities, and copy the key: it's shown only once. [API keys](https://docs.sevalla.com/developer-tools/api-keys#create-an-api-key) in the platform docs covers roles, capabilities, expiration and rotation. You can also create keys with [Create API key](https://api-docs.sevalla.com/v3/api-keys/create-api-key.md).

Create one key per integration or environment, so you can rotate or revoke one without breaking the others.

## Send the key

Keep the key in an environment variable and send it on every request:

```bash curl theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
curl https://api.sevalla.com/v3/applications \
  -H "Authorization: Bearer $SEVALLA_API_KEY"
```

```typescript TypeScript theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
const res = await fetch("https://api.sevalla.com/v3/applications", {
  headers: { Authorization: `Bearer ${process.env.SEVALLA_API_KEY}` },
});
const applications = await res.json();
```

Never put the key in code you commit, a URL or a browser app: anyone with the key can act on the company within its permissions.

## Check a key

Two operations work with any valid key, whatever its permissions:

| Operation | Returns |
| - | - |
| [Validate API key](https://api-docs.sevalla.com/v3/api-keys/validate-api-key.md) (`GET /api-keys/validate`) | The key's `name`, `expires_at`, `company_id` and `status` |
| [Get current API key](https://api-docs.sevalla.com/v3/api-keys/get-current-api-key.md) (`GET /api-keys/me`) | The key's details and `capabilities`: every permission it has, from its roles and custom capabilities, with the `resource_id` it's limited to (`null` for all resources) |

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
curl https://api.sevalla.com/v3/api-keys/me \
  -H "Authorization: Bearer $SEVALLA_API_KEY"
```

## Permissions

Each operation checks the permissions it needs, written `RESOURCE:ACTION`: [List applications](https://api-docs.sevalla.com/v3/applications/list-applications.md) needs `APP:READ`, [Trigger deployment](https://api-docs.sevalla.com/v3/applications/trigger-deployment.md) needs `APP:UPDATE`, and [Clone application](https://api-docs.sevalla.com/v3/applications/clone-application.md) needs both `APP:READ` and `APP:CREATE`. A key has a predefined role or custom capabilities, and a capability can be limited to specific resources. [Permissions](https://docs.sevalla.com/developer-tools/api-keys#permissions) in the platform docs lists the roles and capabilities.

When a capability is limited to specific resources, requests for other resources of that type fail with `403`, and list operations return only the resources the key can see.

> [!WARNING]
>
> A key with `API_KEY:CREATE` can create new keys with any role, including **Company admin**. Give that permission only to keys you'd trust with full access.

## Authentication errors

| Status | Message | Cause | Fix |
| - | - | - | - |
| `401` | `Unauthorized` | The header is missing, or the key is mistyped, disabled, expired or deleted, or it's an old token past its rotation period | Check the `Authorization: Bearer` header and the key's status under **Tools** > **API keys** |
| `403` | `This API key is missing the APP:UPDATE permission. Grant it to the key or use a key that has it.` | The key lacks the permission named in the message. When the key has the permission for other resources only, the message reads `permission for this resource`. | [Update the key's permissions](https://docs.sevalla.com/developer-tools/api-keys#update-an-api-key), or use another key |
| `403` | `The service is suspended.` | The company, or the application or database the request acts on, is suspended | Activate the application or database, or [reactivate the company](https://docs.sevalla.com/billing/failed-payments#reactivate-a-suspended-company) |
| `403` | `Your company is being migrated to new infrastructure. Changes are disabled until the migration finishes.` | The company is being migrated. Reads (`GET`) still work. | Retry the change after the migration |
| `403` | `Your company is under maintenance. Changes are temporarily disabled.` | The company is under maintenance. Reads (`GET`) still work. | Retry the change after the maintenance |
| `400` | `An API key cannot modify itself` | A key tried to update, rotate, disable or delete itself | Use another key, or the dashboard |

A request that doesn't match the operation's schema, such as an ID that isn't a UUID, returns `400` before the key is checked. See [Errors](https://api-docs.sevalla.com/v3/errors.md) for every status code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.