# Quickstart with the REST API

> Create an API key, create a model, add an assumption and a formula, and read the computed values with three HTTP calls.

The REST API is served under `https://layerz.cc/api/v1`. Every request carries a Bearer token: an API key (`lz_` followed by 40 hex characters) or an OAuth access token. See [Authentication](/docs/api/authentication).

## 1. Create a key

In the app, open the account menu, then **API**: name the key, pick its scope (all models or one model) and its permissions (full or read-only), then copy it. It is shown once.

```bash
export LAYERZ_KEY=lz_...
```

## 2. Create a model

```bash
curl -s https://layerz.cc/api/v1/models \
  -H "Authorization: Bearer $LAYERZ_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Plan 2027", "timelines": { "monthly": { "start": "2027-01-01", "end": "2029-12-31" } } }'
```

The response carries the model `id`. A new model is empty: no section is added for you.

## 3. Add lines

```bash
curl -s https://layerz.cc/api/v1/models/$MODEL_ID/items/batch \
  -H "Authorization: Bearer $LAYERZ_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "items": [
    { "temp_id": "pl", "role": "section", "display_name": "P&L" },
    { "role": "assumption", "display_name": "Customers", "parent_layer_uid": "pl", "value": 40 },
    { "role": "assumption", "display_name": "Price", "parent_layer_uid": "pl", "value": 900 },
    { "role": "formula", "display_name": "Revenue", "parent_layer_uid": "pl", "formula": "Customers * Price" }
  ] }'
```

`temp_id` lets a line of the batch point at another one created in the same call. Formulas reference lines by name.

## 4. Read the numbers

```bash
curl -s "https://layerz.cc/api/v1/models/$MODEL_ID/compute" -H "Authorization: Bearer $LAYERZ_KEY"
```

`values` maps each line's id to its series, `periods` lists the period labels of each timeline.

## Next

- [Models](/docs/api/models), [Items](/docs/api/items): the endpoints used above, in full.
- [Compute and snapshot](/docs/api/compute-and-snapshot): read values, download or upload the whole model.
- [Limits and errors](/docs/api/limits-and-errors): quotas, rate limits, status codes.
- For whole statements at once, post a blueprint: [`POST /models/:id/blueprint`](/docs/api/models#blueprint).
