Andi API

Data Model

Define objects, attributes, operations, and lifecycle hooks in Andi

Open Markdown

What is an object?

An object is the entity you want to model in Andi, such as a Customer, Order, Ticket, or PurchaseOrder.

Objects are the core unit of data that agents and apps read, update, and act on.

Object shape

Each object includes a common base structure:

  • id: unique identifier for the record.
  • name: human-readable label.
  • description: optional context for people and agents.
  • attributes: typed fields that represent domain-specific data.

Object definition (what the object is):

{
  key: "Order",
  name: "Order",
  description: "Represents a customer purchase order",
  attributes: {
    customerId: { type: "string", required: true },
    amount: { type: "number", required: true },
    status: { type: "string", required: true },
    createdAt: { type: "datetime", required: true }
  }
}

Real object (one record of that definition):

{
  id: "ord_123",
  name: "Order #123",
  attributes: {
    customerId: "cus_789",
    amount: 1499,
    status: "pending",
    createdAt: "2026-03-05T12:00:00Z"
  }
}

Object operations

Common data operations supported by Andi objects:

  • Get by id: retrieve one object by identifier.
  • Append many: insert multiple new objects in bulk.
  • Upsert: create objects if they do not exist, or update if they do.
  • Update many: update multiple objects in one operation.
  • Delete many: remove multiple objects in one operation.
  • Query: list objects using filters, sorting, pagination, and other constraints.

Lifecycle hooks

Objects can run lifecycle hooks on every operation so you can enforce logic, side effects, and policies consistently.

Recommended lifecycle stages:

  • pre-create: validate input, set defaults, enforce permissions.
  • post-create: trigger notifications, indexing, or downstream jobs.
  • pre-update: validate changes, check invariants, enforce policies.
  • post-update: emit events, sync external systems, recalculate derived data.
  • pre-delete: block unsafe deletes and run dependency checks.
  • post-delete: clean up references and propagate deletion events.
  • pre-read: apply access control and field-level restrictions.
  • post-read: redact/transform outputs and attach computed fields.

Use these hooks to keep behavior predictable across humans, APIs, and autonomous agents.

On this page