> Source: https://wexa.ai/docs/tools/create-ontology

# create-ontology

Define graph ontology (node types, relationships, properties) for this project. In Simple/auto mode the ontology self-organizes and commits immediately; in Advanced/manual mode use mode=proposal to stage and mode=commit to apply (commit may require approval).

## What it is called on each surface

This tool has three names, and they are not the same. The gateway registers it as `create-ontology`, which is what
the Wexa MCP server advertises and what the canonical REST route is called. Both SDKs post to
`/v1/ontology` instead — a route that predates the one-path-per-tool rule and is kept alive as an
alias precisely so existing callers keep working. Either path answers.

| Surface | Name |
| --- | --- |
| Wexa MCP server | `create-ontology` |
| REST API | `POST /v1/ontology` (also `POST /v1/create-ontology`) |
| TypeScript SDK | `fabric.createOntology()` |
| Python SDK | `fabric.create_ontology()` |

## Arguments

1 of the 5 arguments is required. Omitting a required one is refused before the tool runs, at the validation stage, so it costs nothing and changes nothing.

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `domain` | string | Required | — |
| `mode` | one of 2 | Optional | Advanced mode only: proposal stages; commit applies (may require approval). Ignored in Simple mode. One of: `proposal`, `commit`. |
| `nodes` | array | Optional | Node types: \{name,label,category(person\|interaction\|context\|other),properties[],primaryKey,...\} |
| `relationships` | array | Optional | Relationships: \{name,label,fromNode,toNode,cardinality\} |
| `resume_token` | string | Optional | Resume token from an approved request (Advanced mode) |

`project_id`, `projectID`, `organization_id` and `executed_by` are not arguments you pass: the
platform binds all four from the credential you authenticated with, and both SDKs refuse them
before the request leaves your process — see
[server-bound arguments](/docs/get-started/scope-and-server-bound-arguments).

## What it returns

The three surfaces wrap this differently, and code written against one will not read another
correctly — see [return shape](/docs/tools/overview#return-shape).

A real response, captured from a live call to `create-ontology`:

**Result of create-ontology**

**REST API**

```json
{
  "lifecycle_id": "qlc_000169",
  "result": {
    "live_schema": {
      "version": "",
      "domain": "",
      "nodes": [
        {
          "name": "FixtureCustomer",
          "label": "FixtureCustomer",
          "category": "person",
          "properties": [
            {
              "name": "id",
              "type": "string"
            },
            {
              "name": "name",
              "type": "string"
            }
          ]
        },
        {
          "name": "ProbeCustomer",
          "label": "ProbeCustomer",
          "category": "docsprobedomain",
          "properties": [
            {
              "name": "id",
              "type": "string"
            },
            {
              "name": "name",
              "type": "string"
            }
          ]
        }
      ],
      "relationships": []
    },
    "mode": "auto",
    "self_organized": true,
    "status": "committed"
  }
}
```

**Wexa MCP server**

```json
{
  "content": [
    {
      "type": "text",
      "text": "{\"lifecycle_id\":\"qlc_000169\",\"result\":{\"live_schema\":{\"version\":\"\",\"domain\":\"\",\"nodes\":[{\"name\":\"FixtureCustomer\",\"label\":\"FixtureCustomer\",\"category\":\"person\",\"properties\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"}]},{\"name\":\"ProbeCustomer\",\"label\":\"ProbeCustomer\",\"category\":\"docsprobedomain\",\"properties\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"}]}],\"relationships\":[]},\"mode\":\"auto\",\"self_organized\":true,\"status\":\"committed\"}}"
    }
  ],
  "isError": false
}
```

**TypeScript SDK**

```ts
// the object you get back IS the result — there is no `.result` to read
{
  live_schema: {
    version: '',
    domain: '',
    nodes: [
      {
        name: 'FixtureCustomer',
        label: 'FixtureCustomer',
        category: 'person',
        properties: [
          {
            name: 'id',
            type: 'string'
          },
          {
            name: 'name',
            type: 'string'
          }
        ]
      },
      {
        name: 'ProbeCustomer',
        label: 'ProbeCustomer',
        category: 'docsprobedomain',
        properties: [
          {
            name: 'id',
            type: 'string'
          },
          {
            name: 'name',
            type: 'string'
          }
        ]
      }
    ],
    relationships: []
  },
  mode: 'auto',
  self_organized: true,
  status: 'committed'
}

// The TS SDK names these camelCase — lifecycleId, traceId — where Python uses
// lifecycle_id and trace_id. Both are non-enumerable: readable, but omitted by
// Object.keys() and JSON.stringify(). `result.lifecycleId` here is undefined.
result.lifecycleId // 'qlc_000169'
```

**Python SDK**

```python
# a dict subclass; `result` is already unwrapped
{
 "live_schema": {
  "version": "",
  "domain": "",
  "nodes": [
   {
    "name": "FixtureCustomer",
    "label": "FixtureCustomer",
    "category": "person",
    "properties": [
     {
      "name": "id",
      "type": "string"
     },
     {
      "name": "name",
      "type": "string"
     }
    ]
   },
   {
    "name": "ProbeCustomer",
    "label": "ProbeCustomer",
    "category": "docsprobedomain",
    "properties": [
     {
      "name": "id",
      "type": "string"
     },
     {
      "name": "name",
      "type": "string"
     }
    ]
   }
  ],
  "relationships": []
 },
 "mode": "auto",
 "self_organized": True,
 "status": "committed"
}

out.lifecycle_id  # 'qlc_000169' — an attribute, not a key
```

Keeping the `lifecycle_id` is what lets you ask later why a call was allowed, refused or held.

## Calling it

The same call on all four surfaces. Pick a tab once and every code block in the documentation follows it.

The ids in this example are real, and resolve against the project the documentation is written
against. Swap them for your own. A value in angle brackets is one only you can supply, and the
platform refuses a literal `<...>`.

**Call create-ontology**

**Wexa MCP server**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "create-ontology",
    "arguments": {
      "domain": "<domain>"
    }
  }
}
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/ontology \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"domain":"<domain>"}'
```

**TypeScript SDK**

```ts
import { Fabric } from '@wexa-fabric/sdk'

const fabric = new Fabric()
const { result } = await fabric.createOntology({
  domain: "<domain>"
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.create_ontology(domain="<domain>")
```

## Errors

Both SDKs raise the same typed errors, chosen from the gateway's own error string first and its
HTTP status second. `create-ontology` checks the `fabric:ontology.write` grant, and reaches the seven classes every
tool reaches — listed under [the common set](/docs/tools/errors#the-common-set). These are the ones specific to it:

| Error | Status | Raised when |
| --- | --- | --- |
| `ApprovalRequired` | 202 | A policy held this call for a person to approve. The error carries the approval id; see below. |

## Governance

Every call to `create-ontology` runs through the same ten-stage lifecycle as every other Wexa tool: the
credential is resolved to a scope, the `fabric:ontology.write` grant is checked, quota is drawn down, the arguments are
validated, policy rules are evaluated, the call is executed, the result is shaped and redacted, and an audit
record is written. The `lifecycle_id` in the response is the handle to that record.

`create-ontology` is marked consequential, which means it changes something rather than only reading. Two things
follow. It is audited in full rather than lightly, and a policy rule may hold it for human approval — in which
case the call returns `202` and an `ApprovalRequired` error carrying the approval id, and the SDKs can wait for
the decision and resume rather than making you call again.

## See also

[The tool index](/docs/tools/overview) and [errors](/docs/tools/errors).
