---
title: "Create an agent run and wait for the response"
method: POST
path: "/rest/api/v1/agents/runs/wait"
tags: ["Agents"]
---

# Create an agent run and wait for the response

`POST /rest/api/v1/agents/runs/wait`

Executes an [agent](https://developers.glean.com/agents/agents-api) run and returns the final response. **Note**: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the `input` object.

## Request body

- AgentRunCreate — Payload for creating a run. **Important**: If the agent uses an input form trigger, the `input` field is required and must include all fields defined in the form schema. Even fields marked as optional in the UI must be included in the request—use an empty string (`""`) for optional fields without values. Omitting required form fields will result in a 500 error.
  - `agent_id` string, required — The ID of the agent to run.
  - `input` object — The input to the agent. Required when the agent uses an input form trigger.
  - `messages` Message[] — The messages to pass an input to the agent.
    - `role` string — The role of the message.
    - `content` object[] — The content of the message.
      - `text` string, required
      - `type` 'text', required
  - `metadata` object — The metadata to pass to the agent.

## Response `200`

Success

- AgentRunWaitResponse
  - `run` AgentRun — Payload for creating a run. **Important**: If the agent uses an input form trigger, the `input` field is required and must include all fields defined in the form schema. Even fields marked as optional in the UI must be included in the request—use an empty string (`""`) for optional fields without values. Omitting required form fields will result in a 500 error.
    - `agent_id` string, required — The ID of the agent to run.
    - `input` object — The input to the agent. Required when the agent uses an input form trigger.
    - `messages` Message[] — The messages to pass an input to the agent.
      - `role` string — The role of the message.
      - `content` object[] — The content of the message.
        - `text` string, required
        - `type` 'text', required
    - `metadata` object — The metadata to pass to the agent.
    - `status` 'error' | 'success' — The status of the run. One of 'error', 'success'.
  - `messages` Message[] — The messages returned by the run.
    - `role` string — The role of the message.
    - `content` object[] — The content of the message.
      - `text` string, required
      - `type` 'text', required

## Other responses

- `400` — Bad request
- `403` — Forbidden
- `404` — Not Found
- `409` — Conflict
- `422` — Returned when the agent has tools the caller has not authorized. The response body enumerates the tools that need connecting.
- `500` — Internal server error

---

[API](https://skmtc.net/gleanwork/apis/glean-api.md) · [All operations](https://skmtc.net/gleanwork/apis/glean-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gleanwork/glean-api/revisions/ebd602e4aea4/schema)
