Skip to main content
POST /v1/agent/invoke Send a message to an agent from your own app or service.

Authentication

Send your workspace API key in the Authorization header.
Agent webhook triggers use the agent webhook secret instead of an API key. See Webhook trigger.

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. 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:
They can also use this object shape when you want to provide metadata:
Only https:// URLs are accepted. Up to five attachments are allowed per message. 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. Image attachments are sent to the model as multimodal input. For image URLs without a file extension, use the object shape with file_type set to an image MIME type (for example image/png). 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
For extensionless URLs, such as Fetch Hive Media Library URLs, pass the URL directly. Fetch Hive allow-lists the URL for read_file, and the file tool detects the actual type when it fetches the file. Valid:
Invalid:
The code snippet dialog uses this body shape:
When using thread_id for persistent conversations:
When using messages for caller-managed (stateless) history:
If a previous assistant turn generated a file, pass that file back on the relevant history message through 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

If streaming 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. If the client disconnects first, Fetch Hive treats it as a silent cancellation and does not create a failed agent run, bill usage, or report a provider-error event unless the provider had already completed and usage was committed. Example reasoning event:
Example response event:
Example tool event:
Example final usage event:
Example error event:
If streaming is false, Fetch Hive returns one JSON response. Provider execution failures return 502 Bad Gateway with an error message.

Example