# Anatomy of one approved request

You can start this with a terminal and the hosted demo. Ask the shop to check out, with no credentials:

```http
POST /checkout HTTP/1.1
Host: shop.demo.allowedby.com

HTTP/1.1 401 Unauthorized
WWW-Authenticate: AllowedBy realm="shop.demo.allowedby.com", error="passport_required"
```

The first refusal is about the agent. The shop wants to know who is calling before it bothers a person.

## The second refusal

The agent returns with its passport: a short-lived document from its node that names the agent's key. Now the service knows the agent, and that nobody has approved this. Here is the example from the specification:

```http
HTTP/1.1 401 Unauthorized
WWW-Authenticate: AllowedBy realm="api.example.com", error="grant_required",
    action="invoices:approve", scope="invoice:4711", class="write-hard",
    level="2", code="K7QM",
    approve="https://askmyhuman.org/a/8ZK3V4Q9T2M6R1XJ5WB0YHCDNE"
```

The agent gives the person the link and the code. That is all the agent contributes to the conversation.

## The tap

The page belongs to the person's own node. It fetches the sentence templates from the service, renders the sentence and shows the code. The person compares the code with their chat and taps a passkey. The passkey signs a hash of the grant, and the grant contains the sentence.

## The retry

```http
POST /invoices/4711/approve HTTP/1.1
Allowed-By: eyJ0eXAiOiJhYnktZ3JhbnQrand0Ii…
AllowedBy-Proof: …
```

`Allowed-By` carries the grant. `AllowedBy-Proof` is signed by the agent's key over this method, this URL and this body, and is accepted for at most about three minutes.

## The check

The service verifies the node's signature, the person's passkey signature and the agent's proof. It checks level, scope, amount, time and replay. Every key it needs is already on the machine; revocation lists refresh in the background. The architecture's budget is about 0.1 milliseconds for a grant seen before, and under one millisecond for a new one.

There is no call to us in that path. If our servers went dark, a service would keep verifying the grants agents already hold while its revocation lists are fresh. When they grow too old, it refuses rather than guesses: past 60 seconds for serious actions, past an hour for the rest.

Source: https://allowedby.com/blog/anatomy-of-a-request
