Skip to main content
Paused — work in progress. Lifecycle hooks are switched off: hooks do not fire, every /api/v1/hooks endpoint answers 503 with the reason, crewship hooks is hidden, and Settings no longer links to the page. Hooks registered earlier are kept in hooks_config and do not run. The feature returns once hooks can reach tools like Slack or Teams directly. For development, CREWSHIP_HOOKS_ENABLED=1 on the server process turns them back on. The rest of this page describes the feature as built.
The lifecycle hook registry. Hooks fire shell commands, HTTP webhooks, or subagents on lifecycle events; this API registers them, edits them, removes them, and toggles them on or off. See the Hooks guide.
All endpoints require authentication and are workspace-scoped. Non-host writes and hook deletion require workspace OWNER or ADMIN. Creating, editing or enabling a host shell handler requires an instance administrator with instance:admin token scope — see the shell gate.

Endpoints


Reading hooks

List the registered hooks for a workspace, optionally narrowed to one crew.

List hooks

Query parameters: Response: 200 OK
Errors:

Writing hooks

Create a hook

Auth: Non-host hooks require workspace OWNER or ADMIN. Host shell hooks require an instance administrator, including when that administrator is a workspace MEMBER. Scoped tokens also need the route’s workspace:admin scope and, for host operations, instance:admin. Body:
Response: 201 Created, body is the created hook in the same shape list returns per row. Errors: Writes an audit_logs row with action hook.create.
A hook whose event is misspelled would insert cleanly (the hooks_config schema constrains handler_kind, not event), never match the dispatcher’s query, and silently never fire — while still listing and toggling like a healthy hook. That is why an unknown event is a hard 400 rather than a warning.

Update a hook

Auth: OWNER or ADMIN. An instance administrator is required to set handler_kind: "shell", edit an existing host hook, or enable it. Semantics are patch, not put: only the fields present in the body change. An omitted field keeps its current value, so {"event": "pre_agent_start"} does not clear the matcher, the blocking flag, or the enabled flag. In particular, a body that never mentions event at all leaves it untouched — including on a legacy row whose event is pre_tool_call, which stays editable for every other field. Consequently, changing a blocking pre_* hook to a post_* or on_* event must also send "blocking": false; otherwise the merged observation hook is rejected with 400. Accepts the same fields as create, all optional. Response: 200 OK with the updated hook. Errors: as create, plus 404 when the hook is outside your workspace (cross-tenant IDs are indistinguishable from missing ones). Writes an audit_logs row with action hook.update.

Delete a hook

Auth: OWNER or ADMIN. The request has no body. Response: 200 OK
Errors: 401 unauthenticated, 403 for a non-OWNER/ADMIN, 404 when the hook is not in your workspace. Deletion is permanent. To stop a hook firing while keeping its definition, use disable instead. Writes an audit_logs row with action hook.delete carrying the deleted hook’s event, handler kind, and crew scope — after the delete there is nothing left to reconstruct it from.

The shell gate

handler_kind: "shell" runs a command on the crewshipd host, outside container isolation, with the privileges of the crewship process. That is a strictly larger grant than the rest of the ADMIN surface, so it needs an instance administrator — on create, update and enable. An http hook PATCHed into a shell hook is the same grant by a longer road, and is refused for the same reason. The handler verifies instance authority and token scope. hooks.Register, hooks.Update and hooks.SetEnabledAuthorized also require the caller to supply verified authority; they cannot infer identity themselves. Runtime dispatch additionally checks approval of the exact stored configuration. Restore paths clear imported approval.

Toggling hooks

Flip a hook on or off. Both transitions emit system.hook_toggled into the journal with the actor’s user ID.
Enabling a hook can invoke shell commands, hit third-party webhooks, or dispatch subagents — enabling a host shell hook requires an instance administrator. Workspace OWNER or ADMIN can disable it to stop execution. Non-host toggles retain the workspace role gate.

Enable

Path parameters: id is the hook ID. The request has no body. Auth: Enabling a host shell hook requires an instance administrator and instance:admin token scope. Non-host hooks require workspace OWNER or ADMIN. Disabling host hooks is allowed for either workspace management authority or an instance administrator. Response: 200 OK
Errors: Emits system.hook_toggled into the journal with the actor’s user ID.

Disable

Path parameters: id is the hook ID. The request has no body. Same auth rules, same response shape with "enabled": false. Errors: 401 when unauthenticated, 403 for a non-OWNER/ADMIN, 404 when the hook is outside the workspace, and 500 on a database error.

Registration from Go

In-process provisioning code can skip HTTP and call the store directly. This is the same function the endpoints above call — there is one write path, not two:
The trailing allowedShell bool argument is the gate on HandlerKindShell: pass false without verified instance administrator authority — the function returns hooks.ErrShellHookNotAllowed if the hook is a shell kind and this flag is false. HTTP / subagent hooks are unaffected by the flag. Register also returns hooks.ErrUnknownEvent for an event outside the declared fifteen. hooks.Update(ctx, db, workspaceID, hook, allowedShell) is the equivalent for edits. It takes the full desired hook (not a patch — merging is the HTTP layer’s job), pins id + workspace_id from its arguments so a struct naming another workspace cannot move the row, and never rewrites created_at / created_by.

Host hook review after upgrade or restore

Host shell hooks require instance administrator authority, not workspace ownership. Existing host hook definitions are preserved but disabled on upgrade because prior versions did not record historical instance authority. The audit log records hook.host_review_required without recording command contents. A restored host hook also loses imported approval and stays disabled until local review. An instance administrator must inspect the current command and configuration, then use Enable in Lifecycle hooks or crewship hooks enable ID with the appropriate workspace and an instance-admin session/token (instance:admin). host_review_required in list/detail responses identifies pending review. Creating or editing a host hook requires the same authority. The default global lifecycle pause still prevents execution; it is not an authorization bypass. Container startup hooks are a separate feature and are unchanged.