Grid82
grid82.comJoin the waitlist
BuildBuilding workflows

Building workflows

Author durable TypeScript automations in the Studio workbench, inspect the live diagram, test runs safely, and monitor execution traces.

Open Automations in an app’s Studio sidebar to write workflows, inspect the auto-generated execution diagram, run tests, and trace completed or waiting runs.

Studio Automations workbench displaying Large deal approval workflow

The Studio Automations view showing a compiled workflow's code, live diagram, and test/run history

Anatomy of an app workflow

Every workflow calls workflow(config, handler) from "grid82:workflow". Section comments starting with // ## become labeled headings in the visual diagram, and every SDK step starts with a unique human-readable label:

TypeScript
import { workflow, record } from "grid82:workflow";

export default workflow(
  {
    name: "Large deal approval",
    trigger: record.updated("Sales CRM.Deals", {
      fields: ["Stage"],
      when: { Stage: "Proposal" },
    }),
    apps: ["Sales CRM"],
  },
  async ({ trigger, db, approval }) => {
    // ## Check threshold
    if ((trigger.record["Net value"] ?? 0) < 50000) return;

    // ## Ask Sales Manager
    const decision = await approval.ask("Ask Sales Manager to approve discount", {
      role: "Sales Manager",
      question: "Approve proposal terms on this enterprise deal?",
      show: {
        Deal: trigger.record.Name,
        "Net value": trigger.record["Net value"],
        Discount: trigger.record.Discount,
      },
    });

    if (decision.approved) {
      await db["Sales CRM"].Deals.update("Mark deal approved", trigger.record.id, {
        Stage: "Negotiation",
      });
    }
  },
);

Five rules the workflow compiler enforces

Because paused workflows replay from the top when waking from a sleep or approval.ask, the compiler rejects nondeterministic code before saving:

  1. Every SDK call needs a unique literal label and its own await: Pass parallel calls explicitly through Promise.all([...]).
  2. Use for...of over a step result: Classic for and while loops are disallowed so step counts stay inspectable.
  3. No unguarded clocks or randomness: Call Date.now(), new Date(), or Math.random() inside step.do(...), or read trigger.firedAt.
  4. Destructure only what you use: If handler lists { db, step } without trigger, accessing trigger fails compilation.
  5. List secrets safely: Secrets ("secret:NAME") are valid only as the complete URL argument to http.get or http.post, never interpolated inside headers or JSON bodies.

Read the Workflow SDK reference for the complete db, ai, step, approval, and http API.

Use these docs with your AI tools

An AI agent can read this documentation directly. You do not need an account or an API key. Everything here is public and read-only.

Query these docs via MCP

Recommended

Add this server to Claude, Claude Code, Cursor, Mistral, or any tool that supports MCP. Your agent can then search Grid82 documentation and read it in full, instead of answering from memory.

https://grid82.com/docs/mcp
  • searchFind the passages that answer a question.
  • fetchRead one page in full, as Markdown.
  • list_pagesSee every page in this documentation.

Query these docs over HTTP

The same tools also work as plain web requests. Use this for scripts, or for any tool that does not support MCP. There is one endpoint per tool. Arguments go in the query string, and the answer comes back as JSON.

https://grid82.com/docs/api/docs/search?query=custom+domain

Read the OpenAPI description. It is built from the same definitions as the tools, so it always matches what the endpoints do.

Read these docs as Markdown

Add .md to any page URL to get its Markdown source. You can also send the headerAccept: text/markdown to the page URL itself.

To read the whole documentation in one file, open llms-full.txt. For a short index of every page, open llms.txt.