# Coordinate Worker Deployments and Service Releases

These instructions apply to the current Admin Console.

For a solution that uses Service-managed components, install or update the required Service releases in the target tenant, then deploy the Workers. Reuse compatible components already in the target tenant. You can deploy a Worker that needs no Service-delivered components directly.

For example, an order-processing managed Worker may need a Service-owned `order` Object Type and a tenant-owned customer relationship management (CRM) Connection. Install the Service release, configure the target tenant's Connection, then deploy the Worker with the [Workers CLI](https://docs.contextual.io/build/contextual-workers/contextual-cli.md) and bind its Connection alias to that Connection.

Deploy the Worker separately from the Service. Keep both the Worker and its platform-created Agent (which has the same ID) out of the Service package.

For a Worker defined by a Docker build, image, Compose file, or managed template, an Application manifest can deploy it and reference Service-managed prerequisites. See [Deploy alongside an existing Service](https://docs.contextual.io/build/applications/examples.md#deploy-alongside-an-existing-service).

{% hint style="info" %}
Here, **Service** means a Contextual package of versioned components. A Compose `service` defines a container within a Worker.
{% endhint %}

## Decide What to Release

| Part of the solution | How to deliver it |
| --- | --- |
| Object Types, Connections, and AI Routes | Release Service-owned components through their Services. |
| Existing target-tenant components | Reuse compatible components; declare peer dependencies where your Service requires them. |
| Worker code and configuration | Push the image, then create or update the Worker through the CLI or the admin console. |
| Application records | Include specific records explicitly as Service dependencies, or create or migrate them separately. Installing an Object Type definition does not copy its records. |

A Service installs and manages its **direct dependencies**, such as an `order` Object Type included in its release. **Peer dependencies** are components the Service requires but does not install or manage, such as a shared CRM Connection. These components must already exist in the target tenant.

## Promote a Solution to Production

The following sequence combines platform prerequisites with release planning, verification, and recovery recommendations. Adapt the recommendations to your solution.

### 1. Plan the Release

A release checklist can help track:

* Service releases, existing dependencies, and each Worker's image digest and configuration, including its template version when used.
* Target-tenant IDs, Connection bindings, AI Routes, and event destinations, including references between Workers.
* Required data setup or migration, application checks, and recovery steps.

Choose one process to manage each resource. Reference Service-owned resources from other tools rather than maintaining competing definitions. One pipeline can coordinate the release; the checklist itself does not enforce dependencies.

Specifying `--config-id <target-config-id>` explicitly on release commands helps avoid targeting the wrong tenant. Without this flag, the CLI uses its current default configuration, which may point to another tenant and receive unintended Service changes, image pushes, or Worker deployments.

### 2. Install or Update the Required Services

{% hint style="warning" %}
Service updates overwrite direct dependencies and can delete components removed from a release. Check compatibility with running Workers before updating.
{% endhint %}

Confirm that peer dependencies are present and compatible. Use the Contextual CLI to inspect Services and releases or change a source Service's dependencies with `ctxl services patch`. To validate and install or update the required releases, use **Build > Services** in the admin console.

The application may also need initial records or data migration, plus production-specific Connection endpoints, credentials, authorization, and resource IDs.

For a Service-owned Object Type, a staged cutover can use two releases: install prerequisites without the new [Object Type trigger](https://docs.contextual.io/build/object-types/object-type-details/triggers.md), deploy the Worker, then release the routing change when the Worker is ready. This gives you an opportunity to check the Worker before routing production events. Keep trigger changes in the source Service; later updates overwrite edits made only in the installed tenant.

### 3. Deploy the Worker to the Target Tenant

Confirm Worker enablement and create or update permissions in the target tenant. Use the target tenant's CLI configuration for image pushes and Worker deployment.

Create or update the Worker using an image from an [accepted image host](https://docs.contextual.io/build/contextual-workers/about-workers.md#image-references) accessible to the target tenant. Set production environment variables, `CONFIG`, and `CONNECTION_BINDINGS` as applicable. Enter secrets in the admin console under **Environment variables**. For managed Workers, [Release Versions](https://docs.contextual.io/build/contextual-workers/managed-workers.md#release-versions) lists compatible adapter and template versions.

Use [Workers CLI Reference](https://docs.contextual.io/build/contextual-workers/contextual-cli.md) and [Templates and Options](https://docs.contextual.io/build/contextual-workers/managed-workers/templates-and-options.md) for commands and settings. Saving starts deployment, so prerequisites must be ready for event or scheduled processing. Installing a resource does not grant access to it; investigate permission failures through [Worker Identity](https://docs.contextual.io/build/contextual-workers/managed-workers/platform-services.md#worker-identity).

### 4. Verify the Application and Complete Cutover

The Worker's **Deployment** view and [logs](https://docs.contextual.io/build/contextual-workers/contextual-cli.md#read-logs) can help assess startup and runtime status. Application checks might include a record operation, a Connection call, an HTTP request, a [test event](https://docs.contextual.io/build/contextual-workers/connect-to-contextual.md#events-and-schedules), or a scheduled run, depending on what the Worker does. A started container alone does not establish correct application behavior.

For a staged cutover, activate deferred routing when the new Worker is ready to receive production work.

## Coordinate Updates and Recovery

For a compatible rollout, you can deploy dependency updates that support the running implementation before updating the Worker, then remove obsolete fields or components in a later release. A breaking change may need a coordinated cutover.

Change only the release that needs updating. Worker-only changes do not require a Service release, and Service-only changes still need compatibility checks against running Workers.

Retaining previous images and settings can make recovery easier. You can [restore an earlier Worker image](https://docs.contextual.io/build/contextual-workers/contextual-cli.md#return-to-a-previous-image) with compatible configuration and template settings, provided the earlier application still works with the tenant's current schemas and data. A corrective Service release can restore component definitions.

Service installation and Worker deployment do not form an atomic transaction. A failure does not automatically reverse earlier changes. Restoring code or definitions also does not undo record writes or external effects; data recovery may need separate handling.
