---
title: "Semantic entity search within a space's graph"
---

> 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.

# Semantic entity search within a space's graph

Path: CloudRaker Workspace API › Ontology

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

Semantic search over the entities in a space. JSON body: `text` (1-2000 chars, required — the natural-language query), optional `topK` (1-100) to cap results, optional `types` (non-empty array of organization | person | location | identifier | date | amount | other) to restrict to entity kinds. Returns `{ matches }`, each `{ id, type, name, score }` ranked by similarity (higher `score` = closer). Requires `space:read` on `:spaceId`; missing access surfaces as a 404.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

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

## Request body

_Required._

- `text` (`searchSpaceOntology.text`; string, required)
  - minLength 1; maxLength 2000; example `"acme purchase orders"`
- `topK` (`searchSpaceOntology.topK`; integer, optional)
  - min 1; max 100
- `types` (`searchSpaceOntology.types`; array<string>, optional)
  - one of `"organization"`, `"person"`, `"location"`, `"identifier"`, `"date"`, `"amount"`, `"other"`

## Example request

```json
{
  "text": "acme purchase orders",
  "topK": 1,
  "types": [
    "organization"
  ]
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/ontology/search' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "text": "acme purchase orders",
  "topK": 1,
  "types": [
    "organization"
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/ontology/search';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({text: 'acme purchase orders', topK: 1, types: ['organization']})
};

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/search"

payload = {
    "text": "acme purchase orders",
    "topK": 1,
    "types": ["organization"]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

Ranked entity matches.

#### Example

```json
{
  "matches": [
    {
      "id": "string",
      "type": "organization",
      "name": "string",
      "score": 0
    }
  ]
}
```

- `matches` (`searchSpaceOntology.response.200.matches`; array<object>, required)
  - `id` (`searchSpaceOntology.response.200.matches.id`; string, required)
  - `type` (`searchSpaceOntology.response.200.matches.type`; string, required)
    - example `"organization"`
  - `name` (`searchSpaceOntology.response.200.matches.name`; string, required)
  - `score` (`searchSpaceOntology.response.200.matches.score`; number, required) — Similarity in [-1, 1]; higher is closer.

### 400

Validation Error

#### Example

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

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


Source: https://docs.cloudraker.com/workspace/api/ontology/search-space-ontology/index.md
