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

# Knowledge Processing

> Endpoints for building and removing knowledge graphs

These endpoints transform raw data into structured knowledge graphs and remove data from them.

## Cognify

**`POST /api/v1/cognify`** — Transform datasets into structured knowledge graphs.

Takes uploaded data and runs entity extraction, relationship detection, and embedding generation. This is the same pipeline described in [Cognify](/core-concepts/main-operations/legacy-operations/cognify).

```bash theme={null}
curl -X POST https://your-tenant.aws.cognee.ai/api/v1/cognify \
  -H "X-Api-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{"datasets": ["my_dataset"]}'
```

By default the request blocks until graph building finishes. Set `run_in_background=true` in the JSON body to return immediately and track progress with the [dataset status](/cognee-cloud/functionality/dataset-management#dataset-status) endpoint.

<Note>
  If you used [`remember`](/cognee-cloud/functionality/data-ingestion#remember) to ingest data, cognify was already executed automatically. You only need to call cognify separately when using the `add` endpoint.
</Note>

### Error responses

| Status | Body                                                   | Meaning                                                                                                                             |
| ------ | ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | `{"error": "No datasets or dataset_ids provided"}`     | Neither `datasets` nor `dataset_ids` was provided.                                                                                  |
| `402`  | `{"error": "Token budget exhausted", "detail": "..."}` | The configured LLM provider (or LiteLLM proxy) reported that its token budget is exhausted. Treat as terminal — see the note below. |
| `409`  | `{"error": "..."}`                                     | A referenced `ontology_key` does not exist.                                                                                         |
| `500`  | `{"error": "Pipeline run errored", "detail": "..."}`   | The pipeline run failed server-side (e.g. missing LLM API key, database connection failure, or a dataset that does not exist).      |

<Warning>
  `POST /api/v1/cognify` returns **`402 Payment Required`** with body `{"error": "Token budget exhausted", "detail": "..."}` when the configured LLM provider or LiteLLM proxy reports token-budget exhaustion. This response is **terminal** — Cognee does not retry budget-exhaustion errors, so clients should not reattempt the request automatically. Handle `402` by surfacing a top-up / billing flow rather than retrying.
</Warning>

## Forget

**`POST /api/v1/forget`** — Remove data from the knowledge graph.

Deletes content from the graph, vector store, and associated metadata. See [Forget](/core-concepts/main-operations/forget) for the underlying operation.

Identify the target with the **`dataset`** field (the dataset name) — not `dataset_name`. There is no `data` field; to remove a single item, pass its `data_id` together with a dataset.

```bash theme={null}
curl -X POST https://your-tenant.aws.cognee.ai/api/v1/forget \
  -H "X-Api-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{"dataset": "my_dataset"}'
```

### Request body

| Parameter    | Type    | Description                                                                                                                                                                              |
| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dataset`    | string  | Dataset **name** to delete (or clear with `memoryOnly`). Use this or `datasetId`, not both.                                                                                              |
| `datasetId`  | UUID    | Dataset UUID, alternative to `dataset`.                                                                                                                                                  |
| `dataId`     | UUID    | UUID of a single data item to remove. Requires `dataset` or `datasetId` to also be set.                                                                                                  |
| `memoryOnly` | boolean | When `true` with a dataset, delete only graph nodes/edges and vector embeddings and reset pipeline status — raw files are preserved so the dataset can be re-cognified. Default `false`. |
| `everything` | boolean | **DANGER:** when `true`, permanently deletes **all** datasets and data you own. Ignores `dataId`/`dataset`/`datasetId`. Default `false`.                                                 |

<Note>
  Field names are shown camelCased in the schema; snake\_case aliases (`data_id`, `dataset_id`, `memory_only`) are accepted too.
</Note>

### Forget behavior

* **`dataset` (or `datasetId`) alone** → delete the entire dataset and its graph/vector data.
* **`dataset` + `dataId`** → delete a single item, leaving the dataset intact.
* **`dataset` + `memoryOnly: true`** → clear the dataset's memory but keep the raw files, so you can re-run [cognify](#cognify).
* **`everything: true`** → wipe everything you own.

### Error responses

| Status | When                                                                                                                                                                                                                                                                                                                       |
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `422`  | Invalid parameter combination — e.g. both `dataset` and `datasetId`, `dataId` without a dataset, or `memoryOnly` without a dataset.                                                                                                                                                                                        |
| `500`  | `{"error": "An error occurred during deletion."}` — the deletion failed server-side. The most common cause is naming a dataset that does not exist or that you lack delete permission on. Confirm the exact name with [`GET /api/v1/datasets/`](/cognee-cloud/functionality/dataset-management#list-datasets), then retry. |

<Accordion title="Calling forget (and other JSON endpoints) with curl on Windows">
  The single quotes around the `-d` body in these examples are a Unix shell convention. `cmd.exe` and PowerShell do not strip them, so the body is sent with literal quotes and the request fails to parse.

  **Windows `cmd.exe`** — wrap the body in double quotes and escape the inner double quotes with `\`:

  ```bat theme={null}
  curl -X POST https://your-tenant.aws.cognee.ai/api/v1/forget ^
    -H "X-Api-Key: your-key" ^
    -H "Content-Type: application/json" ^
    -d "{\"dataset\": \"my_dataset\"}"
  ```

  **PowerShell** — escaping is fragile; passing the JSON from a file with `-d "@body.json"` avoids it entirely (this also works on macOS/Linux):

  ```powershell theme={null}
  '{"dataset": "my_dataset"}' | Out-File -Encoding ascii body.json
  curl -X POST https://your-tenant.aws.cognee.ai/api/v1/forget `
    -H "X-Api-Key: your-key" `
    -H "Content-Type: application/json" `
    -d "@body.json"
  ```
</Accordion>
