Documentation
Developers

API authentication

Choose a credential for the Bobsled AI API, send it with a request, act as an Account member, and fix authentication errors.

This page explains how to authenticate requests to the Bobsled AI API. It's for developers who write scripts, services, and clients. To create and govern these credentials in the app, see Developer access.

Choose an authentication method

Send exactly one credential with each request. Bobsled AI rejects a request that carries more than one credential family. Each operation in the API reference lists the credentials that it accepts.

The following table compares the methods:

Method
Use it for
How you send it
Lifetime
Scopes
Personal API keyDevelopment and automation that a user ownsX-Dogsled-API-Key header7, 30, 60, or 90 days in the appapi:read, api:write
Service principalCI, backend services, and shared production automationAuthorization: Bearer header with an OAuth access token5 minutes for each access tokendogsled:api:read, dogsled:api:write
MCP OAuthAn interactive MCP client, such as a coding agentThe MCP client runs the OAuth flowUp to 30 days of refreshed accessdogsled:read, dogsled:write
Browser sessionThe Bobsled AI appSession cookie on the same originThe sign-in sessionNot applicable

Before you begin

The curl examples on this page read the following shell variables:

  • $BOBSLED_ORIGIN: your Bobsled AI URL, such as https://customer.dogsled.it.
  • $BOBSLED_PROJECT_ID: the ID of the Project that you call.
  • $BOBSLED_ACCOUNT_ID: the ID of your Account.

Each section lists the credential variables that its examples add. Store credentials in a local or hosted secret manager, never in a checked-in .env file.

Authenticate with a personal API key

A personal API key represents the user who owns it. Bobsled AI authorizes each request with the owner's current Account role, the owner's Project grants, and the Project on the request.

To create a key, in the user menu, select Personal API Keys, and then click Create API key. Choose api:read, api:write, or both, and an expiry of 7, 30, 60, or 90 days. Bobsled AI shows the key once. The /api/v1/me/personal-api-keys routes also create keys and accept an expiresInDays value from 1 to 90. For the complete steps, see Create a personal API key.

Send the key in the X-Dogsled-API-Key header. Don't also send a session cookie or a bearer token. The following command lists recent runs from one Project:

bash
curl --fail-with-body --silent --show-error \ --header "X-Dogsled-API-Key: $BOBSLED_API_KEY" \ "$BOBSLED_ORIGIN/api/v1/projects/$BOBSLED_PROJECT_ID/pipeline-runs?limit=20"

Set $BOBSLED_API_KEY to your personal API key.

To check whether an operation accepts a personal API key, and whether it needs api:read or api:write, see the API reference.

Authenticate with a service principal

A service principal represents software that the Account owns. An Account Admin creates it on the Machine credentials page. The Admin gives it selected Project grants or Whole organization access, and dogsled:api:read, dogsled:api:write, or both. For setup, see Create a service principal.

To call the API, exchange the client ID and client secret for a short-lived access token. Then send the token with each request.

Get an access token

Request a token from /api/auth/oauth2/token with the OAuth 2.0 client credentials flow. Send your Bobsled AI API resource, $BOBSLED_ORIGIN/api/v1, as the resource value. The following command requests a read-only token:

bash
curl --fail-with-body --silent --show-error \ --user "$BOBSLED_CLIENT_ID:$BOBSLED_CLIENT_SECRET" \ --header "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "grant_type=client_credentials" \ --data-urlencode "resource=$BOBSLED_ORIGIN/api/v1" \ --data-urlencode "scope=dogsled:api:read" \ "$BOBSLED_ORIGIN/api/auth/oauth2/token"

Set the following variables:

  • $BOBSLED_CLIENT_ID: the service principal's client ID.
  • $BOBSLED_CLIENT_SECRET: the service principal's client secret.

The output is similar to the following:

json
{ "access_token": "ACCESS_TOKEN", "token_type": "Bearer", "expires_in": 300, "expires_at": 1796083500, "scope": "dogsled:api:read" }

The scope parameter works as follows:

  • Request only the scopes that the integration needs. For both, send the space-delimited value dogsled:api:read dogsled:api:write.
  • If you omit scope, the token receives every scope that the service principal holds.
  • A scope that the service principal doesn't hold fails with invalid_scope.

Each token lasts 5 minutes, and the response has no refresh token. Cache a token only for its lifetime, and request a new one before it expires. Never store a token as though it were the long-lived client secret. Requests from a disabled or revoked service principal fail closed.

