Three ways to call an agent.
01·Interfaces Create a research job, poll its status or slug, and receive a signed webhook when it finishes. Agent Card discovery and JSON-RPC task methods so your own agents can call Grep. Expose Grep as MCP tools inside Claude, Cursor, or any MCP-compatible client.
- CurrentREST API v2Create a research job, poll its status or slug, and receive a signed webhook when it finishes.POST /api/v2/researchReference
- NewA2A ProtocolAgent Card discovery and JSON-RPC task methods so your own agents can call Grep.Spec
- NewMCP ToolsExpose Grep as MCP tools inside Claude, Cursor, or any MCP-compatible client.Connect
From API key to report in four calls.
02·The v2 loop Generate a bearer token at /developers/keys and store it server-side as GREP_API_KEY. Submit a question with effort low, medium, high, or build. Add Idempotency-Key only when you need retry-safe creates. Read /research/{job_id_or_slug} for status, or poll /timeline to show what the agent is doing live. Read report.markdown, structured_output, revisions, and workspace files from the completed job.
A small surface for powerful integrations.
03·What v2 exposes Optional Idempotency-Key makes network retries return the original job instead of starting another billable run. Cursor-paginated events show tool calls, sub-agent work, final answers, and sanitized previews. Pass json_schema with the job and read the filled fields from structured_output on the detail response. Upload input files before the job starts, then list or download the files the agent produced. Check quota before a run, read credit headers, and query billing usage or transactions for dashboards. Register webhook_url on create to receive signed callbacks when a job reaches a terminal state.
Create, poll, read report.
The same contract powers the playground and your terminal: API-key auth, idempotent create, defensive polling, and report.markdown as the final prose output. Completed jobs return the report body, optional structured output, and published report revisions.
bash
import os
import time
import requests
API_KEY = os.environ["GREP_API_KEY"]
BASE = "https://api.grep.ai/api/v2"
TERMINAL = {"completed", "complete", "failed", "blocked", "cancelled"}
create = requests.post(
f"{BASE}/research",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"question": "Due diligence on Stripe Inc", "effort": "medium"},
)
create.raise_for_status()
job_id = create.json()["job_id"]
while True:
detail = requests.get(
f"{BASE}/research/{job_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
).json()
if detail["status"] in TERMINAL:
break
time.sleep(2)
print(detail.get("report", {}).get("markdown", ""))bash
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"slug": "due-diligence-on-stripe-inc",
"status": "completed",
"report": {
"markdown": "# Stripe Inc\n\nStripe builds financial infrastructure...",
"revision_sha": "9f4c2a1"
},
"structured_output": {
"company": "Stripe Inc",
"risk_flags": []
},
"revisions": [
{ "commit_sha": "9f4c2a1", "checkpoint_type": "new_subjob" }
]
}Open the exact surface you need.
04·Docs that map to real routes
- QuickstartFirst v2 call, polling loop, and full Python example.
- API keysGenerate, rotate, and revoke bearer tokens for the public API.
- AuthenticationAPI key auth, scopes, and key rotation for the public API.
- API v2 referenceLive OpenAPI reference for every v2 endpoint and schema.
- IdempotencyRetry-safe creates with the Idempotency-Key header.
- WebhooksSigned completion callbacks and request correlation headers.
- ErrorsStatus codes and error response shapes for v2.
- PaginationCursorPage shape for research lists, timelines, and billing transactions.
- Data sourcesConnectors the agents pull evidence from.
- A2A AgentAgent Card discovery and JSON-RPC task methods for agent clients.
- API playgroundRun the same v2 calls in the product with your own API key.
Build against v2.
The old v1 surface still exists for legacy integrations. New work should start with /api/v2/research and the live v2 reference.