# Serve several customers

Each customer account has its own approvals, and can tighten your rules.

**Python only today.**

| | |
|---|---|
| Level | 1: A person approves with a passkey. |
| Class | `write`: Something changes and can be undone. The approval can be reused. |

## What the test proves

- the person approves for one customer's account: 201
- that approval does not work on another customer's account
- a customer's own ceiling (50 EUR) holds whatever the person approved

## Python

```python
routes.append(route("POST", "/t/{tenant}/orders", "orders:place", cls="write", level=1,
                    resource="tenant:{tenant}:order:new", amount_field="/total", summary="Order for a customer account",
                    body={"total": "a decimal string, e.g. 60.00", "currency": "e.g. EUR"}))
templates["orders:place"] = "Order for up to {amount.max} {amount.currency} on {scope}"
tenants["umbrella"] = {"name": "Umbrella", "routes": {}}
tenants["hooli"] = {"name": "Hooli", "routes": {"orders:place": {"amount_max": "50.00"}}}  # can only tighten your rules


@app.post("/t/<tenant>/orders")
def place_order(tenant):
    # An approval for one customer's account never works on another's.
    if tenant not in tenants:
        return {"error": "no such customer"}, 404
    return {"ordered": request.json["total"], "account": g.allowedby.tenant}, 201
```
