# Create graph

URL: https://docs.hanzo.ai/docs/openapi/graph/graphassert

> Records a batch of assertions and counts what became of each.

`POST /v1/graph`

> [Graph →](https://docs.hanzo.ai/docs/openapi/graph) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/graph`        |
| **Method**    | `POST`                                 |
| **Operation** | `graphAssert`                          |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Records a batch of assertions and counts what became of each.

Each member is judged alone: one refusal does not discard the rest, and a
member this plane already holds is a duplicate, not a refusal. A batch with
nothing admitted answers 400.

Time: at and until are when the statement was so, which an as\_of read is
bounded by; the server stamps knowable, the later of seen and its own clock,
which an as\_known read is bounded by. Nothing is overwritten: a correction is
the statement filed again, and the version known latest speaks for it.

## Request

11 fields, body `application/json` (required).

| Field                     | In   | Type               | Required | Description                                                                                                |
| ------------------------- | ---- | ------------------ | -------- | ---------------------------------------------------------------------------------------------------------- |
| `assertions`              | body | graph.graphFact\[] | yes      | Assertions is the batch.                                                                                   |
| `assertions[].at`         | body | string             | yes      | At is when the thing was so, RFC 3339.                                                                     |
| `assertions[].confidence` | body | number (double)    | —        | Confidence in \[0,1].                                                                                      |
| `assertions[].entity`     | body | string             | yes      | Entity is the thing being described, in the organization's own namespace.                                  |
| `assertions[].evidence`   | body | string             | —        | Evidence points at the record this claim came from, 512 bytes at most.                                     |
| `assertions[].names`      | body | boolean            | —        | Names says the value is an entity.                                                                         |
| `assertions[].relation`   | body | string             | yes      | Relation is what is being asserted — `depends`, `owner`, `same`, `title` — and a key, folded as Entity is. |
| `assertions[].seen`       | body | string             | —        | Seen is when this assertion became knowable, RFC 3339.                                                     |
| `assertions[].source`     | body | string             | yes      | Source names who asserted.                                                                                 |
| `assertions[].until`      | body | string             | —        | Until is when the thing stopped being so, RFC 3339, and must follow At.                                    |
| `assertions[].value`      | body | string             | —        | Value is what the relation points at.                                                                      |

## Response

| Status    | Body                 | Meaning |
| --------- | -------------------- | ------- |
| `200`     | graph.graphAssertOut | ok      |
| `default` | problem-details      | refused |

`200` body — 4 fields.

| Field       | In   | Type            | Always | Description                                                                                                                                                                                                                                                                        |
| ----------- | ---- | --------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `duplicate` | body | integer (int64) | —      | Duplicate is how many members this plane already held.                                                                                                                                                                                                                             |
| `reasons`   | body | string\[]       | —      | Reasons names why each refused member was refused, in the order sent.                                                                                                                                                                                                              |
| `recorded`  | body | integer (int64) | —      | Recorded is how many members became new rows.                                                                                                                                                                                                                                      |
| `refused`   | body | integer (int64) | —      | Refused is how many members were turned away — a missing entity, a timestamp that is not RFC 3339, a confidence outside \[0,1], a relation whose declared domain or range the entity's type does not meet, or a declaration from a caller who is not an admin of the organization. |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo graph create
```

**SDK**

**.ts**

```ts
import { Configuration, GraphApi } from 'hanzoai';

const api = new GraphApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.graphAssert({ assertions: [{"entity":"<entity>","relation":"<relation>","at":"<at>","source":"<source>"}] });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import GraphApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = GraphApi(client).graph_assert(assertions=[{"entity":"<entity>","relation":"<relation>","at":"<at>","source":"<source>"}])
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.GraphAPI.GraphAssert(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, graph_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = graph_api::graph_assert(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.GraphApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new GraphApi(client).graphAssert();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/graph \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "assertions": [
         {
           "entity": "<entity>",
           "relation": "<relation>",
           "at": "<at>",
           "source": "<source>"
         }
       ]
     }'
```

**MCP**

Tool `graph`, op `graphAssert` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "graph",
         "arguments": {
           "op": "graphAssert",
           "input": {
             "assertions": [
               {
                 "entity": "<entity>",
                 "relation": "<relation>",
                 "at": "<at>",
                 "source": "<source>"
               }
             ]
           }
         }
       }
     }'
```

---

[Graph API](https://docs.hanzo.ai/docs/openapi/graph) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
