Authentication
Endpoint
POST https://api.fetchhive.com/v1/agent/invoke
If you want Fetch Hive to generate the cURL example for you, open Agents, then use More -> Get Code. If you are already in the editor for a specific agent, click Code Snippet instead.
Request
Use this request shape:| Field | Type | Required | Description |
|---|---|---|---|
agent | string | Yes | The agent ID |
message | string | Yes | The message you want to send to the agent |
streaming | boolean | No | Whether the response should stream back as events |
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. |
messages | array | No | Previous conversation turns supplied by the caller. Used as context without persisting to the database. Each item: { "content": string, "role": "user" | "assistant" | "system", "attachments"?: array, "image_urls"?: array }. |
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 flat and scalar-only: strings, numbers, booleans, or null. Nested objects and arrays return a validation error 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
a 422 validation error instead of opening the stream. The error uses the
standard error_code, error, and message fields; error and message are
localized from the authenticated account language when available.
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.
The in-app snippet shows the same body shape:
Basic example
metadata for audit fields you want to see or filter in logs, such as customer IDs, plan names, regions, or experiment names. It is stored with the run and displayed under User metadata in logs. See Invoke metadata for examples and log filtering details.
Response
Ifstreaming is true, the route returns a stream of events rather than one final JSON object. If the provider fails after the stream has opened, the route sends a final error event before closing the stream.
Streaming response
The stream can include a summary event, reasoning chunks, response chunks, tool events, a final usage event, or an error event. Events arrive in this order when all successful events are present:summary → reasoning → response → tool → usage. An error event can arrive instead of usage if the provider fails mid-stream.
Summary event (only emitted on threads with auto-summarization enabled):
original_token_count is the token count before compression; context_limit is the model’s total context window. You can surface this to users as a “conversation summarized” indicator, or ignore it — your app’s behaviour is unaffected either way.
Reasoning event:
Non-streaming response
Ifstreaming is false, the route returns one JSON response with the generated output, usage data, and the request ID you can use to inspect the run in Logs. Provider execution failures return 502 Bad Gateway with an error message.
The exact output field can vary by provider, but the response includes the run metadata you need. For example:
Multi-turn conversations
The invoke endpoint supports two approaches for multi-turn conversations.Persistent threads (Fetch Hive manages history)
Pass athread_id — any string you choose — and Fetch Hive will automatically create the thread on the first call and resume it on every subsequent call with the same value. Message history is stored in Fetch Hive and included in the context automatically.
thread_id — a user ID, session ID, ticket number, or any other identifier that makes sense for your use case.
Stateless history (caller manages history)
If you prefer to manage conversation state yourself, pass the previous turns in themessages array. Fetch Hive uses the provided history for context but does not persist it.
messages[].attachments. Fetch Hive uses the
structured attachment URLs in current and historical messages to attach the
provider-facing read_file tool and authorize access for follow-up turns; URLs
mentioned only in plain text are not treated as file-tool attachments.
Use messages when you already maintain your own chat state and do not need Fetch Hive to store the conversation history.

