Skip to main content

Authentication

Every integration authenticates with a personal access token sent in the Authorization header, using the Bearer scheme:

Authorization: Bearer bt_pat_<token-id>_<secret>

That is the whole mechanism for the REST API. (The one exception is the MCP endpoint, which also accepts an OAuth access token issued to a connected AI assistant; OAuth tokens issued to connectors are refused everywhere else. The first-party mobile apps use a Kratos session token, not an OAuth token, and any other bearer is refused with 401.) There is no custom header, no request signing, no API key query parameter, and no separate client secret.

curl https://api.budgetthing.com/api/v1/workspaces \
-H "Authorization: Bearer bt_pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty_Xr8mQ2vP0kNd7Zt5Ls3Wc9Yb1Hg4Jf6Am0Rn2Ue8Qiw"

The token value is matched by its bt_pat_ prefix. A bearer credential that does not start with bt_pat_ is not treated as a personal access token, and the request continues as if no token had been sent.

What the API checks​

A token is accepted only when all of the following hold:

  • the value parses as a well-formed token (see Personal Access Tokens);
  • the secret matches the stored hash;
  • the token has not been revoked;
  • the token has no expiry, or its expiry is still in the future;
  • the user who owns it still exists.

Every one of those failures produces the same opaque 401. The API never tells you which check failed, so an expired token, a revoked token and a mistyped token are indistinguishable from the outside.

{
"status": 401,
"code": "unauthenticated",
"detail": "authentication required"
}

The response carries Content-Type: application/problem+json. It is deliberately shorter than the full problem body described in Errors, because it is written before any operation is matched.

A token whose owner has deleted their Budget Thing account also gets 401: accepting the deletion request removes every token the account owns (see Personal Access Tokens). A request from that account that still authenticates while the deletion is in progress, such as one made with a browser session, answers 403 with the code ACCOUNT_DELETION_PENDING instead. This response uses the full problem body described in Errors.

Once a token is accepted, the request is authorized twice more: first against the token's scopes, then against everything that applies to the owning user anyway — their role, their workspace membership, and the resource itself. A scope can only narrow what the owner can already do; it never widens it.

Treat tokens like passwords

A token is a bearer credential. Anyone who has the string can act as you, within its scopes, until it expires or you revoke it. Send it only over HTTPS, keep it out of source control, URLs, logs and screenshots, and pass it through an environment variable rather than typing it into a shell command.

Other authentication schemes​

The API also accepts a browser session, which is what the Budget Thing web application itself uses. The session is validated against Ory Kratos, and is presented either as the ory_kratos_session cookie or as an X-Session-Token header. That path is for first-party clients; you cannot mint a session for an integration, and it is not a documented way to call the API.

A browser session is accepted only if it has completed two-factor authentication when the user has a second factor turned on. A session signed in with a passkey counts as two-factor; a password-only session of a user with an authenticator app, recovery codes or a security key is refused with 403 SECOND_FACTOR_REQUIRED (see Errors). The same refusal applies to the OAuth login step for AI assistant connectors. Routes that don't need a signed-in user, such as shared documents, keep working for that session. If the second-factor status can't be checked because the identity service is down, the request fails with 503 SECOND_FACTOR_CHECK_UNAVAILABLE and the session is not accepted.

The distinction matters in one place. Managing tokens is deliberately restricted to a browser session: a request authenticated with a personal access token cannot list, create, read or revoke tokens, and cannot read the scope catalog. Those calls answer 403 with the short body that the token check writes:

{
"status": 403,
"code": "PERSONAL_ACCESS_TOKEN_SCOPE_DENIED",
"detail": "personal access token is not permitted to perform this operation"
}

A token therefore cannot mint another token, extend its own life, or widen its own permissions.

Native apps​

The first-party mobile apps don't open a browser to sign in. They use Ory Kratos's native (API) self-service flows against the same Kratos host as the web app (/self-service/login/api, /self-service/registration/api and so on, instead of the /browser variants), which return a session token. The app keeps the token in secure storage and sends it on every API call:

GET /api/v1/me HTTP/1.1
X-Session-Token: <session token>

There is no cookie, Origin header or CSRF token to send; state-changing requests work with the header alone.

  • Same semantics as a browser session. The API validates the token with Kratos on every request and resolves the same user, workspace roles and step-up rules as for the cookie. A user with a second factor turned on is refused with 403 SECOND_FACTOR_REQUIRED until the app has completed the second step of the Kratos flow; if the second-factor status can't be checked the answer is 503 SECOND_FACTOR_CHECK_UNAVAILABLE. A revoked, expired or unknown token is treated as no credentials (401 on routes that need a user).
  • Revocation is Kratos's. Signing out, a password change, an account recovery and POST /v1/me/sign-out-everywhere revoke Kratos sessions, so the token stops working on the next request. There is no separate token type to revoke.
  • Token and cookie together. If a request carries both, both go to Kratos, which reads the session token first. A valid token wins over a forged or garbage cookie, and an invalid token is not rescued by a valid cookie. Apps should send only the header.
  • Bearer tokens are not accepted here. Authorization: Bearer accepts only personal access tokens on the REST API (and OAuth tokens on the MCP endpoint). Any other bearer value answers 401, even if the request also carries a valid session. The earlier OAuth sign-in client for the mobile apps was never enabled on the hosted service and has been removed.

Integrations should keep using personal access tokens; the session token is a first-party credential and its flows aren't a supported way to call the API.

Sign-in rate limits​

The Kratos host that web and native clients sign in against limits submissions per client IP address. It applies to the browser flows (/self-service/<flow>/browser) and the native flows (/self-service/<flow>/api) alike, because both submit with POST /self-service/<flow>?flow=<id>:

SubmissionsLimit per IP address
login, registration, settings10 a minute, with a burst of 10 more
recovery, verification (these send and check emailed codes)5 a minute, with a burst of 5 more

Over the limit the response is 429 with Retry-After: 60 and a body shaped like a Kratos error: {"error": {"code": 429, "status": "Too Many Requests", "message": "..."}}. Wait, then submit again; the flow is still valid unless it expired. Creating a flow (GET), /sessions/whoami, logout and CORS preflights are not limited, so the check the API makes on every request is never throttled. Clients behind one shared address (an office or mobile carrier network) share one limit. This is separate from the API rate limits on api.<domain>.

MCP-only tokens​

A personal access token created with mcpOnly: true is accepted only on the MCP endpoint. Any other route answers 403 PERSONAL_ACCESS_TOKEN_MCP_ONLY. See Personal Access Tokens.

Unauthenticated requests​

A request with no credentials at all is not rejected by the authentication layer; it simply continues without a user. Operations that require a user then answer 401. Five operations are intentionally public and need no authentication:

OperationOperation ID
List account typeslist-account-types
List currencieslist-currencies
Read the plan catalogget-plans
Read an account deletion receiptget-account-deletion-receipt
Read a calendar feed (GET /v1/calendar-feeds/{token}); the secret in the URL is the credentialget-calendar-feed

Plans the catalog marks with comingSoon: true cannot be purchased yet.

Call these without an Authorization header, or with a personal access token. A token needs no scope for them, and a workspace-restricted token can call them too. They never read the token's identity. All but the calendar feed return the same reference data to every caller; the feed returns what its secret link allows, whoever asks. Every other operation still requires the scopes described in Scopes.

Cross-origin requests​

When CORS is enabled for an origin, the API allows the Content-Type, Authorization, X-Session-Token, X-Request-Id, Idempotency-Key, X-CSRF-Token and X-Account-Deletion-Receipt request headers, and the methods GET, POST, PUT, PATCH, DELETE and OPTIONS.

Do not put a token in a browser

Allowing Authorization across origins does not make it safe to ship a personal access token to a browser. A token has no origin restriction and no short lifetime; anything that can read it can use it from anywhere.