Skip to content
GenerateDocs
What's new
APICall agents over HTTP
On this page

Call a Generate agent over HTTP with an API key

Turn on API Access for an agent, then send it questions, files, project context and follow-ups with one POST request, and read the answer it returns.

EditionsEnterprise: availableConsumer: availableStorage: availableHealthcare: availableAirgapped: available in partno web or connectors
Who can do thisAnyone who can edit the agent; the key needs the API keys privilege.
WhereThe agent's menu, then Edit, then API Access.

This page shows you how to let a script, a CRM or a support desk ask one of your agents a question with a single POST request.

Give the agent an address that accepts requests.

  1. Open the agent’s settings

    Open the agent and its settings.

  2. Turn on API Access

    Turn on API Access (“Allow this agent to be triggered via HTTP API”).

    The agent form’s Web search, Live Browser and API Access rows, with the API Access switch to turn onOpen full size
    Shown in the enterprise edition.
  3. Save the agent

    Until it is saved, the examples use a placeholder agent ID. The API Access section then shows the address and examples to copy.

Ask the agent a question and read its answer.

  1. Copy the address

    Copy Public URL (POST) from the agent’s API Access section.

  2. Send the request

    Send the key in the X-API-Key header and the question as query, as in the example below.

  3. Read the response

    The request stays open until the agent has finished, then returns one JSON response, described in Response fields.

Terminal window
curl -X POST "https://<your Generate address>/api/v1/triggers/agent/<agent-id>" \
-H "X-API-Key: <your key>" \
-H "Content-Type: application/json" \
-d '{"query": "Summarize the open renewal risks for this quarter."}'

The run happens as the owner of the API key: it uses their access and their connections.

Once API Access is on and the agent saved, the section shows:

  • Public URL (POST), the address to call, with Copy. It has the form https://<your Generate address>/api/v1/triggers/agent/<agent-id>.
  • The key the examples use, named in “Using key …”. Generate provisions one for you the first time; you manage it in Settings, then API Keys (see API keys).
  • Ready-to-copy cURL examples for a JSON request, a request with files, a request inside a project, and a follow-up in the same chat.
  • A button that downloads a Markdown guide (.md) to hand to whoever writes the code that calls the agent.
Field What it holds
answer The agent’s reply as text
chat_id The chat the run created; send it back to ask a follow-up
citations The sources the answer cites
tool_calls The tools the agent called
uploaded_file_ids IDs of files you attached in the request
connected_database_id The ID of a database you connected in the request
Field Use it to
query Ask the question. Required.
chat_id Continue an earlier chat, so the agent sees the conversation so far.
project_id Run inside a project, with its knowledge.
file_ids, folder_ids, database_ids Point the agent at specific files, folders or databases you already added.
connectors Name connectors the run may use, as objects with a name.
web_search_enabled Let the agent search the web. Off unless you set it.
skills Name skills to add to the run.
timezone Give the agent your time zone, such as Europe/London.
database_inline Connect a database for this request, with name, type and credentials.
file_wait_timeout_seconds, database_wait_timeout_seconds How long to wait for attached files (60 seconds by default) or an inline database (180 seconds) to be ready. Neither wait can exceed 600 seconds.

To attach files, send multipart/form-data instead: the JSON body goes in a payload field and each file in a files part.

Terminal window
curl -X POST "https://<your Generate address>/api/v1/triggers/agent/<agent-id>" \
-H "X-API-Key: <your key>" \
-F 'payload={"query":"Summarize this report in 3 bullets."};type=application/json' \
-F "files=@./report.pdf"

A call cannot ask anyone which account to use, so Generate checks the agent’s connectors before the run starts. Each connector runs on the key owner’s own connection, or on a shared connection they were granted. If one is missing, the call is refused with status 409 and nothing is created. Connect the missing app as the key owner, or ask an administrator for a shared connection, then call again.

Setting run_as_user_id on a connector to anyone other than the key owner is refused with status 422 (run_as_not_allowed). To act as another person, use that person’s key.

If your administrator requires shared accounts for unattended runs, a call that would use a personal account is refused. See Share connections with your organization.

Status Cause
400 query is missing, the body is empty, or an inline database is missing name, type or credentials.
401, 403 The key is missing, invalid, revoked or not scoped for chat agents. See API keys.
404 The agent does not exist or the key owner cannot reach it.
409 A connector the agent needs is not connected for the key owner.
502 An attached file or inline database failed to process; the body names it.
504 An attached file or inline database was not ready in time. It is kept, so you can retry with its ID.

Last updated on