Skip to main content

Personal Access Tokens

A personal access token is the credential you use to call the Budget Thing API. It belongs to one user, carries a fixed set of scopes, and may optionally be pinned to a single workspace.

A token is how your application calls Budget Thing. The mirror image of it is a webhook, which is how Budget Thing calls your application — two different tools that most integrations use together, and webhook endpoints can themselves be managed with a token carrying the webhooks:read and webhooks:write scopes.

Token format​

A token looks like this:

bt_pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty_Xr8mQ2vP0kNd7Zt5Ls3Wc9Yb1Hg4Jf6Am0Rn2Ue8Qiw

It has three parts:

PartValue
Prefixbt_pat_, on every token
Token ID22 characters, the identifier of the token record
Secret43 characters, base64url, from 32 random bytes

The token ID and the secret are separated by an underscore. The token ID is the same value as the id field on the token record, minus its pat_ prefix — so the token above belongs to the record pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty. That is how the API finds the record without searching, and it is how you can match a leaked token back to the record you need to revoke.

Only a hash of the secret is stored. The full value exists exactly once, in the response to the create call.

Create a token​

Token management is interactive by design: these four operations require a signed-in browser session and reject personal access tokens, so you cannot use one token to mint another. See Authentication.

Creating a token also needs a recent sign-in: if the session last signed in more than 15 minutes ago, the request fails with 403 RECENT_AUTHENTICATION_REQUIRED (details.operation is create-personal-access-token, details.maxAgeSeconds is 900). Sign in again and retry. See Operations that need a recent sign-in.

POST /api/v1/personal-access-tokens
FieldRequiredNotes
nameyes1–100 characters, trimmed
scopesyesat least one scope string
descriptionnoup to 1000 characters
workspaceIdnorestricts the token to one workspace
expiresAtnoRFC 3339 timestamp, must be in the future
mcpOnlynotrue restricts the token to the MCP endpoint (default false). It can't be changed afterwards.
curl -X POST https://api.budgetthing.com/api/v1/personal-access-tokens \
-H "Content-Type: application/json" \
-b "ory_kratos_session=$SESSION" \
-d '{
"name": "Reporting export",
"description": "Nightly export job",
"scopes": ["transactions:read", "reports:read"],
"expiresAt": "2027-01-01T00:00:00Z"
}'

The response is 201 Created:

{
"id": "pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty",
"name": "Reporting export",
"description": "Nightly export job",
"scopes": ["reports:read", "transactions:read"],
"createdAt": "2026-08-26T11:14:03Z",
"expiresAt": "2027-01-01T00:00:00Z",
"token": "bt_pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty_Xr8mQ2vP0kNd7Zt5Ls3Wc9Yb1Hg4Jf6Am0Rn2Ue8Qiw"
}
The token is shown once

token is present only in this response. It is never returned by the list or get calls, and it cannot be recovered afterwards — the API keeps only a hash. Copy it into your secret store immediately. If you lose it, revoke the token and create a new one.

Scopes must match the catalog spelling exactly. They are not lower-cased or trimmed, so Transactions:Read or " transactions:read" is rejected with 422, the same as any other unrecognized scope string. Valid scopes are de-duplicated and stored in sorted order.

If workspaceId is set, it must be a workspace you are an active member of.

MCP-only tokens​

A token created with "mcpOnly": true works only on /api/v1/mcp. On every other route the API answers 403 with the code PERSONAL_ACCESS_TOKEN_MCP_ONLY, before the scope or workspace check runs. Through MCP the token reaches exactly the operations in the MCP tool catalog, which leaves out the outward actions (emailing or sharing a quote or invoice, deleting a payment or a transaction) that the same scopes allow over REST. Use it for anything you hand to an AI assistant: the assistant can read the token from its own configuration, so the restriction is what keeps it to the catalog. The "AI assistant" presets in the app create MCP-only tokens. A token without mcpOnly works across the whole API, exactly as before.

Store a token​

Treat the value as a password. Keep it in a secret manager or an environment variable, never in source control, a URL, a log line or a support ticket. The only thing safe to write down is the token ID, which identifies the record without granting anything.

export BUDGETTHING_TOKEN="bt_pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty_Xr8mQ2vP0kNd7Zt5Ls3Wc9Yb1Hg4Jf6Am0Rn2Ue8Qiw"

List your tokens​

GET /api/v1/personal-access-tokens
{
"personalAccessTokens": [
{
"id": "pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty",
"name": "Reporting export",
"description": "Nightly export job",
"workspaceId": "wks_3fQ0mZk8Xr2Lp9Va6Ne1Ty",
"workspaceName": "Household",
"scopes": ["reports:read", "transactions:read"],
"createdAt": "2026-08-26T11:14:03Z",
"lastUsedAt": "2026-08-26T12:02:55Z",
"expiresAt": "2027-01-01T00:00:00Z"
}
]
}

The list is ordered newest first. It includes expired tokens, but leaves out revoked tokens unless you add ?includeRevoked=true. A single token, revoked or not, is available at GET /api/v1/personal-access-tokens/{personalAccessTokenID}, with the same fields.

FieldWhen present
mcpOnlyAlways present. true when the token works only on the MCP endpoint.
workspaceIdThe token is restricted to one workspace.
workspaceNameThe token is restricted to one workspace. It holds that workspace's current name.
expiresAtThe token was created with an expiry.
lastUsedAtThe token has been used at least once.
revokedAtThe token has been revoked. Only seen with ?includeRevoked=true or on a single-token read.

lastUsedAt is a rough activity signal, not an audit log: it is written at most once an hour per token, so a token used continuously still shows a timestamp that can be up to an hour old, and lastUsedAt is absent on a token that has never been used.

Fields that are not set are omitted from the response rather than sent as null, so a token with no expiry simply has no expiresAt field.

Expiry​

expiresAt is optional. A token created without it never expires and stays valid until you revoke it. When it is set, it must be in the future at creation time, and once the moment passes the token stops authenticating — the request gets the same opaque 401 as any other rejected credential.

Expiry cannot be changed after creation. There is no update operation for a token: to rotate, create the replacement, deploy it, then revoke the old one.

Revoke a token​

DELETE /api/v1/personal-access-tokens/{personalAccessTokenID}
curl -X DELETE \
https://api.budgetthing.com/api/v1/personal-access-tokens/pat_3fQ0mZk8Xr2Lp9Va6Ne1Ty \
-b "ory_kratos_session=$SESSION"

A successful revoke returns 204 No Content with an empty body. The token stops working immediately; there is no grace period and no way to undo it. Revoking a token that is already revoked also returns 204 and leaves the original revocation time unchanged. A token ID that belongs to someone else returns 404 — you can only see and revoke your own.

The record itself is not deleted. It keeps a revocation timestamp (revokedAt), drops out of the default list, and fails authentication from that point on.

When the owner deletes their account​

Once a request to delete the Budget Thing account is accepted, every token that account owns is removed at that moment, not just revoked, so requests made with them answer 401. The tokens do not appear in any list and cannot be restored. Integrations that need to keep running should use a token that belongs to a different account.

Limits​

You may hold ten active tokens at a time. Creating an eleventh fails with 409 and the code PERSONAL_ACCESS_TOKEN_LIMIT_REACHED; revoke one first. Revoked and expired tokens do not count toward the limit.

Next​

  • Scopes — the permissions you can attach to a token.
  • Webhooks — have Budget Thing notify your application instead of polling it.
  • Errors — the failure shapes referenced above.