---
title: "Register and govern an AI agent"
sidebarTitle: "Govern an AI agent"
description: "Delegate an agent a bounded identity, declare its tools, authorize each invocation, approve irreversible actions, and contain or stop it."
keywords: ["AI agent", "workload", "delegation", "tool allowlist", "quarantine", "kill switch", "step-up", "approval", "twa_"]
---

An agent in TRUSTIVAN is a workload of kind `agent`: a non-human identity that
acts on a slice of **your** authority, with its own short-lived credential.
This page is the procedure. [AI agent security](/security/agents) explains
what each rule enforces and what is only observed.

<Note>
  This is the agent registry built into the TRUSTIVAN API, under
  **Agents** in the dashboard. NHI Security has a separate runtime gate for
  agents discovered across your estate; see
  [Runtime authorization gate](/nhi-security/runtime-gate).
</Note>

Who does what:

| Action | Needs |
|---|---|
| Delegate, rotate, quarantine, terminate, disable a tool, approve an action | A person holding `workloads:manage` (the `admin` role and above) |
| Read agents, capabilities, sessions, actions and signals | `workloads:read` |
| Open a session, ask for a decision, declare its own tools | The agent's own credential |

## 1. Delegate the agent

**Settings → Workloads → Delegate**, or:

```bash
curl -s -X POST https://app.trustivan.com/api/v1/workloads \
  -H 'Content-Type: application/json' \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
  -d '{
        "name": "triage-assistant",
        "kind": "agent",
        "scopes": ["findings:read", "findings:write"],
        "ttl_seconds": 3600
      }'
```

The response carries `workload` and `credential`. The credential starts
`twa_`, is shown once, and is stored only as a digest.

Three limits apply before anything is created:

- **You can delegate only what you hold.** Every scope must be one you
  currently have and one a machine may hold. Both are checked again on every
  request the agent makes, so demoting you narrows the agent on its next call.
- **Lifetimes are short.** One hour by default, twelve at most.
- **Counts are bounded.** An agent counts against your plan's non-human
  identity limit, and an organization holds at most 200 live workloads
  (`409` beyond that).

The agent now appears under **Agents**, with no tools.

## 2. Declare its tools

A tool is a named capability and, optionally, the one permission invoking it
requires. Declaring a tool grants nothing: it narrows what the delegation
already allows.

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/agents/$AGENT_ID/tools" \
  -H 'Content-Type: application/json' \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
  -d '{
        "name": "close_finding",
        "description": "Marks a finding resolved",
        "required_permission": "findings:write",
        "irreversible": false
      }'
```

| Field | Meaning |
|---|---|
| `name` | Required. Unique per agent; a duplicate is `409` |
| `required_permission` | What invoking the tool demands. An unknown permission is `400`. One no machine may hold is `403`. One the agent does not hold **yet** is accepted, and refused at invocation |
| `irreversible` | Marks an action that cannot be undone. Invoking it requires a person's approval first (step 5) |

An agent can declare at most 64 tools. A person with `workloads:manage` can
declare tools on any agent; an agent can declare its own and no other's.

To see what the agent can do **right now**, with one line of reasoning per
tool:

```bash
curl -s "https://app.trustivan.com/api/v1/agents/$AGENT_ID/capabilities" -b cookies.txt
```

This is computed on every read, never stored. It is also the **Capabilities**
card on the agent's page.

## 3. Open a session

The agent opens a session for each run of work, stating what the run is for.
From here on the agent calls the API with its own credential:

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/agents/$AGENT_ID/sessions" \
  -H "Authorization: Bearer $AGENT_CREDENTIAL" \
  -H 'Content-Type: application/json' \
  -d '{"purpose": "Triage findings from the nightly scan", "ttl_seconds": 1800}'
```

`purpose` is required. A session lasts at most four hours and never longer
than the credential behind it. The response carries `session`; keep its `id`.

## 4. Ask before every tool call

Before the agent runs a tool, it asks. The request is recorded whether it is
permitted or refused.

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/agents/$AGENT_ID/actions" \
  -H "Authorization: Bearer $AGENT_CREDENTIAL" \
  -H 'Content-Type: application/json' \
  -d '{
        "tool": "close_finding",
        "resource_type": "finding",
        "resource_id": "…",
        "session_id": "…"
      }'
