Browse the documentation

Get started

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.

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.

export LAYERZ_KEY=lz_...

2. Create a model

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

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

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