Skip to content

Biocompile API authentication: tokens and service accounts

Last updated

On this page

Every call to the Biocompile API carries an access token that lasts 10 minutes. You get it by exchanging a long-lived credential at the token endpoint, and the credential decides who the call acts as: you, a service account of your organization, or an app you approved.

Credentials go only to the token endpoint, never to the rest of the API.

Credentials at a glance

Biocompile has three kinds of long-lived credential:

CredentialActs asStarts withCreated inLifetime
Personal access tokenYoubcp_Settings → API tokensUp to 365 days
Service account keyA service account of your organizationbcs_Organization → Service accountsUp to 365 days
OAuth connectionYou, through an app you approvedThe app’s consent screenUntil you disconnect it

The prefixes let secret scanners recognize a leaked credential. Each credential is shown once, when it is created. Biocompile stores only a fingerprint, so it cannot show the credential again.

Create a personal access token

A personal access token acts as you, for your own scripts and notebooks. Any member can create one:

  1. Open Settings → API tokens and choose Create token.
  2. Enter a Name that says where the token is used, such as “Analysis notebook”.
  3. Under Organization, choose the one organization the token may act in. Any of my organizations leaves it unpinned.
  4. Tick the Scopes the script needs and choose a lifetime under Expires after.
  5. Create the token. Result: the token is shown once, with Copy beside it.
  6. Copy the token into your secret manager, then choose Done.

You can hold at most 50 active personal access tokens. The list shows each token’s organization, scopes, expiry and when it was last used.

Pin a token to one organization whenever you can. A pinned token can never act in another organization you belong to.

Create a service account

A service account is an identity that belongs to the organization, not to a person. Use it for pipelines and integrations that must keep working when people change roles or leave. Only organization owners and admins manage service accounts:

  1. Open Organization → Service accounts and choose Create service account.
  2. Enter a Name and a Description, such as “Nightly LIMS sync”.
  3. Under Project access, select the projects the account may see.
  4. Tick the Scopes the account may use, then save. Result: Biocompile shows “Service account created”.
  5. Choose New key, enter a Key name and choose Create key. Result: the Client ID and Client secret are shown once.

A service account sees only the projects granted to it, and never a project restricted to teams. It is always an ordinary member, never an admin. When you change its scopes or projects, the next access token it gets reflects the change. A service account cannot be given agent:converse, contributions:write or webhooks:manage: conversations and contributing act as a person, and webhooks need an admin. With projects:write, an account renames and archives its granted projects but cannot create one.

Note: Project grants do not limit files. With files:read, a service account reads the files your organization makes visible to its members.

An account holds up to 10 active keys. To rotate without downtime, create a new key, deploy it, then revoke the old one. Disable revokes every key of the account at once.

Exchange a credential for an access token

The token endpoint is POST https://app.biocompile.com/api/v1/oauth/token, with a form-encoded body. A personal access token uses the token exchange grant:

curl -s https://app.biocompile.com/api/v1/oauth/token \
  -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
  -d subject_token_type=urn:biocompile:params:oauth:token-type:pat \
  --data-urlencode "subject_token=$BIOCOMPILE_PAT" \
  --data-urlencode "scope=projects:read files:read" \
  -d organization_id="$ORG_ID"

A service account uses the client credentials grant, with its client ID and secret in an HTTP Basic header:

curl -s https://app.biocompile.com/api/v1/oauth/token \
  -u "$BIOCOMPILE_CLIENT_ID:$BIOCOMPILE_CLIENT_SECRET" \
  -d grant_type=client_credentials

Both answer with the access token, its lifetime in seconds and the scopes it carries:

{
  "access_token": "<access token>",
  "token_type": "Bearer",
  "expires_in": 600,
  "scope": "files:read projects:read"
}

Two optional fields narrow the access token further:

  • scope asks for fewer scopes than the credential has. Scopes the credential lacks are left out, and the exchange fails with invalid_scope when none is left.
  • organization_id narrows an unpinned personal access token to one organization you belong to. A service account token is always pinned to its organization.

Some apps act for a person once the person approves them, such as partner apps and AI assistants connected over MCP. They use two more grants at the same endpoint: authorization_code to exchange the code from the approval page (with PKCE), and refresh_token to get a new access token later. Refresh tokens change on every use. The discovery document at /.well-known/openid-configuration lists all four grants.

Use the access token

Send the access token in the Authorization header of every call, as Authorization: Bearer <access token>. After 10 minutes the API answers 401, and you exchange the credential again. The API allows up to 30 seconds of clock difference, so a token can still work for a few seconds after it expires. Do not rely on that: exchange a minute before expires_in runs out.

Treat the access token as opaque. It is a signed token, but its contents are not part of the API and may change. A token pinned to one organization answers 403 with the code organization_mismatch for any other organization.

Revoke a credential

Revoke a personal access token in Settings → API tokens with Revoke. Owners and admins revoke a service account key, or disable the whole account, in Organization → Service accounts.

Revocation is immediate. Access tokens already issued from the credential stop working on their next call with 401 and the code credential_revoked. Leaving an organization ends a token’s access to it at once. A password reset, or signing out of all your sessions, also ends the access tokens issued from your personal access tokens.

Keep credentials safe

A few habits keep a leaked credential from doing harm:

  • Give each credential only the scopes it needs, and narrow further at exchange time.
  • Choose the shortest lifetime that works, and rotate before it ends.
  • Pin each personal access token to one organization.
  • Use a service account for shared automation, with only the projects it needs.
  • Keep credentials in a secret manager or your CI system’s protected variables.
  • Never put a credential or an access token in a URL, where logs and browser history keep it.
  • Revoke a leaked credential at once and create a new one.

Token endpoint errors

The token endpoint answers errors in the OAuth format, {"error": ..., "error_description": ...}:

errorStatusMeaning
invalid_request400A required field, such as grant_type, is missing or wrong.
invalid_grant400The personal access token is unknown, expired or revoked, or its owner is no longer active.
invalid_client401The service account ID or key is wrong, expired or revoked, or the account is disabled.
invalid_scope400A requested scope is unknown, or the credential has none of them.
invalid_target400organization_id is not the token’s pinned organization, or you are not a member.
unauthorized_client400The app is not registered for this grant type.
unsupported_grant_type400The grant type is not one of the four Biocompile supports.
slow_down429Too many failed exchanges from your address (50 in 15 minutes). Wait for Retry-After seconds.

Do not retry invalid_grant or invalid_client. Replace or fix the credential instead.

Common questions

How long does a Biocompile personal access token last?

Up to 365 days, chosen under Expires after when you create it. The access tokens exchanged from it last 10 minutes each.

Can I see a personal access token again after creating it?

No. Biocompile shows the token once and stores only a fingerprint. If you lose it, revoke it and create a new one.

What happens to my tokens when I leave an organization?

They lose access to that organization at once. Tokens pinned to another organization, or unpinned tokens used in another organization, keep working there.

Controller: Biocompile, Inc.

Your first project starts here.

Free to start, with credits included.

We use this address to prefill your signup. A founder may email you once to help you get started. No newsletter. Privacy Policy

Already have an account? Sign in