# Resource files

> Each workflow or knowledge resource is one JSON file with a sommatic header. Workflows use the studio export format with stable node ids; runtime fields are never stored.

Source: https://docs.sommatic.ai/en/git-sync/resource-files/ (updated 2026-11-26)

A resource file is the definition of one workflow or one knowledge resource, written so that it can be reviewed in a
pull request and loaded into any installation. It carries a header that says what it is, the fields of the resource,
and tokens wherever a value depends on the installation.

## The header

Every file starts with a `sommatic` object:

```json
{
  "sommatic": {
    "kind": "workflow",
    "key": "support.triage",
    "schema_version": "1.0"
  }
}
```

| Field            | Description                                           |
| ---------------- | ----------------------------------------------------- |
| `kind`           | `workflow` or `knowledge-resource`.                   |
| `key`            | The same key the package manifest uses for this file. |
| `schema_version` | Always `1.0`.                                         |

The JSON Schema is published at
[`https://docs.sommatic.ai/schemas/git-sync/resource-header.schema.json`](https://docs.sommatic.ai/schemas/git-sync/resource-header.schema.json).

## Workflow files

A workflow file is the studio export format (`__export_version` `2.0`) plus the header. Besides descriptive fields
(`name`, `slug`, `description`, `tags`…), it holds the draft:

- `draft_nodes`: the nodes, each with `node_id`, `label`, `operator_slug`, `operator_version`, `config` and `ports`.
- `draft_edges`: the edges, `{ from: { node_id, port }, to: { node_id, port } }`.
- `editor_state`: the canvas layout, including `node_positions` keyed by `node_id`.

A small example, a webhook that classifies the request with an LLM provider that differs per installation:

```json
{
  "__export_version": "2.0",
  "description": "Classifies inbound support requests.",
  "draft_edges": [
    {
      "from": { "node_id": "node-webhook", "port": "out" },
      "id": "edge-webhook-classify",
      "to": { "node_id": "node-classify", "port": "in" }
    }
  ],
  "draft_nodes": [
    {
      "config": { "method": "POST", "response_mode": "immediate" },
      "label": "Webhook Receiver",
      "node_id": "node-webhook",
      "operator_slug": "webhook.trigger",
      "operator_version": "1.0.0",
      "ports": [
        { "is_default": true, "label": "Received", "port_id": "out" },
        { "label": "Error", "port_id": "error" }
      ]
    },
    {
      "config": {
        "invocation_mode": "sync",
        "labels": ["billing", "technical", "other"],
        "llm_provider_id": "@@env.LLM_PROVIDER_ID@@",
        "text": "{{ $json.body.message }}"
      },
      "label": "Classify request",
      "node_id": "node-classify",
      "operator_slug": "ai.classify",
      "operator_version": "1.0.0",
      "ports": [
        { "is_default": true, "label": "Classified", "port_id": "success" },
        { "label": "Error", "port_id": "error" }
      ]
    }
  ],
  "editor_state": {
    "node_positions": {
      "node-classify": { "x": 320, "y": 0 },
      "node-webhook": { "x": 0, "y": 0 }
    }
  },
  "name": "Support triage",
  "slug": "support-triage",
  "sommatic": { "key": "support.triage", "kind": "workflow", "schema_version": "1.0" }
}
```

The `config` and `ports` of each node follow its page in the node catalog, for example
[`webhook.trigger`](https://docs.sommatic.ai/en/nodes/webhook.trigger.md) and [`ai.classify`](https://docs.sommatic.ai/en/nodes/ai.classify.md).

### Keep `node_id` stable

Sommatic AI compares nodes by `node_id`. When you edit a node, keep its id: the preview then reports it as _changed_,
secrets declared with `from: live` keep their value, and the layout stays in place. A new id means a removed node and
an added one.

## Knowledge resource files

A knowledge resource file carries the resource fields (`name`, `slug`, `description`, `resource_type`, `language`,
`tags`, `governance`, `capabilities`, `content`…) with `"kind": "knowledge-resource"` in the header.

## What is never stored

Runtime fields belong to each installation and are never written to a file: `id`, `created`, `modified`, `status`,
`execution_state`, `latest_version_id` and `version_counter`. The resource header schema rejects a file that contains
any of them.

## Format

Write files the way Sommatic AI exports them, so diffs stay small: keys sorted alphabetically, two-space indentation and
a trailing newline. The easiest way to get the exact format is to start from **Export for Git…** in the studio (see
[Export and unlink](https://docs.sommatic.ai/en/git-sync/export-and-unlink.md)).

> **Warning: Ids and secrets are tokens**
>
> Never write a physical id of an installation or a secret in a resource file. Use `@@ref.<key>@@` for other
> resources, `@@env.NAME@@` for provider and credential ids, and `@@secret.NAME@@` for secrets. See
> [Environments and tokens](https://docs.sommatic.ai/en/git-sync/environments-and-tokens.md).

## Next steps

- [Preview and apply](https://docs.sommatic.ai/en/git-sync/preview-and-apply.md): Load the files into an installation.
- [Branches and CI](https://docs.sommatic.ai/en/git-sync/ci.md): Validate every pull request against the schemas.
