Create graph

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

POST /v1/graph

Addresshttps://api.hanzo.ai/v1/graph
MethodPOST
OperationgraphAssert
AuthAuthorization: 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).

FieldInTypeRequiredDescription
assertionsbodygraph.graphFact[]yesAssertions is the batch.
assertions[].atbodystringyesAt is when the thing was so, RFC 3339.
assertions[].confidencebodynumber (double)—Confidence in [0,1].
assertions[].entitybodystringyesEntity is the thing being described, in the organization's own namespace.
assertions[].evidencebodystring—Evidence points at the record this claim came from, 512 bytes at most.
assertions[].namesbodyboolean—Names says the value is an entity.
assertions[].relationbodystringyesRelation is what is being asserted — depends, owner, same, title — and a key, folded as Entity is.
assertions[].seenbodystring—Seen is when this assertion became knowable, RFC 3339.
assertions[].sourcebodystringyesSource names who asserted.
assertions[].untilbodystring—Until is when the thing stopped being so, RFC 3339, and must follow At.
assertions[].valuebodystring—Value is what the relation points at.

Response

StatusBodyMeaning
200graph.graphAssertOutok
defaultproblem-detailsrefused

200 body — 4 fields.

FieldInTypeAlwaysDescription
duplicatebodyinteger (int64)—Duplicate is how many members this plane already held.
reasonsbodystring[]—Reasons names why each refused member was refused, in the order sent.
recordedbodyinteger (int64)—Recorded is how many members became new rows.
refusedbodyinteger (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.

Examples

hanzo graph create
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>"}] });
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>"}])
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
}
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?;
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();
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>"
         }
       ]
     }'

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

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 · All Hanzo APIs · Interactive reference

Was this page useful?