Send the access token

Copy access_token into a secret variable, and send it in the Authorization header. The following command lists recent Project runs:

bash
curl --fail-with-body --silent --show-error \ --header "Authorization: Bearer $BOBSLED_ACCESS_TOKEN" \ "$BOBSLED_ORIGIN/api/v1/projects/$BOBSLED_PROJECT_ID/pipeline-runs?limit=20"

Set $BOBSLED_ACCESS_TOKEN to the access_token value from the token response.

Act as an Account member

A service principal with User impersonation turned on can send a request as one member of its own Account. Send the member's user ID in the x-dogsled-impersonate-user-id header with the bearer token. Get the user ID from the Account members list.

The following command lists chats as the selected member:

bash
curl --fail-with-body --silent --show-error \ --header "Authorization: Bearer $BOBSLED_ACCESS_TOKEN" \ --header "x-dogsled-impersonate-user-id: $BOBSLED_USER_ID" \ "$BOBSLED_ORIGIN/api/v1/accounts/$BOBSLED_ACCOUNT_ID/chats"

Set $BOBSLED_USER_ID to the user ID of the Account member.

Bobsled AI authorizes the request with that member's current Account role and Project grants. Chats and other user-owned records belong to that member. Logs record both the member and the service principal.

The header works only on /api/v1 routes. Bobsled AI rejects the request with 403 forbidden, and doesn't fall back to the service principal, in the following cases:

  • The credential isn't a service-principal bearer token.
  • The service principal has User impersonation turned off.
  • The user isn't a current member of the service principal's Account.
  • The route manages service principals or requires Whole organization access.
  • The header value isn't a valid user ID.

A disabled service principal fails authentication with 401, with or without the header.

Authenticate an MCP client

An MCP client uses the OAuth flow that the Bobsled AI MCP server advertises. The consent page names the client and the requested access. The resulting MCP session is the only source of the actor for delegated tool calls, and tool arguments can't replace that verified identity. To connect a client, see MCP server.

Use a browser session

The Bobsled AI app uses a session cookie and sends it to the same origin. A session-authenticated mutation enforces the same-origin policy that its route declares. Don't copy session cookies into scripts or external services.

How Bobsled AI authorizes a request

Authentication proves the principal. Authorization then evaluates the Account, the Project, the credential's permission, the route policy, and the resource. Each principal gets Project access as follows:

  • A service principal with selected Project grants needs the exact Project grant.
  • A service principal with Whole organization access can reach every live Project in its organization.
  • A personal API key inherits the user's current access.

Each request carries one credential. Bobsled AI authenticates the principal, then authorizes the Account, Project, permission, route policy, and resource before the operation runs.

After Bobsled AI authorizes a request, a provider operation can still fail at the external system. For the permissions that each role holds, see Permissions.

Rotate and revoke credentials

To rotate a personal API key, do the following:

  1. Create a replacement key.
  2. Update the consumer to use the replacement.
  3. Confirm that the consumer works with the replacement.
  4. Revoke the old key.

To rotate a service-principal credential, do the following:

  1. On the Machine credentials page, create or rotate the credential.
  2. Update the consumers.
  3. Request a token, and send an authorized request with it.
  4. Revoke the old secret.

Revoke a credential immediately after a suspected exposure. Keep a named owner and an expiration or review date for every credential.

Troubleshoot authentication

The following table lists common authentication errors:

Symptom
Cause
Fix
401 with missing_credentials or invalid_credentialsThe request has no credential, or the key or token is expired, revoked, or disabled.Send a valid key, or request a new access token.
400 with ambiguous_credentialsThe request carries more than one credential, such as a cookie and an API key.Send exactly one credential.
403 with insufficient_scopeThe key or token lacks the read or write scope that the operation needs.Create a key or request a token with the required scope.
403 with forbidden_originA session-authenticated mutation has no matching Origin header.Call the route from your Bobsled AI URL, or use an API credential.
403 with forbiddenThe principal lacks access to the Account or Project, or impersonation isn't allowed.Check the role, the Project grant, or the impersonation conditions.
invalid_scope from the token endpointThe token request names a scope that the service principal doesn't hold.Request only the scopes that the service principal holds, or omit scope.

When you diagnose a request, record the credential type, safe principal ID, scope, Project ID, route, status, timestamp, and correlation ID. Never record full key material, client secrets, bearer tokens, cookies, authorization headers, or secret-backed provider configuration.

What's next

On this page