On this page
Sommatic Docs
Open portal

Contracts

Every app declares what it receives and what it returns as two JSON Schema files. The input contract shapes sdk.input; the output contract is the payload of sdk.submitOutput that tasks, workflows and other apps rely on.

View as Markdown
Open in

A contract turns an app into a dependable step. Whoever opens the app knows what to send; whoever consumes its result knows what comes back. Contracts live in the contracts/ folder of every app:

contracts/
├── input.schema.json     # what the app receives
└── output.schema.json    # what the app returns

Input contract

contracts/input.schema.json describes the payload the app opens with. At runtime it is sdk.input.

JSON
{
  "type": "object",
  "properties": {
    "title": { "type": "string", "description": "Title shown in the header" },
    "description": { "type": "string", "description": "What needs to be reviewed" },
    "priority": {
      "type": "string",
      "enum": ["low", "medium", "high", "critical"],
      "description": "Priority level"
    },
    "data": { "type": "object", "description": "Payload to review" }
  },
  "required": ["title"]
}
JSX
function Review({ sdk }) {
  const { title, description } = sdk?.input || {};

  if (!title) {
    return <p>No data to review.</p>;
  }

  return (
    <section>
      <h2>{title}</h2>
      <p>{description}</p>
    </section>
  );
}

Output contract

contracts/output.schema.json describes the payload the app returns with sdk.submitOutput(payload).

JSON
{
  "type": "object",
  "properties": {
    "decision": {
      "type": "string",
      "enum": ["approved", "rejected", "escalated"],
      "description": "The reviewer's decision"
    },
    "notes": { "type": "string", "description": "Justification" },
    "reviewed_at": { "type": "string", "format": "date-time", "description": "When it was reviewed" }
  },
  "required": ["decision"]
}
JavaScript
sdk.submitOutput({ decision: 'approved', notes, reviewed_at: new Date().toISOString() });

When an app opened from a task submits its output in the portal, the output becomes the task’s outputs: a decision of rejected rejects the task, any other output completes it. Align the output contract with the task’s required_output so the completion passes validation.

Schema keywords

Contracts use JSON Schema (draft-07 compatible):

KeywordUse
type, properties, required, itemsStructure.
enumFixed choices: decisions, statuses, priorities.
descriptionWhat a field means, for whoever connects the app.
formatdate-time, email, uri.
defaultDefault value.
minLength, maxLength, minimum, maximumLimits.

Draft, submit or cancel

CallPayload must match the output contractSession
sdk.saveDraft(payload)NoStays open; call it as often as you need.
sdk.submitOutput(payload)YesCompleted. Call it once.
sdk.cancel(reason)No outputCancelled.

Apps that need input

The manifest says whether the app can open without input:

ManifestBehavior
"entry_behavior": "home", "requires_context": falseOpens to its home view; input is optional.
"entry_behavior": "context-required", "requires_context": trueNeeds an input. The launcher does not show it without one.

An app that takes no input or returns no output still ships both files, with an empty schema:

JSON
{ "type": "object", "properties": {}, "required": [] }

Good practice

  1. Always ship both contracts, even empty: they document the app.
  2. Mark required fields explicitly.
  3. Describe every property.
  4. Use enum for fixed choices, so the output can drive routing.
  5. Keep the output small: only what consumers need.
  6. When you change a contract, keep it compatible with the workflows and tasks that already use it.

Next steps

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs