Create a machine token
Before you begin
- Plan
- Included in Free, Pro and Team. How plans and limits work
- Role
- Admin or higher.
A machine token belongs to the workspace rather than to a person, so a pipeline or a shared AI assistant keeps working when people leave. It has a role of its own, and can be limited to a single project. Roles, personal tokens and machine tokens explains when to choose one.
-
In the workspace switcher, which shows the workspace’s name in the page header, choose the workspace the token is for.
-
Open Settings → Tokens. Settings is in the account menu, which shows your name in the page header.
-
Under Machine tokens, select New machine token. When the workspace already has as many machine tokens as its plan allows, the button is dimmed and selecting it says “No more machine tokens” instead of opening the form; the limits page lists the Machine tokens per workspace of each plan. On a plan without machine tokens there is no button, and the page says “Machine tokens are not part of this workspace’s plan.”
-
Under What is it for?, choose:
- Sync a project from a repository, for a pipeline that pulls, compares and pushes one project’s configuration document with the MockHub CLI. The token gets Editor on that one project.
- Preview environments for pull requests, for a pipeline that creates an ephemeral environment for each pull request. The token gets Editor on every project, and may create, list and delete ephemeral environments.
- Something else, for anything else, such as a shared AI assistant.
-
Enter a Name that says what will use the token, such as
orders-api pipeline. -
For Sync a project from a repository, choose the Project. Select Also apply settings, chaos profiles and webhooks only if the pipeline changes those; the token then gets Admin on that project.
For Something else, choose a Role: Viewer, Editor or Admin. The form starts at Editor; What each role lets it do lists the difference. In Reaches, keep Any project in this workspace, or choose the one project the token may use. Leave Can create, list and delete ephemeral environments off.
-
Choose when it Expires after, from 7 days to 1 year. The form starts at 90 days and shows the date the token will stop working.
-
Select Create machine token.
-
Select Copy, and store the token in the secret store of whatever will use it. It starts with
mh_mt_and is shown only this once. For the two pipeline purposes, the dialog also shows how to install the CLI and give it the token, and for a sync token a startingmockhub.yamlfor the project. -
Select I have stored it.
The project’s Config as code page links to this form with Create a token for this project, and Settings → Environments with New CI token; each opens it with the purpose, and the project, already chosen.
What each role lets it do
Section titled “What each role lets it do”| Role | The token can |
|---|---|
| Viewer | List the projects it reaches, and read their mocks, request logs and configuration document |
| Editor | Also create, change and delete mocks; rename a project or change its description or subdomain; turn a logged request into a mock and delete request logs; apply a configuration document that leaves settings, chaos profiles and webhooks as they are |
| Admin | Also delete the projects it reaches, and apply a configuration document that changes their settings, chaos profiles or webhooks |
With Can create, list and delete ephemeral environments off, as above, a machine token cannot create projects, whatever its role. Other than through the configuration document, it cannot reach a project’s settings, scenarios, chaos profiles or webhooks, and it cannot use alert rules, insights, captures, version history or Try it. Nothing else in the workspace is open to it either: members, invitations, billing, tokens, custom domains and activity are refused. With Reaches set to one project, every other project in the workspace is invisible to it.
Through MockHub’s MCP server a machine token can use every tool its role allows except create_project; see MCP tools.
Result
Section titled “Result”The token is listed under Machine tokens with its Name; under Acts as, its role and what it reaches: Any project in this workspace, or for a token limited to one project, that project’s name; the characters it Starts with; Never used under Last used; and the date it Expires.
A pipeline sends it in the Authorization header of each request:
Authorization: Bearer mh_mt_…To revoke it, select the revoke button in its row, named Revoke followed by the token’s name, then Revoke token. Anything still using it gets 401 from its next request.
Limits
Section titled “Limits”- The role and the project in Reaches are fixed when the token is created. To change either, create another token and revoke the old one.
- A token reaches one project or all of them; it cannot be given a list of several.
- A token cannot be extended, and lives at most a year. Replace it before its date.
- An expired machine token stays in the list, and keeps counting towards the number the plan allows, until you revoke it.
- Each token can make 600 calls a minute to MockHub, counted apart from every other token. AI assistants are counted separately; see MCP tools. Further calls are answered with
429and aRetry-Afterheader giving the seconds until the minute is over. - Reaches lists the first 100 projects by name. A project further down the list cannot be chosen there.
- Only Admins can see the list. Other members see only that machine tokens may exist.
- When a workspace has more machine tokens than its plan allows, for example after a downgrade, the existing ones keep working, but no new one can be created until the workspace is below the limit.
- A machine token survives its creator leaving the workspace or deleting their account. It does not survive one case: if the creator’s MockHub address was never verified, their first sign-in with GitHub or Google for that address deletes every token they created, machine tokens included. See Manage sign-in methods and sessions.