# Get agents

URL: https://docs.hanzo.ai/docs/openapi/principal/get-principal-agents-by-ref

> Attests which principal one of the caller's agents answers to: the org, the chain of agents that spawned it, and the same signed with the platform's key as a JWS (EdDSA) a verifier checks offline against GET /v1/principal/keys.

`GET /v1/principal/agents/{ref}`

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

|               |                                                  |
| ------------- | ------------------------------------------------ |
| **Address**   | `https://api.hanzo.ai/v1/principal/agents/{ref}` |
| **Method**    | `GET`                                            |
| **Operation** | `get_principal_agents_by_ref`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`           |

Attests which principal one of the caller's agents answers to: the org, the
chain of agents that spawned it, and the same signed with the platform's key as
a JWS (EdDSA) a verifier checks offline against GET /v1/principal/keys. Any
member of the agent's org.

An agent of another org is not found. A spawned agent answers to its parent's
org, which is its own: a parent is resolved only in the org the agent is created
in. The statement is valid for 24 hours.

## Request

1 field.

| Field | In   | Type   | Required | Description                                            |
| ----- | ---- | ------ | -------- | ------------------------------------------------------ |
| `ref` | path | string | yes      | Ref is the agent's id or its name in the caller's org. |

## Response

| Status    | Body                  | Meaning |
| --------- | --------------------- | ------- |
| `200`     | principal.Attestation | ok      |
| `default` | problem-details       | refused |

`200` body — 14 fields.

| Field              | In   | Type                    | Always | Description                                                                                                               |
| ------------------ | ---- | ----------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| `agent`            | body | principal.AgentBrief    | —      |                                                                                                                           |
| `agent.id`         | body | string                  | —      | ID is the agent id — the ref a run names and the value a member id derives from, so it must be stable across a reconcile. |
| `agent.name`       | body | string                  | —      | Name is the display name a person reads in a member list.                                                                 |
| `agent.parent`     | body | string                  | —      | Parent is the agent that spawned this one; empty for an agent a person defined.                                           |
| `agent.status`     | body | string                  | —      | Status is the registry status VERBATIM, never a boolean.                                                                  |
| `expires`          | body | integer (int64)         | —      | Expires is when the statement stops being valid, unix seconds.                                                            |
| `kid`              | body | string                  | —      | Kid is the key that signed it.                                                                                            |
| `org`              | body | string                  | —      | Org is the principal it answers to — the org it was defined in.                                                           |
| `parents`          | body | principal.AgentBrief\[] | —      | Parents are the agents that spawned it, nearest first.                                                                    |
| `parents[].id`     | body | string                  | —      | ID is the agent id — the ref a run names and the value a member id derives from, so it must be stable across a reconcile. |
| `parents[].name`   | body | string                  | —      | Name is the display name a person reads in a member list.                                                                 |
| `parents[].parent` | body | string                  | —      | Parent is the agent that spawned this one; empty for an agent a person defined.                                           |
| `parents[].status` | body | string                  | —      | Status is the registry status VERBATIM, never a boolean.                                                                  |
| `statement`        | body | string                  | —      | Statement is the same, signed: a JWS a verifier checks offline against GET /v1/principal/keys.                            |

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

## Examples

**CLI**

`hanzo` has no subcommand for this operation — the CLI serves only what cloud's live route table confirms. Use HTTP or an SDK.

**SDK**

**.ts**

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

const api = new PrincipalApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getPrincipalAgentsByRef({ ref: 'ref' });
```

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = PrincipalApi(client).get_principal_agents_by_ref(ref='ref')
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new PrincipalApi(client).getPrincipalAgentsByRef();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/principal/agents/<ref> \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **principal** through the `principal` tool, which names its 7 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_principals"
         }
       }
     }'
```

---

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