# Approvals: a person in the loop for any agent

Source: https://docs.autessa.com/docs/features/approvals

> Pause an AI agent until a person approves or denies, with a timeout, from any agent framework, using Autessa's built-in approval tools.

# Approvals

Before your agent does something risky, ask a person. The agent sends a request, a person approves or denies it in Autessa, and the agent continues with the answer.

## When to use it

- Refunds, payments, or account changes above a limit.
- Sending data or email to someone new.
- Any action you want a named person to sign off on.

## Quickstart

1. [Get a free API key](https://builder.autessa.com/get-api-key). New accounts get $100 of free credits for your first month, no card needed. This developer key works for this feature; see [Keys](/docs/start/keys.md).
2. Call `request_approval` with a title, details, and a timeout. You get an `approvalId`.
3. Call `get_approval` until `decision` is no longer `PENDING`.

**curl:**

```bash
curl -X POST https://api.autessa.com/clients/agent-tools/request_approval/invoke \
  -H "Authorization: $AUTESSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"input": {"title": "Refund $480 to order 1042", "details": "Customer reports the item arrived damaged.", "timeoutSec": 900}}'

curl -X POST https://api.autessa.com/clients/agent-tools/get_approval/invoke \
  -H "Authorization: $AUTESSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"input": {"approvalId": "apr_8f2c"}}'
```

**Python:**

```python
import os
import time
import requests

API = "https://api.autessa.com/clients/agent-tools"
H = {"Authorization": os.environ["AUTESSA_API_KEY"]}

def tool(name, **input):
    r = requests.post(f"{API}/{name}/invoke", headers=H, json={"input": input}, timeout=30)
    r.raise_for_status()
    return r.json()["output"]

approval_id = tool("request_approval", title="Refund $480 to order 1042",
                   details="Item arrived damaged.", timeoutSec=900)["approvalId"]
while (d := tool("get_approval", approvalId=approval_id))["decision"] == "PENDING":
    time.sleep(5)
print(d["decision"], d.get("by"))
```

**TypeScript:**

```typescript
const API = "https://api.autessa.com/clients/agent-tools";
const tool = async (name: string, input: object) => {
  const r = await fetch(`${API}/${name}/invoke`, {
    method: "POST",
    headers: { Authorization: process.env.AUTESSA_API_KEY!, "Content-Type": "application/json" },
    body: JSON.stringify({ input }),
  });
  return (await r.json()).output;
};

const { approvalId } = await tool("request_approval", {
  title: "Refund $480 to order 1042",
  timeoutSec: 900,
});
let d = await tool("get_approval", { approvalId });
while (d.decision === "PENDING") {
  await new Promise((r) => setTimeout(r, 5000));
  d = await tool("get_approval", { approvalId });
}
console.log(d.decision);
```

**Java:**

```java
var http = java.net.http.HttpClient.newHttpClient();
java.util.function.Function<String, java.net.http.HttpRequest.Builder> tool = name ->
    java.net.http.HttpRequest.newBuilder(java.net.URI.create(
            "https://api.autessa.com/clients/agent-tools/" + name + "/invoke"))
        .header("Authorization", System.getenv("AUTESSA_API_KEY"))
        .header("Content-Type", "application/json");

var req = tool.apply("request_approval").POST(java.net.http.HttpRequest.BodyPublishers.ofString("""
    {"input": {"title": "Refund $480 to order 1042", "timeoutSec": 900}}
    """)).build();
System.out.println(http.send(req, java.net.http.HttpResponse.BodyHandlers.ofString()).body());
```

## How it works

- `request_approval` takes `title` and `timeoutSec`, plus optional `details` and `approvers` (member emails or group names; leave it out to use your company's approvers). It returns `approvalId`.
- `get_approval` returns `decision`: `PENDING`, `APPROVED`, `DENIED`, or `EXPIRED`, plus `by` and `at` once someone decides.
- If nobody decides before the timeout, the decision is `EXPIRED`. Treat it as a no.
- The [AI Application Firewall](/docs/features/ai-application-firewall.md) can also return `REQUIRE_APPROVAL` on its own. Use these tools to carry it out.

## Libraries

| Language | Package | Call |
| --- | --- | --- |
| Python | `autessa-approvals` | `Approvals().request(title, details=None, approvers=None, timeout_sec=3600)`, `get(approval_id)`, `wait(approval_id)` |
| TypeScript | `@autessa/approvals` | `new Approvals().request({ title, details?, approvers?, timeoutSec })`, `get(approvalId)`, `wait(approvalId)`, `requestAndWait(req)` |
| Java | `com.autessa:autessa-approvals` | `Approvals.fromEnv().request(title, details, approvers, timeoutSec)`, `get(approvalId)`, `await(approvalId)`, `requestAndWait(...)` |

```python
from autessa.approvals import Approvals

approvals = Approvals()  # reads AUTESSA_API_KEY
ask = approvals.request("Refund $480 to order 1042", details="Item arrived damaged.", timeout_sec=900)
decision = approvals.wait(ask.approval_id)
print(decision.decision, decision.by)
```

`wait` returns once the decision is `APPROVED`, `DENIED`, or `EXPIRED`. Treat anything but `APPROVED` as a no.

The libraries are in private preview and not yet on PyPI, npm, or Maven Central. Install from GitHub as each library's README describes, for example:

```bash
pip install "autessa-core @ git+https://github.com/Autessa-Inc/autessa-python#subdirectory=packages/autessa-core"
pip install "autessa-approvals @ git+https://github.com/Autessa-Inc/autessa-python#subdirectory=packages/autessa-approvals"
```

## Limits

- Poll no faster than every few seconds. The libraries' `wait` does this for you.
- Per-key rate limits apply. See [API keys and scopes](/docs/start/api-keys.md).

## API reference

[Agent Tools API](/docs/reference/agent-tools.md)

## Benchmarks

None for approvals. See [Benchmarks](/docs/benchmarks.md).

## Example

- [LangGraph support agent](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/langgraph-support-agent): a person approves each refund before the refund tool runs.
- [Spring AI bank assistant](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/spring-ai-bank-assistant): the approval tools as Spring AI tools.

## Related

- [Agent tools and MCP](/docs/features/agent-tools-mcp.md)
- [AI Application Firewall](/docs/features/ai-application-firewall.md)
- [LangChain integration](/docs/integrations/langchain.md)

