# Make your app ready for agents

Agents can already reach your app, by scraping it or by borrowing a customer's login. Accepting them on your terms takes four steps. The example uses Python; SDKs also exist for JavaScript, Go, Java, C#, PHP, Ruby and Rust.

## 1. List what an agent may call

One line per route. Say what it does and how serious it is.

```python
routes = [
    route("GET", "/plans", level=0, summary="Plans and prices"),
    route("GET", "/account", "account:read", level=1),
    route("POST", "/plans/{plan}/subscribe", "billing:subscribe", cls="write-hard",
          level=1, resource="plan:{plan}", amount_field="/monthly_total"),
]
```

Routes you do not list keep your own authentication. Read [Choosing a level](https://allowedby.com/blog/choosing-a-level.md) before this step.

## 2. Write the sentences

```python
templates = {
    "account:read": "See your account and usage",
    "billing:subscribe": "Subscribe to {scope} for {amount.max} {amount.currency} per month",
}
```

Only enforced values can fill the blanks. If a sentence is hard to write, the action is probably two actions.

## 3. Wrap the app

```python
aby = AllowedBy(origin="https://beacon.example", node="https://node.example.org",
                org={"legal_name": "Beacon Labs SAS", "country": "FR"},
                routes=routes, templates=templates)
app = aby.wsgi(app)
```

The wrapper answers the `401`, checks every listed route before your code runs, and publishes your rules at `/.well-known/allowedby` and as OpenAPI 3.1. An agent given only your address can find its way.

## 4. Use what it verified

Your handler receives a context: the agent, its operator, the level, and an identifier for the person that is stable in your app and different elsewhere. Store it as you would a user id.

## Before production

If you run more than one instance, share the replay store, for example with Redis. Serve over https. Choose which nodes you trust. The packages are not on public registries yet and the specifications are a draft, so today this is for a pilot. [Talk to us](https://upto.tech) if you want one.

Source: https://allowedby.com/blog/make-your-app-agent-ready
