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.
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:
Input contract
contracts/input.schema.json describes the payload the app opens with. At runtime it is sdk.input.
{
"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"]
}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).
{
"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"]
}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):
| Keyword | Use |
|---|---|
type, properties, required, items | Structure. |
enum | Fixed choices: decisions, statuses, priorities. |
description | What a field means, for whoever connects the app. |
format | date-time, email, uri. |
default | Default value. |
minLength, maxLength, minimum, maximum | Limits. |
Draft, submit or cancel
| Call | Payload must match the output contract | Session |
|---|---|---|
sdk.saveDraft(payload) | No | Stays open; call it as often as you need. |
sdk.submitOutput(payload) | Yes | Completed. Call it once. |
sdk.cancel(reason) | No output | Cancelled. |
Apps that need input
The manifest says whether the app can open without input:
| Manifest | Behavior |
|---|---|
"entry_behavior": "home", "requires_context": false | Opens to its home view; input is optional. |
"entry_behavior": "context-required", "requires_context": true | Needs 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:
{ "type": "object", "properties": {}, "required": [] }Good practice
- Always ship both contracts, even empty: they document the app.
- Mark required fields explicitly.
- Describe every property.
- Use
enumfor fixed choices, so the output can drive routing. - Keep the output small: only what consumers need.
- When you change a contract, keep it compatible with the workflows and tasks that already use it.