{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Leaseline records",
  "$defs": {
    "Agent": {
      "type": "object",
      "description": "An Agent is a digital worker with instructions, tools, and a model that performs Verbs for a Startup.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Agent"
        },
        "instructions": {
          "type": "string",
          "description": "What the Agent does and how."
        },
        "model": {
          "type": "string",
          "description": "The model the Agent runs on."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "The tools the Agent may call."
          },
          "description": "The tools the Agent may call."
        },
        "skills": {
          "type": "array",
          "items": {
            "description": "The Skills it loads."
          },
          "description": "The Skills it loads."
        },
        "memory": {
          "type": "string",
          "description": "One of `tenant` (one Memory per Customer Tenant) or `startup` (one Memory for the Startup).",
          "enum": [
            "tenant",
            "startup"
          ]
        },
        "maxSteps": {
          "type": "integer",
          "description": "The most steps one Task may take."
        },
        "budget": {
          "$ref": "#/components/schemas/Money",
          "description": "The most one Task may spend; the Mandate’s Limits apply as well."
        },
        "handoffs": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "The Roles it hands work to. The Role id."
          },
          "description": "The Roles it hands work to."
        },
        "status": {
          "type": "string",
          "description": "One of `standby`, `seated`, `paused` or `retired`: whether it fills a Role and is working.",
          "enum": [
            "standby",
            "seated",
            "paused",
            "retired"
          ]
        }
      },
      "required": [
        "$id",
        "$type",
        "instructions",
        "model",
        "status"
      ]
    },
    "Change": {
      "type": "object",
      "description": "A Change is a proposed set of writes to Things, drafted against a base Version on its own branch, then checked, approved and merged.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Change"
        },
        "status": {
          "type": "string",
          "description": "One of `Open`, `Reviewing`, `Merged`, or `Closed`.",
          "enum": [
            "Open",
            "Reviewing",
            "Merged",
            "Closed"
          ]
        },
        "base": {
          "type": "string",
          "description": "The Version it was drafted against. The Version id."
        },
        "tier": {
          "type": "integer",
          "description": "Launch tier from the merged diff: 3 fixes, 2 adds a Verb or Entitlement, 1 adds a Product or Offer."
        }
      },
      "required": [
        "$id",
        "$type",
        "status",
        "base"
      ]
    },
    "Contact": {
      "type": "object",
      "description": "A Contact is a person or Agent a Startup knows by at least one address, where Consent to message them is recorded.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Contact"
        },
        "email": {
          "type": "string",
          "format": "email",
          "description": "The primary email address."
        },
        "phone": {
          "type": "string",
          "description": "The primary phone number."
        },
        "name": {
          "type": "string",
          "description": "The name the Contact goes by."
        }
      },
      "required": [
        "$id",
        "$type"
      ]
    },
    "Customer": {
      "type": "object",
      "description": "A Customer is a party that has accepted an Offer from a Startup at any price, including zero.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Customer"
        },
        "since": {
          "type": "string",
          "format": "date-time",
          "description": "When the party first accepted an Offer."
        },
        "outside": {
          "type": "boolean",
          "description": "Computed: true when it shares no owner, account, or sibling chain with the Startup."
        },
        "status": {
          "type": "string",
          "description": "One of `trialing`, `activated`, `atRisk`, `churned`, or `wonBack`, computed from Events and never set by hand; `atRisk` reads customer health.",
          "enum": [
            "trialing",
            "activated",
            "atRisk",
            "churned",
            "wonBack"
          ]
        },
        "billingEmail": {
          "type": "string",
          "format": "email",
          "description": "Where Invoices and receipts go, when it differs from the sign-in email."
        },
        "billingAddress": {
          "type": "string",
          "description": "The address printed on new Invoices; Stripe Tax reads it to compute tax."
        },
        "taxIds": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "The Customer’s tax ids, such as a VAT number, printed on new Invoices and read by Stripe Tax."
          },
          "description": "The Customer’s tax ids, such as a VAT number, printed on new Invoices and read by Stripe Tax."
        },
        "creditRecharge": {
          "description": "When unspent credit falls below `below`, buy `amount` of the credit Offer with the default Payment Source."
        }
      },
      "required": [
        "$id",
        "$type",
        "since"
      ]
    },
    "Domain": {
      "type": "object",
      "description": "A Domain is a hostname that points at a Thing, with a role, a status, and a lifecycle tracked as data.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Domain"
        },
        "hostname": {
          "type": "string",
          "description": "The name, such as `leaseline.app`."
        },
        "role": {
          "type": "string",
          "description": "What the Domain does for the Thing it serves; a defensive name takes `redirect`.",
          "enum": [
            "canonical",
            "alias",
            "redirect",
            "preview",
            "tenant",
            "signIn",
            "outreach"
          ]
        },
        "acquired": {
          "type": "string",
          "description": "One of `claimed`, `purchased`, or `connected`.",
          "enum": [
            "claimed",
            "purchased",
            "connected"
          ]
        },
        "state": {
          "type": "string",
          "description": "Where the Domain stands; `verifying`, `live`, `degraded`, `expiring` and `lapsed` are observed, the rest follow an Action.",
          "enum": [
            "candidate",
            "held",
            "claimed",
            "registered",
            "connected",
            "verifying",
            "live",
            "degraded",
            "expiring",
            "lapsed",
            "renewed",
            "transferred",
            "released"
          ]
        },
        "registrant": {
          "type": "string",
          "description": "The owner of record: the holding Company while held, or the holder of a self-serve Startup’s Stripe account. The Party id."
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time",
          "description": "When the registration ends, as the registrar reports it; empty for a claimed Domain."
        },
        "autoRenew": {
          "type": "boolean",
          "description": "True when renewal runs without a Decision; false sends the Domain through renewal review."
        },
        "renewalPrice": {
          "$ref": "#/components/schemas/Money",
          "description": "What the next renewal costs, which for a premium name differs from the purchase price."
        },
        "transferableAt": {
          "type": "string",
          "format": "date-time",
          "description": "The first moment the registrar allows a transfer out, after any registration, transfer or registrant lock."
        },
        "names": {
          "type": "string",
          "description": "How its subdomains are given out: explicit records only, or one-label claims by other Startups.",
          "enum": [
            "closed",
            "issued"
          ]
        },
        "publicSuffix": {
          "type": "boolean",
          "description": "True once the public suffix list browsers ship carries the Domain; an issuing Domain gives out no label before then."
        },
        "registrarAccount": {
          "type": "string",
          "description": "The registrar account that holds the Domain: one per Startup, never shared with a sibling."
        },
        "registryLock": {
          "type": "boolean",
          "description": "True when the registry refuses transfer, update and delete until a verified out-of-band request lifts it."
        },
        "certificate": {
          "description": "Certificate state (`pending`, `active`, `renewing` or `failed`), its expiry, and the failing check with its fix."
        },
        "validation": {
          "type": "string",
          "description": "`delegated` proves control through a CNAME to the platform; `serving` is for an apex that cannot hold one.",
          "enum": [
            "delegated",
            "serving"
          ]
        },
        "walletsEnabled": {
          "type": "boolean",
          "description": "True once Stripe lists the Domain as a payment method domain on the Startup’s account."
        },
        "carriedIdentity": {
          "type": "boolean",
          "description": "True once the Domain received mail, hosted a Mailbox or verified an outside account; it never resets."
        },
        "to": {
          "type": "string",
          "description": "For a redirect: the canonical Domain it forwards to permanently, path and query kept. The Domain id."
        }
      },
      "required": [
        "$id",
        "$type",
        "hostname",
        "role",
        "state"
      ]
    },
    "Event": {
      "type": "object",
      "description": "An Event is the immutable record of something that happened to a Thing, named by its Noun and past-tense Verb.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Event"
        },
        "name": {
          "type": "string",
          "description": "The Noun and the event form of its Verb, such as `Order.placed`."
        },
        "at": {
          "type": "string",
          "format": "date-time",
          "description": "When it happened."
        },
        "data": {
          "description": "The Thing as the Action left it."
        },
        "seq": {
          "type": "integer",
          "description": "Its position in the namespace, one more than the Event before; any seq is a cursor into the history."
        }
      },
      "required": [
        "$id",
        "$type",
        "name",
        "at"
      ]
    },
    "Human": {
      "type": "object",
      "description": "A Human is a Worker who is a person, acting on Tasks through Apps, Mailboxes, and Channels.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Human"
        },
        "name": {
          "type": "string",
          "description": "The name the Worker goes by in a Startup."
        },
        "instructions": {
          "type": "string",
          "description": "How the Worker does its work."
        },
        "email": {
          "type": "string",
          "format": "email",
          "description": "The address the Human signs in with."
        }
      },
      "required": [
        "$id",
        "$type",
        "name",
        "email"
      ]
    },
    "Invoice": {
      "type": "object",
      "description": "An Invoice is what a Customer owes for one or more Offers over one billing period.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Invoice"
        },
        "total": {
          "$ref": "#/components/schemas/Money",
          "description": "The amount due."
        },
        "due": {
          "type": "string",
          "format": "date",
          "description": "When payment is due."
        },
        "paidAt": {
          "type": "string",
          "format": "date-time",
          "description": "When it was paid."
        },
        "status": {
          "type": "string",
          "description": "One of `draft`, `open`, `paid`, `void`, or `uncollectible`.",
          "enum": [
            "draft",
            "open",
            "paid",
            "void",
            "uncollectible"
          ]
        },
        "collection": {
          "type": "string",
          "description": "`charge` charges the saved payment method; `send` sends the Invoice and waits for a transfer. `charge` by default.",
          "enum": [
            "charge",
            "send"
          ]
        },
        "terms": {
          "type": "integer",
          "description": "Days from issue until a `send` Invoice is due, such as 30; sets `due`."
        },
        "purchaseOrder": {
          "type": "string",
          "description": "The Customer’s purchase order number, printed on the Invoice."
        },
        "refunded": {
          "$ref": "#/components/schemas/Money",
          "description": "The total returned to the Customer, from zero up to the amount paid."
        },
        "number": {
          "type": "string",
          "description": "The Invoice number, sequential per Startup and never reused, voided Invoices included."
        },
        "lines": {
          "description": "Each Offer billed: its quantity, Period and amount, with any Coupon or Credit Grant applied."
        },
        "pdf": {
          "type": "string",
          "format": "uri",
          "description": "The Invoice, or its receipt once paid, as a PDF on the Startup’s Domain that names the seller of record."
        },
        "payUrl": {
          "type": "string",
          "format": "uri",
          "description": "The page on the Startup’s Domain where the Customer pays it by card or bank transfer."
        }
      },
      "required": [
        "$id",
        "$type",
        "total",
        "due"
      ]
    },
    "Lease": {
      "type": "object",
      "description": "A Lease is one resident’s agreement on one unit, from signing to renewal.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Lease"
        },
        "id": {
          "type": "string",
          "description": "The stable identifier, which never changes."
        },
        "type": {
          "type": "array",
          "items": {
            "description": "The Nouns this Thing is an instance of."
          },
          "description": "The Nouns this Thing is an instance of."
        },
        "state": {
          "type": "string",
          "description": "The current state in its lifecycle."
        },
        "outside": {
          "description": "The ids this Thing has in outside tools, one per Integration, so a re-run matches instead of duplicating."
        },
        "unit": {
          "type": "string",
          "description": "The unit the Lease covers."
        },
        "resident": {
          "type": "string",
          "description": "The resident who signed it. The Contact id."
        },
        "endsOn": {
          "type": "string",
          "format": "date",
          "description": "The last day of the term."
        },
        "rent": {
          "$ref": "#/components/schemas/Money",
          "description": "The monthly rent."
        },
        "status": {
          "type": "string",
          "description": "One of `active`, `renewing`, `renewed` or `ended`.",
          "enum": [
            "active",
            "renewing",
            "renewed",
            "ended"
          ]
        }
      },
      "required": [
        "$id",
        "$type",
        "id",
        "type",
        "unit",
        "endsOn",
        "status"
      ]
    },
    "Offer": {
      "type": "object",
      "description": "An Offer is a Product, under a Brand, at a price, on terms, made by a Startup.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Offer"
        },
        "price": {
          "$ref": "#/components/schemas/Money",
          "description": "The amount, currency, and unit. Zero is a price."
        },
        "terms": {
          "type": "string",
          "description": "The conditions the Customer accepts, refund rights included."
        },
        "from": {
          "type": "string",
          "description": "Lineage: the slot it compiles from, as `Hypothesis#<slot>@v<version>`."
        },
        "activation": {
          "description": "The Event, count and window that mark a Customer activated, such as `Reminder.sent` 20 times within 7 days."
        },
        "credit": {
          "$ref": "#/components/schemas/Money",
          "description": "The Credit Grant each purchase issues, for an Offer that sells prepaid credit, such as $50 of calls."
        },
        "atBound": {
          "type": "string",
          "description": "What a call past an Entitlement’s Limit gets: `stop`, `overage` or `upgrade` (refuse it, bill it through the Meter, or move to the next Offer).",
          "enum": [
            "stop",
            "overage",
            "upgrade"
          ]
        },
        "interval": {
          "type": "string",
          "description": "How often it bills: `once`, `day`, `week`, `month` or `year`.",
          "enum": [
            "once",
            "day",
            "week",
            "month",
            "year"
          ]
        },
        "availableFrom": {
          "type": "string",
          "format": "date-time",
          "description": "When it can first be bought. Unset: from when it is published."
        },
        "availableUntil": {
          "type": "string",
          "format": "date-time",
          "description": "When it can last be bought. Existing Subscriptions continue past it."
        },
        "trial": {
          "description": "The free trial every new Customer starts with: `days`, and `card` true to take a card up front. Unset: no trial."
        },
        "seats": {
          "type": "string",
          "description": "How a per-seat Price counts: `manual` (the buyer sets the quantity) or `members` (people in the Customer’s Tenant, prorated as they change).",
          "enum": [
            "manual",
            "members"
          ]
        },
        "uptime": {
          "description": "The monthly uptime it promises, and the share of that month’s charge credited back below each level."
        },
        "license": {
          "type": "string",
          "description": "What a buyer may do with the records it sells: use them `internal`ly, `display` them to its own users, or `redistribute` them.",
          "enum": [
            "internal",
            "display",
            "redistribute"
          ]
        },
        "attribution": {
          "type": "string",
          "description": "The credit line a buyer shows wherever the records appear."
        },
        "privateTo": {
          "type": "string",
          "description": "The one Party who sees it and may accept it, making it a private Offer; no pricing page lists it. The Party id."
        }
      },
      "required": [
        "$id",
        "$type",
        "price"
      ]
    },
    "Organization": {
      "type": "object",
      "description": "An Organization is an outside party as one Startup knows it, keyed by its domain, such as an employer or a vendor.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Organization"
        },
        "name": {
          "type": "string",
          "description": "The name it trades under."
        },
        "hostname": {
          "type": "string",
          "description": "The web domain that keys it."
        }
      },
      "required": [
        "$id",
        "$type",
        "name"
      ]
    },
    "Party": {
      "type": "object",
      "description": "A Party is a person or legal entity that can be a side of an Agreement or an Order, or hold rights.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Party"
        },
        "name": {
          "type": "string",
          "description": "The legal or personal name."
        }
      },
      "required": [
        "$id",
        "$type",
        "name"
      ]
    },
    "Person": {
      "type": "object",
      "description": "A Person is a human with one identity across every Startup; each Startup’s Contact is its own view of that Person.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Person"
        },
        "name": {
          "type": "string",
          "description": "The legal or personal name."
        },
        "verified": {
          "type": "boolean",
          "description": "True once the identity is verified."
        }
      },
      "required": [
        "$id",
        "$type",
        "name"
      ]
    },
    "Role": {
      "type": "object",
      "description": "A Role is a seat that owns a set of work and holds the Permissions to do it, filled by a Human or an Agent.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Role"
        },
        "name": {
          "type": "string",
          "description": "The title of the seat."
        },
        "responsibilities": {
          "type": "string",
          "description": "The work the seat owns."
        },
        "status": {
          "type": "string",
          "description": "One of `vacant` or `filled`.",
          "enum": [
            "vacant",
            "filled"
          ]
        },
        "approvals": {
          "description": "What waits for the founder: rules by action class (`spend`, `sign`, `publish`, `price`, `send`), each optionally above an amount in USD."
        }
      },
      "required": [
        "$id",
        "$type",
        "name",
        "status"
      ]
    },
    "Startup": {
      "type": "object",
      "description": "A Startup is the smallest business that can be moved, promoted, or sold on its own, with its own Products, Offers, Customers, and P&L.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Startup"
        },
        "name": {
          "type": "string",
          "description": "The name the Startup trades under."
        },
        "domain": {
          "type": "string",
          "format": "uri",
          "description": "The canonical hostname of the Startup."
        },
        "launchedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When the Startup went live."
        },
        "template": {
          "type": "string",
          "description": "The slug of the template it extends; the root one when none is named."
        },
        "idea": {
          "type": "string",
          "description": "The Idea it starts from, in a sentence, recorded as its Idea."
        },
        "spendState": {
          "type": "string",
          "description": "How freely money Limits allow spend: `free`, `tight` (discretionary Limits halved) or `hold` (one-way spend stops).",
          "enum": [
            "free",
            "tight",
            "hold"
          ]
        }
      },
      "required": [
        "$id",
        "$type",
        "name"
      ]
    },
    "Subscription": {
      "type": "object",
      "description": "A Subscription is a Customer’s standing acceptance of an Offer, billed each Period until canceled.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Subscription"
        },
        "status": {
          "type": "string",
          "description": "One of `active`, `trialing`, `pastDue`, `paused`, `incomplete`, or `canceled`.",
          "enum": [
            "active",
            "trialing",
            "pastDue",
            "paused",
            "incomplete",
            "canceled"
          ]
        },
        "renewsAt": {
          "type": "string",
          "format": "date-time",
          "description": "When it next renews."
        },
        "quantity": {
          "type": "integer",
          "description": "How many units of the Offer’s Price it holds, such as 12 members; 1 by default."
        },
        "trialEndsAt": {
          "type": "string",
          "format": "date-time",
          "description": "When a trial ends and the first paid period starts."
        },
        "termEndsAt": {
          "type": "string",
          "format": "date-time",
          "description": "When a committed term ends; the Renewal and the renewal notice read it."
        }
      },
      "required": [
        "$id",
        "$type",
        "status"
      ]
    },
    "Thing": {
      "type": "object",
      "description": "A Thing is an instance of one or more Nouns, with an identity, a current state, and the union of their properties.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Thing"
        },
        "id": {
          "type": "string",
          "description": "The stable identifier, which never changes."
        },
        "type": {
          "type": "array",
          "items": {
            "description": "The Nouns this Thing is an instance of."
          },
          "description": "The Nouns this Thing is an instance of."
        },
        "state": {
          "type": "string",
          "description": "The current state in its lifecycle."
        },
        "outside": {
          "description": "The ids this Thing has in outside tools, one per Integration, so a re-run matches instead of duplicating."
        }
      },
      "required": [
        "$id",
        "$type",
        "id",
        "type"
      ]
    },
    "Version": {
      "type": "object",
      "description": "A Version is an immutable build of a definition at a fingerprint; an Order keeps the Offer Version it bought.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Version"
        },
        "fingerprint": {
          "type": "string",
          "description": "The content hash that identifies the build."
        }
      },
      "required": [
        "$id",
        "$type",
        "fingerprint"
      ]
    },
    "Worker": {
      "type": "object",
      "description": "A Worker is a Human or an Agent that fills a Role and acts on Tasks.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Worker"
        },
        "name": {
          "type": "string",
          "description": "The name the Worker goes by in a Startup."
        },
        "instructions": {
          "type": "string",
          "description": "How the Worker does its work."
        }
      },
      "required": [
        "$id",
        "$type",
        "name"
      ]
    },
    "Workflow": {
      "type": "object",
      "description": "A Workflow is the durable, executable body of one Action: its steps, the Functions that run them, retries, and waits.",
      "properties": {
        "$id": {
          "type": "string",
          "format": "uri"
        },
        "$type": {
          "const": "Workflow"
        },
        "steps": {
          "description": "The ordered steps, each run by a Function."
        },
        "retries": {
          "type": "integer",
          "description": "How many times a failed step retries."
        },
        "body": {
          "type": "string",
          "description": "The Verb whose Action it is the durable body of, such as `Order.refund`; a Workflow with a body has no Trigger."
        }
      },
      "required": [
        "$id",
        "$type",
        "steps"
      ]
    }
  }
}
