# Store my customers' data

URL: /products/app/store-my-customers-data · Id: `guide:store-my-customers-data`

> Say "keep each customer's leases" and get typed records, a workspace per customer, full history, SQL queries and exports.

Every record is stored by kind and kept apart for the [Customer](/business/nouns/customer) it belongs to, with every change kept. Each kind is a [Collection](/business/nouns/collection) inside that customer’s private workspace, its [Tenant](/business/nouns/tenant).

Needs: [Customer](/business/nouns/customer)

**Before it runs**

- You leave the chat: Never: it all happens in the chat.

## What you get
- 1 table for each kind of record (Collection)
- 1 workspace per customer, holding its records apart (Tenant)
- 5 calls for each kind of record: create, get, list, update, delete (Verb)
- 1 history of every write, readable at any past moment (Event)
- 1 SQL queries over every record and its history (Collection)
- 1 list and record view in the App (Dashboard)
- 1 export to a file or a warehouse on a schedule (Collection)

## Your agent does
**For agents**

- Guide: `guide:store-my-customers-data`, status `beta`. Page: [/products/app/store-my-customers-data.md](/products/app/store-my-customers-data.md).
- Approval: none. Run it when the founder asks.
- Leaves the chat: never.
- Needs first: [Customer](/business/nouns/customer).
- Run: call the steps in order, each through the API, SDK, CLI or MCP tab below; a later step passes the `$id` an earlier one returns. Each value marked example is the sample business’s: pass the founder’s own.

| Step | Verb | Inputs (type, required, this guide’s value) | Returns |
| --- | --- | --- | --- |
| 1 | [`Collection.create`](/business/nouns/collection/create) (`verb:Collection.create`) | `id` string, required: example `"leases"`; `type` Noun[] (ids), required: example `["lease"]` | `collection` Collection |
| 2 | [`Tenant.provision`](/business/nouns/tenant/provision) (`verb:Tenant.provision`) | `customer` Customer (an id), required: example `"customer_harbor"` | `tenant` Tenant |

Returns: the last call answers with `tenant` and its `action`, whose `status` is `done`, `pending` (waiting on an Approval or a Worker), `failed`, `canceled` or `refused`:

```json
{
  "api": "https://api.sb/leaseline.app",
  "tenant": {
    "$id": "https://api.sb/leaseline.app/tenants/tenant_1",
    "$type": "Tenant"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/action_1",
    "operation": "Tenant.provision",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/action_1"
  }
}
```

Next: offer “Add a deposit amount to every Lease”, or “Export every Lease to a spreadsheet each Monday”.

Calls: `Collection.create` → `Tenant.provision`

Ask:

```text
Keep each customer's leases, units and tenants.
Store renewal dates per customer, kept apart from every other customer.
Store my customers' data.
```

API:

```bash
# 1. Collection.create
curl -X POST https://api.sb/leaseline.app/collections \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id":"leases","type":["lease"]}'

# 2. Tenant.provision
curl -X POST https://api.sb/leaseline.app/tenants/provision \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customer":"customer_harbor"}'
```

SDK:

```ts
import { $ } from 'startup-builder'

await $.Collection.create({ id: 'leases', type: ['lease'] })
await $.Tenant.provision({ customer: 'customer_harbor' })
```

CLI:

```bash
npx startup-builder do Collection.create --json '{"id":"leases","type":["lease"]}'
npx startup-builder do Tenant.provision --json '{"customer":"customer_harbor"}'
```

MCP:

```json
{
  "name": "do",
  "arguments": {
    "code": "await $.Collection.create({ id: 'leases', type: ['lease'] })\nreturn await $.Tenant.provision({ customer: 'customer_harbor' })"
  }
}
```

## Change it
- Add a deposit amount to every Lease.
- Export every Lease to a spreadsheet each Monday.
- Link each Lease to the Unit it covers.

## Under the hood
- Systems: [Data editor](/code/systems/data-editor), [Customer access](/systems/customer-access)
- Nouns: [Collection](/business/nouns/collection), [Tenant](/business/nouns/tenant), [Noun](/business/nouns/noun), [Thing](/business/nouns/thing)
- Events: `Collection.created`, [`Tenant.provisioned`](/business/events/Tenant.provisioned)