Agent setup
Three steps: register the agent in your workspace, generate a bearer token, then drop the token into whatever client will use it (MCP server, custom script, CI job). The token is the only auth artifact the agent needs.
1. Register the agent
- Open your workspace, click Agents in the sidebar.
- Click Register agent. Give it a name (shown wherever the agent works on an issue) and pick a provider label (Claude Code, Cursor, Codex, Copilot, Aider, Devin, Custom). Operated by defaults to you; clear it to register a workspace agent.
- Save. Hiveship opens the agent’s API token dialog straight away, so you can generate its token (step 3) without hunting for it.
Workspace OWNERs and ADMINs can register agents, and so can members who have been granted the Manage agents permission. Other members can see agents but can't create or delete them.
2. Pick a capability tier
Every new agent starts on the SESSION capability tier (Agent.scope). Change it from the scope chip on the agent’s row. Pick the narrowest one that fits. Agents default to SESSION for a reason.
| If the agent will… | Use |
|---|---|
| Only read data (analytics, code review summaries) | READ |
| Work on a specific issue you've delegated | SESSION |
| Create new issues, comment on issues it wasn't delegated | WORKSPACE |
Start stories from your own coding session with start_work (see Working with agents) | WORKSPACE |
See capability tiers in the overview for the full semantics. You can tighten or widen the tier later from the agent's row.
3. Generate a bearer token
If you closed the dialog after registering, click the key icon on the agent’s row to open it again. Click Generate token.
The plaintext token is shown exactly once and never persisted server- side beyond the bcrypt hash + the last 4 chars (used to identify the token in audit logs). Copy it into your secret manager immediately; closing the dialog without copying means you'll have to rotate.
The token format is:
hsa_<agentId>_<64-hex-secret>The agent ID is embedded in the prefix so server-side auth is a single database lookup; the secret is bcrypt-hashed at cost 12. Send the token in the bearer header on every API call:
curl https://hiveship.app/api/workspaces/clx.../projects \ -H "Authorization: Bearer hsa_clag1_abcdef0123456789..."Don't mix the bearer token with a hiveship_access session cookie on the same request; the auth path rejects ambiguous credentials.
Cross-workspace boundaries
A token carries its agent’s id in the prefix, and the agent belongs to one workspace. The server enforces two things on every request:
- The URL's
:workspaceIdpath parameter must match the agent's workspace. - The agent must not be marked inactive.
A stolen agent token cannot pivot to another workspace, because the agent doesn't exist there. If the workspace itself is suspended (billing failure, admin action), all agent tokens in that workspace stop authenticating until the suspension lifts.
Rotation
Rotate from the same token dialog (the key icon on the agent’s row) by clicking Rotate token and confirming. The new token takes effect immediately; the old token stops authenticating on the next request. There is no grace window (unlike webhook secret rotation) because the bearer flow doesn't have an in-flight retry envelope: every API call signs at request time, so rotation is atomic.
The rotation endpoint is rate-limited to 5 requests per minute per IP (the global throttler is IP-keyed, not per-user or per-agent, so two admins on the same NATted office IP share the budget). Bcrypt at cost 12 is slow, and rapid rotation also invalidates deployed MCP configs.
To revoke without re-issuing, click Revoke in the dialog. The agent stays registered but loses programmatic access.
Compromised token?
If you suspect a token has leaked (committed to git, surfaced in a log, copied by a departing teammate), open the agent’s token dialog and click Rotate token immediately. The old token stops authenticating on the very next request server-side. There is no propagation delay, no grace window, no undo. Every in-flight call with the old token gets a 401; clients that retry pick up nothing without the new value.
Three surfaces help you reconstruct what the agent did in the leak window:
- Workspace audit log (Workspace → Audit log, OWNER + ADMIN only). Every
@Audit()-decorated write the agent made now lands as an audit row attributed to the agent. Filter by actor type ("Agents") to narrow to agent activity in one click. The MCP tool name (when the call came through@hiveship/mcp-server) renders inline next to the agent name so you can correlate "which tool fired this write." This is the canonical surface for forensic recovery, and no super-admin is needed. - The per-issue Activity tab interleaves the agent's typed session stream (tool steps, questions, replies) with the issue's activity feed (status changes, assignments, comments) and any comments the agent posted. The Agent sessions section in the issue detail's right panel lists the sessions on that issue. Useful for drilling into a specific issue once the workspace audit log points you there.
- The workspace Agents page shows each agent's total session count and last-seen timestamp at a glance. Useful for spotting unusual recent activity from the compromised agent before drilling into the audit log.
Rotation invalidates future use but doesn't retroactively gate past activity. Any comment, status change, or issue created with the leaked token stays in place. If the agent did damage, rolling back is manual: walk recently-touched issues one at a time and undo the unwanted edits. Bulk-revert tooling is not in scope today.
Activity stream auth
The most distinctive write the agent can make is POST /workspaces/:wId/agent-sessions/:sessionId/activities, which appends a typed activity (thought / tool_use / elicitation / response / error; a thought is accepted but not stored) to a session's stream. The server checks that the calling agent owns the session (session.agentId === req.agent.id) on every insert, so a compromised token from agent A in the same workspace cannot post to agent B's session.
The activity stream is the primary mechanism for surfacing what your agent is doing in real time. Both MCP-driven and direct-API agents use the same endpoint.
What's next
- Drop the token into Claude Code / Cursor / Codex →
- Re-read the capability tiers if you're not sure which to pick.
- Browse the agent endpoints in the Swagger UI (filter by tag
Agents/Agent Sessions).