Rate limits are applied per workspace, per minute: 30 for listing agents, 60 for reading one, 10 for creating a thread, and 60 for reading a thread.
Overview
Agent work is asynchronous. You create a thread, which holds the agent’s run, and poll that thread until it reaches a terminal status. Creating a thread returns immediately with a thread id.Key Capabilities
- Reuse Your Own Agents: Run the agents your firm already built and published, without rebuilding their logic in your own systems
- Attach Documents Per Run: Send documents alongside the prompt for the agent to read
- Grounded Answers: Receive citations that name the source document, page, and quoted passage behind each claim
- Collect Generated Files: Retrieve memos, summaries, and other files the agent produced
Before You Start
The Agents API must be enabled for your workspace. Until it is, every endpoint returns404 rather than an authorization error. Contact your Account Manager or reach out to us at support@harvey.ai to request it.
Your token needs the Agents and workflows API and Use agents and workflows permissions, set in the API Tokens section of your workspace settings.
API tokens act as your workspace’s service user rather than as the person who created the token. For each agent you want to call:
- Share the agent with the workspace, at
RUNaccess or higher. An agent private to one person is invisible to the API, even if that person can run it in the web app. - Share every Vault project and knowledge source the agent uses. If the service user cannot reach an agent’s sources, the agent itself becomes unreachable.
- Publish the agent. Unpublished agents, and published agents with no instructions, cannot be listed or run.
404, the same response as an agent that does not exist.
The Request Cycle
Create a thread, then poll it untilstatus is terminal:
id it returns — it is the only handle you get on the thread, and how you read the result.
Use Cases
Use Case 1: Discover the Agents You Can Run
Challenge: An integration hardcoding agent names breaks the moment someone renames or replaces an agent, and there is no reliable way to tell which agents the integration is actually allowed to run. Solution: List the agents available to your workspace and store theagent_id values you need. Pass back pagination.next_cursor until has_more is false.
agent_id.
Use Case 2: Confirm an Agent Before Running It
Challenge: A storedagent_id can go stale — the agent may be unpublished, its knowledge sources may have moved out of reach, or it may have been republished with different behavior.
Solution: Read the agent before a scheduled batch. It resolves exactly as creating a thread would, so an id it returns is an id the run endpoint accepts.
version_id against the value you last stored to detect that an agent was republished. A run always executes the latest published version and cannot be pinned to an earlier one.
Use Case 3: Run an Agent Over Incoming Documents
Challenge: Contracts arrive continuously from counterparties, vendors, and internal teams, and each needs the same first-pass review before a lawyer sees it. Solution: Create a thread from your intake pipeline, attaching the document for the agent to read.Use Case 4: Attribute Agent Work to a Client Matter
Challenge: Work run through an integration still needs to reach the right client and matter for billing, retention, and conflicts. Solution: Passclient_matter_id when creating a thread. It accepts either the matter UUID that GET /api/v1/client_matters returns as id, or the matter’s name.
The response reports the matter it resolved to, as a UUID, even when you supplied a name. If your workspace requires a client matter on every query, omitting it returns 400 with the code RUN_REFUSED.
Use Case 5: Return Results to Your Own System
Challenge: Reviewers work in a matter management or contract system, not in Harvey, and need the agent’s conclusions where they already are. Solution: Oncestatus is COMPLETED, read output.text for the answer and output.citations for the sources behind it. Each citation names the source document, the page it appears on, and the quoted passage, with <mark> wrapping the quoted span.
output.files. Fetch their bytes with POST /api/v1/files/download using file_id. To hand the work to a person instead, link them to harvey_url.
Best Practices
Poll on Terminal Status
Readstatus and stop when it is COMPLETED, ERRORED, or CANCELLED. Do not wait for a specific non-terminal value, and do not treat a 200 as meaning the thread has finished — an in-progress thread returns 200 as well.
Write Specific Prompts
- Avoid: “Review this contract”
- Use: “Summarize the termination rights in this agreement. For each, state who may exercise it, the notice period, and any cure period.”
Switch on Error Codes
Requests rejected before a thread is created carry a machine-parseablecode. Switch on it rather than matching message text, which is localized and may change.
Error Handling
The Agents APIs use standard HTTP status codes. Anything your workspace cannot reach returns404 rather than 403 — one 404 covers a resource that does not exist, one belonging to another workspace, and one you lack access to. An ethical wall is the only case that returns 403.
Requests to
POST /api/v1/agent_threads that are rejected before the thread is created return one of these codes:
Need help getting started? Contact your Harvey Customer Success Manager for more information.