AI agent keys
An AI agent key is the agent’s own identity. Work done with a person’s API key (gtk_) is recorded under that person’s name; work done with an agent key (gtag_) is recorded under the agent’s name, and the issue screen marks it with a ✦ AI badge.
There are two ways to hand work to an agent.
From an AI tool (no server) — see “Connect to an AI tool” below
- Connect an AI tool such as Claude Code, Codex or Cursor with the agent key.
- Assign the issue to that agent and tell the AI tool to “work on my assigned issues”.
- The AI tool reads its assigned issues, changes their status and posts the result as a comment.
From a program you built (webhook)
- When an issue is assigned to an AI agent, GoalTrack sends
work_item.assignedto the agent’s webhook URL (Verifying webhooks). - The agent uses its key to read the issue and its comments, and to look up the team’s statuses.
- When it starts working it changes the status (
POST …/status) and posts the result as a comment (POST …/comments).
Either way, people see what the agent did in the activity and comments on the same issue screen, and the person who assigned the issue to the agent gets a notification.
Getting a key
Section titled “Getting a key”- Workspace owners and admins add agents and create their keys in Settings › Workspace › AI agents. The full key (starting with
gtag_) is shown once at creation and GoalTrack keeps only a hash, so put it in your secret store right away. GoalTrack does not run the agent itself. The AI tool connected with the key, or a program you built, does the work. - Agent keys do not expire. If a key leaks, click Regenerate key or Revoke on the same screen.
Connect to an AI tool
Section titled “Connect to an AI tool”Connect Claude Code, Codex or Cursor with an agent key and that agent works on its assigned issues — no program to write, no server to run. Each workspace has one address, separate from the person connection (/w/<slug>/mcp):
https://goaltrack.work/w/<slug>/mcp/agentKeep the key in the environment variable GOALTRACK_AGENT_KEY; the config file only names the variable, so committing it never commits the key. Settings › AI agents shows this config with your workspace address filled in when you create a key.
Create an .envrc file in the folder where you run the AI tool and add the line below. Typing the key directly into your shell leaves it in your shell history.
export GOALTRACK_AGENT_KEY=gtag_…With direnv, the folder picks it up automatically after direnv allow. Without direnv, run source .envrc in the same shell before you start the AI tool. Add .envrc to .gitignore so it never reaches the repository, and in CI use the CI’s secret variables instead.
If the tool shows “failed to connect”, check first whether this variable is empty. In Claude Code, claude mcp list names any variable that is empty.
Claude Code — .mcp.json
{ "mcpServers": { "goaltrack-<slug>-agent": { "type": "http", "url": "https://goaltrack.work/w/<slug>/mcp/agent", "headers": { "Authorization": "Bearer ${GOALTRACK_AGENT_KEY}" } } }}Codex — config.toml
[mcp_servers.goaltrack-<slug>-agent]url = "https://goaltrack.work/w/<slug>/mcp/agent"bearer_token_env_var = "GOALTRACK_AGENT_KEY"Cursor — .cursor/mcp.json
{ "mcpServers": { "goaltrack-<slug>-agent": { "url": "https://goaltrack.work/w/<slug>/mcp/agent", "headers": { "Authorization": "Bearer ${env:GOALTRACK_AGENT_KEY}" } } }}This connection works as the agent. Do not add it to the same AI tool session as your own GoalTrack connection — keep it in a project folder or CI job used only by this agent. In a shared session, instructions written in an issue body could run through your own connection and be recorded under your name.
If your own GoalTrack connection is added for all projects (Codex user config · Cursor global ~/.cursor/mcp.json), it loads in every folder, so a separate folder is not enough — run this agent from a separate CODEX_HOME, another machine, or CI.
Seven tools: find assigned issues (list_work_items with assignee_id), read an issue (get_work_item), read comments (list_comments), list target states (list_workflow_states), goal context of an assigned issue (get_work_item_context), change status of an assigned issue (update_status), comment on an assigned issue (create_comment). There are no tools to create or edit issues or change assignees. Reading issues and comments also works on issues not assigned to the agent (non-draft issues in this workspace — read below). Changing status, writing comments and goal context work only on assigned issues.
Comments and status changes the agent makes notify the person who assigned the issue to it.
After you revoke or regenerate the key, the AI tool shows “failed to connect” — the connection never turns into a person’s connection. Turning off Allow developer tool connections blocks this address but not REST with the same key; if a key leaks, regenerate or revoke it.
Calling the API
Section titled “Calling the API”curl "https://goaltrack.work/api/v1/work_items/$ISSUE_ID" \ -H "Authorization: Bearer $GOALTRACK_AGENT_KEY"curl -X POST "https://goaltrack.work/api/v1/work_items/$ISSUE_ID/status" \ -H "Authorization: Bearer $GOALTRACK_AGENT_KEY" \ -H "Content-Type: application/json" \ -d '{ "status_id": "<target status id>", "expected_version": 3 }'- The key is bound to the agent’s workspace. If you send an
x-workspace-slugheader it must match that workspace; otherwise you get403 WORKSPACE_MISMATCH. - When changing the status, send the
versionof the issue you last read asexpected_version. If someone changed it first you get409 VERSION_CONFLICTtogether with the latest issue — decide again and send the newversion. - Pick the target status with
GET /api/v1/workflow_states?available_for_team=<team_id>(team_idis on the issue and in the assignment webhook). - To reply to a comment, include
reply_to_idin the body.
Requests open to agent keys
Section titled “Requests open to agent keys”Only the requests below accept an agent key. Calling any other request with an agent key returns 401 UNAUTHORIZED (including requests open to personal API keys).
| Request | Scope | Per-minute limit |
|---|---|---|
GET /api/v1/work_items |
read |
120 |
GET /api/v1/work_items/:id |
read |
120 |
GET /api/v1/work_items/by-short/:shortId |
read |
120 |
GET /api/v1/work_items/:id/comments |
read |
120 |
GET /api/v1/workflow_states |
read |
120 |
GET /api/v1/work_items/:id/context |
assigned_read |
120 |
POST /api/v1/work_items/:id/status |
assigned_write |
120 |
POST /api/v1/work_items/:id/comments |
assigned_write |
120 |
read— reads issues, comments, and statuses in the agent’s workspace. Other people’s draft issues are not visible (404).assigned_write— writes only to issues assigned to the agent. Once the assignee changes to someone else, writes to that issue immediately return403 AGENT_NOT_ASSIGNED; reads keep working.
Rejections
Section titled “Rejections”Checks run in the order below. If an earlier check rejects the request, later ones are not evaluated.
| Situation | Response |
|---|---|
| Wrong key, or the old key after a rotation | 401 UNAUTHORIZED |
| Revoked key | 401 AGENT_KEY_REVOKED |
| The agent is not a member of the workspace | 403 FORBIDDEN |
| The agent account is suspended | 403 ACCOUNT_SUSPENDED |
x-workspace-slug differs from the agent’s workspace |
403 WORKSPACE_MISMATCH |
| The workspace is suspended | 403 WORKSPACE_SUSPENDED_FULL or 403 WORKSPACE_SUSPENDED_READ_ONLY (a read-only suspension blocks writes only) |
| A write while the agent has the viewer role | 403 WRITER_ROLE_REQUIRED |
| The issue to write to does not exist, is in another workspace, or is someone else’s draft | 404 NOT_FOUND |
| The issue to write to is not assigned to the agent | 403 AGENT_NOT_ASSIGNED |
All codes and what to do about them are listed in Error codes.
Revocation and rotation
Section titled “Revocation and rotation”- Revocation: once an admin revokes the agent, the next request gets
401 AGENT_KEY_REVOKED. - Rotation: when an admin creates a new key with Regenerate key, the new key is shown once and requests with the old key get
401 UNAUTHORIZEDfrom that moment. There is no grace period where both keys work, so switch to the new key right away. - Requests already in progress run to completion. Invalidation applies from the next request.
Rate limits
Section titled “Rate limits”- Limits count all requests from one agent together — any mix of the requests in the table adds up to 120 per minute, reset every minute. Exceed one and you get
429with aRetry-Afterheader (seconds). Wait that long, then send again. - There are other caps against abuse as well (for example, repeatedly sending an invalid key). Whichever limit you hit, on
429wait forRetry-Afterand then retry.