---
title: "Extract a file into the ontology (doc + space + org levels)"
---

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

# Extract a file into the ontology (doc + space + org levels)

Path: CloudRaker Workspace API › Ontology

`POST /spaces/{spaceId}/ontology/ingest`

Extracts entities and relations from a file once and populates the document, space, and organization graph levels together. JSON body: `fileId` (required, non-empty). The file must belong to `:spaceId` or the request returns 404. Returns `{ fileId, results }`, one `IngestNamespaceResult` per graph level with `status` (ok | error) and the `entities`/`mentions`/`edges` counts written. Idempotent — re-ingesting creates or enhances the existing graphs. Requires `space:contribute` on `:spaceId`; lacking write permission is a 403 (a missing `space:read` prerequisite would be a 404).

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`ingestFileOntology.path.spaceId`; string, required)

## Request body

_Required._

- `fileId` (`ingestFileOntology.fileId`; string, required)
  - minLength 1; example `"4f6f1c1e-1b2a-4d3c-9e8f-7a6b5c4d3e2f"`

## Example request

```json
{
  "fileId": "4f6f1c1e-1b2a-4d3c-9e8f-7a6b5c4d3e2f"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/ontology/ingest' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "fileId": "4f6f1c1e-1b2a-4d3c-9e8f-7a6b5c4d3e2f"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/ontology/ingest';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({fileId: '4f6f1c1e-1b2a-4d3c-9e8f-7a6b5c4d3e2f'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/spaces/<spaceId>/ontology/ingest"

payload = { "fileId": "4f6f1c1e-1b2a-4d3c-9e8f-7a6b5c4d3e2f" }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Per-level ingestion results with the counts written.

#### Example

```json
{
  "fileId": "string",
  "results": [
    {
      "namespace": "string",
      "status": "ok",
      "entities": -9007199254740991,
      "mentions": -9007199254740991,
      "edges": -9007199254740991,
      "error": "string"
    }
  ]
}
```

- `fileId` (`ingestFileOntology.response.200.fileId`; string, required)
- `results` (`ingestFileOntology.response.200.results`; array<object>, required)
  - `namespace` (`ingestFileOntology.response.200.results.namespace`; string, required) — The graph level written.
  - `status` (`ingestFileOntology.response.200.results.status`; string, required)
    - one of `"ok"`, `"error"`
  - `entities` (`ingestFileOntology.response.200.results.entities`; integer, required)
    - min -9007199254740991; max 9007199254740991
  - `mentions` (`ingestFileOntology.response.200.results.mentions`; integer, required)
    - min -9007199254740991; max 9007199254740991
  - `edges` (`ingestFileOntology.response.200.results.edges`; integer, required)
    - min -9007199254740991; max 9007199254740991
  - `error` (`ingestFileOntology.response.200.results.error`; string, optional)

### 400

Validation Error

#### Example

```json
{
  "success": false,
  "error": [
    null
  ],
  "data": null
}
```

- `success` (`ingestFileOntology.response.400.success`; boolean, required)
  - one of `false`
- `error` (`ingestFileOntology.response.400.error`; array<unknown>, required)
- `data` (`ingestFileOntology.response.400.data`; unknown, required)


Source: https://docs.cloudraker.com/workspace/api/ontology/ingest-file-ontology/index.md
