Adding Fact Triplets
Manually specify fact/node triplets to add structured relationships to your graph
Overview
You can add manually specified fact/node triplets to the graph. You need only specify the fact, the target node name, and the source node name. Zep will then create a new corresponding edge and nodes, or use an existing edge/nodes if they exist and seem to represent the same nodes or edge you send as input. And if this new fact invalidates an existing fact, it will mark the existing fact as invalid and add the new fact triplet.
The add_fact_triple method returns a task_id that can be used to track the processing status of the operation. See the Check Data Ingestion Status recipe for how to poll task status.
Adding a Fact Triplet
Retrieving Created UUIDs
Because fact triple creation is asynchronous, the UUIDs for the edge and nodes are not returned immediately. After the task completes, you can retrieve them by calling client.task.get() with the task_id returned from add_fact_triple. The task’s params field will contain edge_uuid, source_node_uuid, and target_node_uuid.
Advanced Options
Custom types and attributes
You can attach custom scalar attributes to nodes and edges, and optionally reference custom entity and edge types from your ontology to enforce a schema.
source_node_labels/target_node_labels— specify a single entity type name from your ontology.fact_name— serves as both the relationship display name and the edge type name looked up in your ontology.source_node_attributes/target_node_attributes/edge_attributes— custom scalar properties on those nodes and edges, usable for filtering in graph searches.
Attribute validation — specifying types is optional. If a label or fact_name is not found in your ontology, attributes pass through without validation:
When validation activates, every attribute key and value type must match the schema — otherwise the call returns HTTP 400.
Attribute values must be scalar types: string, number, boolean, or null. Nested objects and arrays are not supported.
Specifying Node UUIDs
You can optionally specify source_node_uuid and/or target_node_uuid to control which nodes are used. The behavior depends on whether you provide a UUID:
See the associated SDK reference for complete details on all available parameters.