On this page
Sommatic Docs
Open portal

Preview and apply

Preview resolves a package or a resource at the head of the branch and shows what would change, without writing. Apply writes exactly the commit you previewed, skips what did not change and can publish new versions.

View as Markdown
Open in

Deploying from Git is two calls. Preview tells you which commit the installation’s branch is at and what each resource would become. Apply writes that commit, and only that commit. The same operations are behind Sync package and Sync from Git… in the portal.

The examples use two placeholders: $SOMMATIC_API is the API base URL (https://api.sommatic.ai) and $SOMMATIC_TOKEN is a Bearer token for your organization (see Authentication). <repository_id> is the id of the Git repository connection, for example pi-git-repo-xxxxxxxxxxxxxxx. Every response uses the standard envelope { status, success, message, result }.

Choose what to sync

Preview and apply select the same way:

ParameterSelects
pathEvery resource of the package in that folder.
keyOne resource, by its logical key.
resource_idOne resource, by its id in this installation.
keysApply only: together with path, only these keys of the package.

Read the package

Shell
curl -s "$SOMMATIC_API/platform-infrastructure/git-repository/<repository_id>/package?path=support" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"

The result lists the manifest, the head commit of the branch and, for each resource, its resource_id in this installation (null when the key is not mapped in the environment file).

Preview the change

Shell
curl -s -X POST "$SOMMATIC_API/platform-infrastructure/git-sync/preview" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ "repository_id": "<repository_id>", "path": "support", "include_content": false }'

Preview writes nothing. Read these fields of result:

  • commit, commit_message, commit_date: the head of the branch. This is the commit you will apply.
  • items[], one per resource, with key, path, resource_id and:
    • exists: whether the resource exists in this installation.
    • unresolved: tokens that could not be resolved. It must be empty.
    • changes.has_changes, and for workflows changes.nodes (added, removed, changed), changes.edges (added, removed), changes.fields and changes.layout_changed. changes.details names each node and the config settings that changed.
    • unlinked_here: the resource is unlinked from Git in this installation and will be skipped.

include_content: false leaves out the resolved content of each resource. Keep it off unless you need it.

Apply the reviewed commit

Shell
curl -s -X POST "$SOMMATIC_API/platform-infrastructure/git-sync/apply" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "repository_id": "<repository_id>",
    "path": "support",
    "expected_commit": "<commit from the preview>",
    "publish": true,
    "description": "Pull request #12"
  }'

The result has the commit, whether it published, the counts applied, unchanged, skipped and failed, and items[] with each result, a reason when it failed or was skipped, and the published version.

Check the outcome

A response with success: true can still contain failed items. Check result.failed and every item’s result before you report the deployment as done.

Safety rules

  1. expected_commit is mandatory and must be the commit returned by the preview and still the head of the branch the connection reads. If the branch moved after your preview, apply fails: preview again and review the new commit. Apply never deploys an arbitrary commit, such as one of a feature/* branch that skipped the pull request, and it ignores ref.
  2. Nothing half-resolved is written. A resource with unresolved tokens, or that does not exist in the installation, is reported as failed and left untouched.
  3. Apply is idempotent. Resources without changes are unchanged. With publish: true, an unchanged resource is published only if its deployed version does not come from this commit yet. Running the same apply twice is safe.
  4. Rollbacks happen in Git. To undo a change, merge a revert pull request and apply the new head. You cannot apply an old commit.

Publish

With publish: true, apply creates a new version of each workflow and a new version snapshot of each knowledge resource, and stores the commit, the key and your description with it. You can also publish later, one resource at a time:

Shell
curl -s -X POST "$SOMMATIC_API/workflow-orchestration/control-plane/flow-design/flow-definition/<flow_definition_id>/publish" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"

curl -s -X POST "$SOMMATIC_API/cognitive-infrastructure/cognitive-assets/knowledge-resource/<knowledge_resource_id>/publish" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"

After a sync, each resource keeps a git_binding with the repository, branch, environment, key and file, the last_synced_commit and, once published, the deployed_commit and deployed_version.

Preview another branch

Preview accepts ref (a branch, tag or commit) to resolve a commit other than the head of the connection branch, for example to check a pull request before merging it. Apply ignores ref: only the head of the connection branch can be deployed.

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