> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ontora.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query a campaign with GraphRAG

> Ask grounded questions across every transcript in a campaign and get answers with patterns, divergences, and citations.

The GraphRAG endpoint is Ontora's most powerful query primitive. It runs vector search over transcript chunks, traverses the entity graph for context, and returns a synthesized answer along with structured patterns and divergences.

## Anatomy of a query

```bash theme={null}
curl -X POST https://api.ontora.com/v1/interviews/$ID/graph/query \
  -H "X-API-Key: $ONTORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What are the most painful manual steps in the daily scheduling workflow?",
    "anonymize": false,
    "top_k": 12
  }'
```

### Parameters

| Field                  | Type   | Default | Notes                                                      |
| ---------------------- | ------ | ------- | ---------------------------------------------------------- |
| `query`                | string | —       | Required. Natural-language question.                       |
| `anonymize`            | bool   | `false` | Strip names from cited evidence.                           |
| `top_k`                | int    | `12`    | Chunk retrieval depth. Raise for breadth, lower for speed. |
| `conversation_history` | array  | `[]`    | Prior turns, for follow-up questions.                      |

### Response

```json theme={null}
{
  "answer": "Three manual steps came up across most operations leads...",
  "patterns": [
    {
      "claim": "Cross-referencing two spreadsheets for shift availability",
      "supporting_contacts": 7,
      "citations": ["cv_abc:chunk_12", "cv_def:chunk_4"]
    }
  ],
  "divergences": [
    {
      "claim": "Some teams already use a scheduling tool but find it slower",
      "contacts": 2
    }
  ],
  "verifications": [
    {
      "fact": "Morning standup runs 15 minutes",
      "confirmed_by": 9
    }
  ]
}
```

The endpoint streams responses via Server-Sent Events when the response gets long — if you're calling it from the browser or a streaming-aware client, you'll see the answer materialize token by token.

## Asking follow-ups

Pass the prior turns as `conversation_history` to keep context:

```json theme={null}
{
  "query": "Which of those would be highest leverage to automate first?",
  "conversation_history": [
    {"role": "user", "content": "What are the most painful manual steps?"},
    {"role": "assistant", "content": "Three manual steps came up..."}
  ]
}
```

## Anonymized output

For sharing externally, set `"anonymize": true`. Names are replaced with role-based identifiers (e.g., "an operations lead") and email addresses are stripped from citations.

## CLI

```bash theme={null}
ontora query $ID "What are the most painful manual steps in scheduling?"
ontora query $ID "..." --anonymize --top-k 20
```

## When the graph isn't ready

GraphRAG requires the entity-extraction pipeline to have run on the transcripts. New campaigns return `409 Conflict` with `graph_not_ready` until indexing is complete — usually a few minutes after the first conversations land. Check status with:

```bash theme={null}
curl https://api.ontora.com/v1/interviews/$ID/graph/status \
  -H "X-API-Key: $ONTORA_API_KEY"
```
