POST /v1/agent/invoke
Send a message to an agent from your own app or service.
Authentication
Send your workspace API key in theAuthorization header.
Request body
Open an agent in the editor and click Code Snippet to see the current public request shape in Fetch Hive.Webhook trigger
POST /v1/agent/webhooks/{agent_id}
Use an agent webhook trigger when an external service should start an agent run without a workspace API key. The request must include the agent webhook secret in X-Fetch-Hive-Webhook-Secret. If a third-party tool cannot set custom headers, use ?secret=YOUR_WEBHOOK_SECRET as a fallback.
Agent webhook triggers always use callback delivery. Include async.callback_url; Fetch Hive returns 202 with request_id and run_status: "running", then delivers either agent.completed or agent.failed to the callback URL.
message is required. thread_id is optional and can be reused to resume a caller-managed thread. metadata follows the same flat scalar-only rule as normal agent invokes and appears in log filtering.
Fetch Hive signs the outbound callback with the same webhook secret used for inbound trigger authentication.
Callback data contains response on agent.completed and error on agent.failed; use the top-level event_type and request_id for terminal state and correlation.
| Field | Type | Required | Description |
|---|---|---|---|
agent | string | Yes | The agent ID |
message | string | Yes | The message you want to send |
streaming | boolean | No | Stream response events instead of waiting for one final JSON response |
thread_id | string | No | An arbitrary string identifying the conversation thread. Fetch Hive creates a new thread on first use and resumes it on subsequent calls with the same value. Ideal for persistent, multi-turn conversations. |
messages | array | No | Previous conversation turns to use as context without persisting history to the database. Each item: { "content": string, "role": "user" | "assistant" | "system", "attachments"?: array, "image_urls"?: array }. Use this when you manage conversation state yourself. |
attachments | array | No | HTTPS file URLs attached to the current message. Each item can be a URL string or an object with file_url. Supported document files are CSV, XLSX, PDF, DOCX, and text/Markdown by extension. Images can also be passed here. |
image_urls | array | No | Backward-compatible shorthand for HTTPS image attachments on the current message. Use this for image-only integrations, especially when the image URL has no extension. |
metadata | object | No | Flat caller-defined metadata for audit and log filtering. This is not added to the agent prompt. |
metadata must be a flat object. Keys must be non-empty strings, and values must be strings, numbers, booleans, or null. Arrays and nested objects are rejected before the run starts.
attachments items can be simple URL strings:
https:// URLs are accepted. Up to five attachments are allowed per
message, counting both attachments and image_urls. Document attachments are
exposed to the agent through the system read_file tool as an
<available_files> manifest; the agent calls read_file before relying on
document contents. If an attachment URL or type is invalid, Fetch Hive returns
422 Unprocessable Entity instead of opening the stream.
Supported document attachments:
- CSV:
text/csv,.csv - XLSX:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,.xlsx - PDF:
application/pdf,.pdf - DOCX:
application/vnd.openxmlformats-officedocument.wordprocessingml.document,.docx - Text and Markdown by extension:
.txt,.md,.markdown
read_file, and the file tool
detects the actual type when it fetches the file.
Valid:
thread_id for persistent conversations:
messages for caller-managed (stateless) history:
messages[].attachments. Fetch Hive uses the
structured attachment URLs in current and historical messages to authorize
read_file access for follow-up turns; URLs mentioned only in plain text are
not treated as file-tool attachments.
Response
Ifstreaming is true, Fetch Hive returns a stream of events. If the provider fails after the stream has opened, Fetch Hive sends a final error event before closing the stream.
Example reasoning event:
streaming is false, Fetch Hive returns one JSON response. Provider execution failures return 502 Bad Gateway with an error message.
Example
Related
- See Authentication for API key setup
- See Agents for agent setup and runtime context
- See Testing with Chat for the in-editor testing flow
- See Run with API for an agent-focused guide

