> ## Documentation Index
> Fetch the complete documentation index at: https://docs.asteroid.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Versions and publishing

> How saving, drafts and publishing decide which instructions an execution uses.

Every workflow is versioned. Saving updates the editable draft. Publishing or executing it freezes that **version**.

A saved version is a **draft**. One version of the workflow is **published**. The published version is the one your production traffic runs.

<CardGroup cols={2}>
  <Card title="Draft" icon="pencil" horizontal>Where every edit lands. Runs in production do not see it.</Card>
  <Card title="Published" icon="rocket" horizontal>The version that API calls, schedules and integrations use.</Card>
</CardGroup>

## Which version an execution uses

An execution uses one version, and it holds that version until it finishes.

| Trigger                    | Version used                                                  |
| -------------------------- | ------------------------------------------------------------- |
| API or SDK                 | The published version, unless the call passes `version`       |
| Schedules and integrations | The published version, unless the schedule pins a version     |
| Run button on the platform | The version you pick in the execution dialog, drafts included |

Edits in a draft do not change an execution until you publish.

<Warning>
  If your API runs ignore a change, check that you published the new version. A test execution can target the draft. The workflow then looks correct in testing while production runs the older version.
</Warning>

## Pinning a version from the API

The execute call takes an optional `version` field. Pass an integer to run that exact version, published or not.

```bash theme={null}
curl -X POST https://odyssey.asteroid.ai/agents/v2/agents/YOUR_AGENT_ID/execute \
  -H "X-Asteroid-Agents-Api-Key: $ASTEROID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": { "company": "Acme" },
    "version": 12
  }'
```

Omit `version` and the execution uses the published version. See [Call a workflow from your code](/integrate/call-an-agent).

A schedule set to a specific version keeps that version, even after you publish a newer one. See [Schedules](/operate/schedules).

## Publishing

Publishing promotes one version to be the default for API, schedule and integration triggers.

* On the platform, open the workflow and click **Publish**.
* From your code, call `POST /agents/{agentId}/workflows/{workflowId}/publish`.

Publishing never touches an execution that already started. Each [execution](/concepts/executions) keeps the version it began with.

## Version history

The platform shows the workflow's version lineage and marks the published one.

Asteroid keeps every version that was published or executed. You can always read the exact instructions a past run used. Only an unpublished draft with no executions can be deleted.

<CardGroup cols={2}>
  <Card title="Test, iterate, publish" icon="flask-conical" href="/build/test-and-publish">The loop from draft to published</Card>
  <Card title="Call a workflow" icon="code" href="/integrate/call-an-agent">Start an execution, with or without a pinned version</Card>
</CardGroup>
