Use an access token in a script or pipeline

Make a token for one workspace and the modules a script needs, give your organization's pipeline an identity of its own, and revoke either the moment you no longer trust it.

In short

An access token is a long secret a script or pipeline sends instead of signing in. You make one for one workspace and only the modules it needs, and revoke it the moment you no longer trust it. An organization can give its pipelines a service account that does not depend on any person.

Before you start

Make your own token

  1. Open Settings › "Sign-in & security" and find "Access tokens". Press "New token".
  2. Type a name and choose the one workspace it works in: your personal workspace or an organization you belong to.
  3. Under "What it may reach", choose "Read everything", "Read and write everything" or "Pick products", and set each product to "Read" or "Read and write". Choose only what the script needs.
  4. Choose "Stops working after" - 90 days unless you choose otherwise, a year at most - type your password and press "Make token".
  5. Copy the token now into your pipeline's secret store. It is shown once.

Use a token

  1. Send it with every request as the header Authorization: Bearer followed by the token.
  2. To check it before a pipeline starts, call the address ending in /api/v1/access/tokens/current. It answers the token's workspace, scopes and expiry.
  3. To stop it, press "Revoke" beside it. It stops from its next request on.

Service accounts for an organization

A service account is a machine identity that belongs to the organization: no sign-in, inbox or seat, not a member, and it keeps working when whoever set it up leaves. The organization's Access › Tokens lists them for people who may manage access tokens - organization admins by default.

See what a token did

  1. Find the token in your list, or in the organization's Access tokens if you manage them.
  2. Press "Calls". Each request the token made shows newest first: the route it reached, the answer, how long it took and when.
  3. Pick "Refused" or "Failed" to see only problems, or search for a route or a tool.
  4. Press "Download" for a CSV of what you see. An organization's download is part of plans with the audit export.

Only the route, the record it named, the answer and the time are kept, for a year. Nothing that was sent or answered is kept, and neither is the address. An agent using the {{brand}} CLI shows the tool it used.

Limit an organization's tokens

  1. Open the organization's Access tokens and go to "Token limits".
  2. Choose "Longest a token may live". Tokens that would live longer end that many days from now when you save.
  3. Under "Networks tokens work from", write one network per line, such as 203.0.113.0/24. Leave it empty to allow any address.
  4. Press "Save limits".

The limits apply to every token of the organization: members' tokens, service accounts' tokens and coding agents. A token used from another network is refused, on top of the organization's own network rules.

Good to know

If something goes wrong

Related