# Create path

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

> Finds the shortest chain of in-force edges from one entity to another.

`POST /v1/graph/path`

> [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/path`   |
| **Method**    | `POST`                                 |
| **Operation** | `graphPath`                            |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Finds the shortest chain of in-force edges from one entity to another.

It is the walk behind neighbors stopped at a goal: the same bound and the same
rule for which edge is in force. A causal chain is this op with relations
naming the relations that mean cause, such as caused\_by and influenced.

Time: as\_of and as\_known place the graph the path is found in; either absent
is now.

## Request

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

| Field       | In   | Type      | Required | Description                                                                                                                                      |
| ----------- | ---- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `as_known`  | body | string    | —        | AsKnown is how much this plane had heard, RFC 3339: the answer as it would have been given then, which is what makes a past answer reproducible. |
| `as_of`     | body | string    | —        | AsOf finds the path through the graph as it stood at an instant of the world, RFC 3339: an edge that did not hold then is not crossed.           |
| `direction` | body | string    | —        | Direction is out, in or both.                                                                                                                    |
| `from`      | body | string    | yes      | From is the entity the path starts at.                                                                                                           |
| `relations` | body | string\[] | —        | Relations is the edge relations a path may cross.                                                                                                |
| `to`        | body | string    | yes      | To is the entity the path ends at.                                                                                                               |

## Response

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

`200` body — 35 fields.

| Field                | In   | Type              | Always | Description                                                                                                                                       |
| -------------------- | ---- | ----------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `as_known`           | body | string            | —      | AsKnown is the knowledge instant it was taken at, RFC 3339, the same way.                                                                         |
| `as_of`              | body | string            | —      | AsOf is the instant the path was taken at, RFC 3339: the one asked for, or the server's clock when none was.                                      |
| `bound`              | body | integer (int64)   | —      | Bound is the ceiling the search was held to, the same one a walk is.                                                                              |
| `decay`              | body | number (double)   | —      | Decay is the product of the edges' confidences: how much certainty survives the whole chain.                                                      |
| `edges`              | body | graph.wireFact\[] | —      | Edges is the path from From to To, one assertion per hop, each with its source, evidence and filer.                                               |
| `edges[].at`         | body | string            | —      | At is when the thing was so, RFC 3339, as the asserter gave it.                                                                                   |
| `edges[].by`         | body | string            | —      | By is the identity that filed it — `owner` or `owner/user` — stamped from the validated principal at the write, never from the body.              |
| `edges[].confidence` | body | number (double)   | —      | Confidence in \[0,1] as the asserter gave it; absent is 0.                                                                                        |
| `edges[].entity`     | body | string            | —      | Entity is the thing described, in the organization's own namespace.                                                                               |
| `edges[].evidence`   | body | string            | —      | Evidence points at the record the claim came from.                                                                                                |
| `edges[].id`         | body | string            | —      | ID is the assertion's content address, minted by the server from what was asserted.                                                               |
| `edges[].knowable`   | body | string            | —      | Knowable is the first instant this plane could have answered with the assertion, RFC 3339: the later of Seen and the server's clock at the write. |
| `edges[].names`      | body | boolean           | —      | Names true means the assertion is an edge and Value is an entity.                                                                                 |
| `edges[].relation`   | body | string            | —      | Relation is what was asserted of it.                                                                                                              |
| `edges[].seen`       | body | string            | —      | Seen is when the asserter says it became knowable, RFC 3339.                                                                                      |
| `edges[].source`     | body | string            | —      | Source names who asserted, as the caller gave it.                                                                                                 |
| `edges[].until`      | body | string            | —      | Until is when the thing stopped being so, RFC 3339, as the asserter gave it.                                                                      |
| `edges[].value`      | body | string            | —      | Value is what the relation points at: another entity's key when Names is true, otherwise a scalar.                                                |
| `found`              | body | boolean           | —      | Found is false when no path of in-force edges joins the two within the bound.                                                                     |
| `hops`               | body | integer (int64)   | —      | Hops is how many edges the path crosses: zero when From is To, and zero when nothing was found.                                                   |
| `truncated`          | body | boolean           | —      | Truncated says the bound stopped the search before a path was found, so Found false means none within the bound rather than none at all.          |
| `weakest`            | body | graph.wireFact    | —      |                                                                                                                                                   |
| `weakest.at`         | body | string            | —      | At is when the thing was so, RFC 3339, as the asserter gave it.                                                                                   |
| `weakest.by`         | body | string            | —      | By is the identity that filed it — `owner` or `owner/user` — stamped from the validated principal at the write, never from the body.              |
| `weakest.confidence` | body | number (double)   | —      | Confidence in \[0,1] as the asserter gave it; absent is 0.                                                                                        |
| `weakest.entity`     | body | string            | —      | Entity is the thing described, in the organization's own namespace.                                                                               |
| `weakest.evidence`   | body | string            | —      | Evidence points at the record the claim came from.                                                                                                |
| `weakest.id`         | body | string            | —      | ID is the assertion's content address, minted by the server from what was asserted.                                                               |
| `weakest.knowable`   | body | string            | —      | Knowable is the first instant this plane could have answered with the assertion, RFC 3339: the later of Seen and the server's clock at the write. |
| `weakest.names`      | body | boolean           | —      | Names true means the assertion is an edge and Value is an entity.                                                                                 |
| `weakest.relation`   | body | string            | —      | Relation is what was asserted of it.                                                                                                              |
| `weakest.seen`       | body | string            | —      | Seen is when the asserter says it became knowable, RFC 3339.                                                                                      |
| `weakest.source`     | body | string            | —      | Source names who asserted, as the caller gave it.                                                                                                 |
| `weakest.until`      | body | string            | —      | Until is when the thing stopped being so, RFC 3339, as the asserter gave it.                                                                      |
| `weakest.value`      | body | string            | —      | Value is what the relation points at: another entity's key when Names is true, otherwise a scalar.                                                |

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

## Examples

**CLI**

```bash
hanzo graph path
```

**SDK**

**.ts**

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

const api = new GraphApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.graphPath({ from: "<from>", to: "<to>" });
```

**.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_path(from="<from>", to="<to>")
```

**.go**

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

resp, _, err := client.GraphAPI.GraphPath(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_path(&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).graphPath();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/graph/path \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "from": "<from>",
       "to": "<to>"
     }'
```

**MCP**

Tool `graph`, op `graphPath` — 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": "graphPath",
           "input": {
             "from": "<from>",
             "to": "<to>"
           }
         }
       }
     }'
```

---

[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)
