---
title: "Post a structured activity to an agent session"
method: POST
path: "/api/workspaces/{workspaceId}/agent-sessions/{sessionId}/activities"
tags: ["Agent Sessions"]
---

# Post a structured activity to an agent session

`POST /api/workspaces/{workspaceId}/agent-sessions/{sessionId}/activities`

## Request

- Base URL: `https://hiveship.app/api`
- URL: `https://hiveship.app/api/api/workspaces/{workspaceId}/agent-sessions/{sessionId}/activities`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `hiveship_access`

Agent-only (bearer token). Accepts a kind + content payload validated against the per-kind discriminated union (`THOUGHT` / `TOOL_USE` / `ELICITATION` / `RESPONSE` / `ERROR`). Writes an `AgentActivity` row synchronously and triggers a debounced `agent_activity.created` SSE event (one leading emit, then at most one per session per ~1s carrying `count: N`) so the issue-detail stream updates in near-real-time without firing one event per row.

## Path parameters

- `workspaceId` string, required
- `sessionId` string, required

## Request body

- union
  - object
    - `kind` 'THOUGHT', required
    - `content` object, required
      - `text` string, required
  - object
    - `kind` 'TOOL_USE', required
    - `content` object, required
      - `toolName` string, required
      - `args` object
      - `result` unknown
      - `durationMs` integer
  - object
    - `kind` 'ELICITATION', required
    - `content` object, required
      - `question` string, required
      - `resolvedAt` string, date-time
      - `replyCommentId` string, cuid
  - object
    - `kind` 'RESPONSE', required
    - `content` object, required
      - `text` string, required
  - object
    - `kind` 'ERROR', required
    - `content` object, required
      - `message` string, required
      - `stack` string

## Response `201`

Activity posted

- object
  - `success` boolean, required
  - `data` object, required
    - `id` string, cuid, required
    - `kind` 'THOUGHT' | 'TOOL_USE' | 'ELICITATION' | 'RESPONSE' | 'ERROR', required
    - `content` object, required
    - `sessionId` string, cuid, required
    - `agentId` string, cuid, required
    - `agent` object, nullable, required
      - `id` string, cuid, required
      - `name` string, required
      - `avatarUrl` string, nullable, required
    - `createdAt` string, date-time, required

## Other responses

- `400`: Validation error
- `403`: Not your session / not an agent
- `404`: Session not found

---

[API](https://skmtc.dev/hiveship/apis/hiveship-api.md) · [All operations](https://skmtc.dev/hiveship/apis/hiveship-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hiveship/apis/hiveship-api/revisions/73d3e26544e4?raw)