```

The response is always `200`, with a `decision` and the `action` record
written for it. Act on `decision.result`:

| `result` | `obligation` | What the agent must do |
|---|---|---|
| `allow` | none | Proceed |
| `step_up` | `challenge` | Stop and obtain a person's approval (step 5), then ask again |
| `deny` | none | Do not proceed. Routine: a disabled tool, an ended session, a permission the delegation does not hold |
| `quarantine` | `halt` | Stop using the credential. The agent has been contained and a person must review it |
| `revoke` | `revoke` | The credential is finished |

`decision.rules` lists every rule that was evaluated, including those that did
not fire, and `decision.summary` is one sentence you can log.

<Warning>
  Two requests quarantine the agent automatically: naming a tool it never
  declared, and naming a session that belongs to another agent. An agent that
  asks only an HTTP status question will miss this, because the status is
  `200`. Read `result`.
</Warning>

An agent can only ask about itself. A request whose path names another agent
is `403`.

## Approve an irreversible action

A tool declared `irreversible` returns `step_up` until a person approves that
exact action. The agent cannot assert that someone is present.

<Steps>
  <Step title="A person issues an approval">
    ```bash
    curl -s -X POST "https://app.trustivan.com/api/v1/agents/$AGENT_ID/approvals" \
      -H 'Content-Type: application/json' \
      -b cookies.txt \
      -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
      -d '{
            "tool": "delete_asset",
            "resource_type": "asset",
            "resource_id": "…",
            "code": "123456"
          }'
    ```

    `code` is a current TOTP code, and is required when the approver has a
    second factor (`401` with `mfa_required: true` without one). The response
    carries a `token`, returned once.
  </Step>
  <Step title="The agent presents it">
    The agent repeats the request from step 4 with `"approval_token": "…"`.
  </Step>
</Steps>

An approval covers one agent, one tool and one resource. It is single-use and
expires after five minutes. A token that does not fit (another tool, another
resource, expired, already spent) is not an error: the action is judged as
having no person behind it and answers `step_up` again.

## Contain or stop an agent

Choose the narrowest control that solves the problem.

| Control | Request | Effect |
|---|---|---|
| Disable one tool | `DELETE /api/v1/agents/{id}/tools/{name}` | That tool is refused whatever the delegation says. The agent keeps working |
| End one session | `DELETE /api/v1/agents/{id}/sessions/{sessionId}` | That run stops. The credential still works. The agent can end its own session too |
| Quarantine | `POST /api/v1/agents/{id}/quarantine` | The whole credential stops on the agent's next request. Reversible: the credential survives |
| Release | `DELETE /api/v1/agents/{id}/quarantine` | Lifts a quarantine. `404` if the agent is not quarantined |
| Terminate | `DELETE /api/v1/agents/{id}` | Permanent. Revokes the credential and closes every open session. The response reports `sessions_ended` |

Each accepts a `reason` query parameter of up to 200 characters, and each is
idempotent: the **first** reason recorded is the one kept.

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/agents/$AGENT_ID/quarantine?reason=unexpected+volume" \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')"
```

A quarantine never expires on its own. Only a person releases it.

Anyone holding `workloads:manage` can use these, not only the person who
delegated the agent. During an incident, the person who can stop an agent is
whoever is awake.

## Rotate the credential

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/workloads/$AGENT_ID/rotate" \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')"
```

Rotation replaces the secret and nothing else: the agent keeps its id, scopes,
tools, sessions and history. The previous secret keeps working for five
minutes so requests in flight can finish. A revoked or expired agent cannot be
rotated; delegate a new one.

## Review what it did

| Question | Request | In the dashboard |
|---|---|---|
| What did it do, and was each action permitted? | `GET /api/v1/agents/{id}/actions` (up to 500 per request, newest first) | **Actions**, with a **Refusals only** filter |
| What runs has it made? | `GET /api/v1/agents/{id}/sessions` | **Sessions** |
| Is anything unusual? | `GET /api/v1/agents/{id}/signals` | **Behavioral signals** |

The action trail is append-only and names both actors on every row: the agent
that acted and the person whose delegation made it possible.

Signals are observations, not enforcement. See
[what is observed](/security/agents#observed-not-enforced-behavioural-signals).

## See also

- [AI agent security](/security/agents)
- [Scopes](/api-reference/scopes): what a machine may and may not be granted.
- [Billing and plans](/concepts/billing-and-plans): the non-human identity
  limit.
