Skip to content
Source
Sign inSign up

Make an access token

Work with agents

Make an access token

A script, a CI job or a tool needs a token, but a token with all of your access is a big risk if it leaks. Give the token only the repositories and the actions that it needs, and an end time.

4 min read

1. Open the tokens page

Click your avatar, then Tokens under Agents and access. The page is also at Settings, Tokens.

2. Name the token and pick its access

  1. Type a Token name for the place where the token lives, for example ci or laptop.
  2. Pick the Access:
AccessWhat the token can do
ReadRead code, issues, pull requests, check runs and assets.
WritePush, open and merge pull requests, run jobs, and all that Read does.
Full accessAll that you can do, on every repository.
The New token form: the token name, the Read, Write and Full access choices, the repositories, and the end time of 30 days

3. Add the repositories

Under Repositories, type each repository as owner/name, or search by name. The token works on these repositories only. It does not work on other repositories, public ones included.

Full access has no list of repositories.

Note

A token on a monorepo also works on its members. A member that is added later is in, and a member that is removed drops out at the next request.

4. Pick the end time

Pick the End time: from 1 hour to 90 days, or On a date. The default is 30 days.

  • A token with repositories lives 365 days at most.
  • No expiry is there only for Full access. Such a token can do all that you can do, with no end.

5. Create the token

  1. Click Create token.
  2. Copy the token now. The page shows it one time only.

Use the token as the password when git asks, or send it as Authorization: Bearer <token>.

Done

The token is in Your tokens, with its repositories, its access and its end time. It works on git over HTTPS, the REST API, MCP and src, on those repositories only.

Later: pick single actions

Read and Write are sets of actions. For a different set, open Advanced: pick single actions and select the actions one by one.

You want the token toSelect
Read the vaultvault:read. Read does not include it, because the vault keeps private files.
Read CI secret and variable values back (src secret get, src env pull)jobs:read and secrets:read. The token reads only the environments whose readers include you, and never production.
Set the preview value of a CI secret for one branch, and do nothing elseOnly secrets:preview. See Set preview secrets from an integration.

The Write preset does not include secrets:read, so a token made to push code or run CI never reads secret values.

Note

A token never gets repo:admin or held:review. Changes to the access of a repository, and decisions on held content, are for people in the browser only.

Later: revoke a token

Caution

You cannot undo a revoke. Everything that uses the token stops at once: git, the REST API and MCP clients.

  1. In Your tokens, click Revoke on the token.
  2. Click Revoke token.

What "Expired" means

After its end time, a token shows Expired in Your tokens, and it stops working. git, the REST API and MCP refuse it.

The REST API answers 401 with This access token has expired. Run src auth login, or make a new token at /settings/tokens. Do one of these two steps.

Seven days after the end time, the token leaves the list.

If it fails

  • If git or the REST API gives This access token is unknown or was revoked. Run src auth login, or make a new token at /settings/tokens., the token was revoked, or it is not a token of this site. Log in again, or make a new token.
  • If git refuses a push with This token does not allow contents:write, the token cannot push. Make a token with Write, or select contents:write.
  • If you get You have read access to acme/app; contents:write needs write, you cannot give a token more than your role on a repository. Remove the action, or ask an admin of the repository for a higher role.
  • If you get This token only works on acme/app and cannot do this, the token has repositories, so it cannot do account-level work. Use a Full access token for this work.

Account-level work includes new repositories, agent sessions, skills outside its repositories, and searches across repositories.

On each repository, a token never does more than you. When your role there goes down, the token loses that access too.