Start free
Docs · Authentication

Developer docs

Guide: authenticate to the Beplan API

The Beplan API takes one kind of credential, a bearer token in the Authorization header. This page covers the two kinds of token, how long they live, and how they stop.

Read as Markdown

On this page
  1. Send a bearer token
  2. Two kinds of token
  3. How long tokens live
  4. Revocation is immediate
  5. Introspection
  6. Where to keep tokens

Send a bearer token

curl "https://api.beplan.io/v1/me" -H "Authorization: Bearer beplan_pat_…"
  • Only the Authorization header. A token in the address (?access_token=…) is refused with 401 UNAUTHENTICATED, not ignored. Cookies are never read on /v1, so a signed-in browser session does nothing there.
  • Always HTTPS. Every answer carries Strict-Transport-Security.
  • A 401 carries WWW-Authenticate: Bearer error="invalid_token" when a token was sent and refused, and a bare Bearer when none was sent. A missing scope is 403 INSUFFICIENT_SCOPE with WWW-Authenticate: Bearer error="insufficient_scope", scope="…".
  • The API allows calls from any web origin (CORS *, no credentials). Don't take that as an invitation: a token in a web page's code is visible to everyone who opens it.

Two kinds of token

Personal token OAuth access token
Looks like beplan_pat_ followed by random characters A signed JWT; treat it as opaque
Made by The person, under Developers in their Beplan account Your app, through the authorization-code flow
Lifetime 30, 90 or 365 days, or no expiry (the organization may cap it) One hour, renewed with the refresh token
Scopes Any, including all What the app declared and the person kept; never all
Works on The REST API and the MCP server The resource it was issued for: the API (https://api.beplan.io) or the MCP server (https://api.beplan.io/mcp), never both
Seen Once, when it is made By your app only, never by the person

Both identify a connection, and both are checked against it on every request.

How long tokens live

Token Lifetime
Personal token What the person chose: 30, 90 or 365 days, or never. An organization can set a maximum; a longer-lived token stops working in that organization (403 INTEGRATION_BLOCKED_BY_ORGANIZATION, reason token_lifetime)
Authorization code Single use, 10 minutes
OAuth access token 1 hour
OAuth refresh token 90 days, replaced at every refresh

An expired personal token answers 401 TOKEN_EXPIRED. Make a new one: an expiry can't be extended.

Refresh tokens rotate

Each refresh returns a new refresh token; the one you sent stops working 30 seconds later. That grace period makes a retry after a network failure safe. A refresh token used again after it is a sign of theft: Beplan ends the whole connection (every access and refresh token of it), and the person has to connect your app again.

Keep one refresh in flight per connection, and store the new refresh token before you use the new access token.

Revocation is immediate

Tokens stop on the next request, with no delay and no cache:

  • The person revokes a personal token under Developers, or removes an app or assistant under Integrations, in their settings (or removes everything at once).
  • Your app revokes its refresh token at https://api.beplan.io/api/auth/oauth2/revoke (OAuth): the connection ends.
  • An admin revokes the connection for their organization, blocks your app or the person, or turns the way in off: that organization answers 403 INTEGRATION_BLOCKED_BY_ORGANIZATION; other organizations keep working.
  • Beplan suspends an app: every token of it answers 401 APP_SUSPENDED until the suspension is lifted.

A revoked token answers 401 TOKEN_REVOKED. Signing out of Beplan or changing the password does not revoke tokens: a connection lives until someone removes it.

Expired or revoked?

Answer Personal token App
TOKEN_EXPIRED Its expiry passed: make a new one The access token is more than an hour old: refresh it
TOKEN_REVOKED Revoked: make a new one if it should keep working The connection ended: the person must connect again
UNAUTHENTICATED Unknown or malformed (or deleted some time after it was revoked or expired) Malformed, or issued for the other resource: refresh once, then ask the person to connect again

Introspection

A confidential app can ask whether a token still works, with RFC 7662 introspection and its client credentials:

curl -X POST "https://api.beplan.io/api/auth/oauth2/introspect" \
  -u "CLIENT_ID:CLIENT_SECRET" \
  -d token=ACCESS_OR_REFRESH_TOKEN

The answer is { "active": false } once the token's connection was revoked, even if the token itself has not expired yet. Most apps don't need it: call the API and handle 401.

Where to keep tokens

  • On a server, in a secret store or an environment variable; never in a repository or in code sent to browsers or phones.
  • Refresh tokens and client secrets encrypted at rest.
  • Never in logs. If a token leaks, revoke it at once (security).