---
title: Sync templates from CI
description: Keep a GitHub-connected template on your latest production commit by syncing it from a CI workflow
docs_index: /docs/llms.txt
lastUpdated: 2026-11-27
product: v0 API
type: guide
related:
  - /docs/templates
  - /docs/api/v2/reference/chats/sync-chat-template
---

> For an index of all documentation, see [/docs/llms.txt](/docs/llms.txt).

A [Git-connected template](/docs/templates#updating-a-git-connected-template) stays pinned to one commit until someone syncs it. [`chats.syncTemplate`](/docs/api/v2/reference/chats/sync-chat-template) does the same as **Sync from Repo**: it publishes a new version of the template at the commit of the source chat's READY production deployment. New projects created from the template use that commit; existing projects are not updated.

You need:

- A template whose source chat is connected to a GitHub repository.
- The source chat's ID, which ends its `v0.app/chat` URL after the chat's title. For `v0.app/chat/my-site-oVqgavd5PbW`, it's `oVqgavd5PbW`.
- A user API key created by the template's author, or by an owner of the team the template is shared with. Requests act as the key's creator.

## Sync after each production deployment

Vercel reports deployments to GitHub, so a workflow can sync the template once production is ready. Store the API key as the `V0_API_KEY` secret, the chat ID as the `V0_TEMPLATE_CHAT_ID` variable, and the name of the template project's production environment, as shown under your repository's **Environments**, as the `V0_TEMPLATE_ENVIRONMENT` variable:

```yaml title=".github/workflows/sync-v0-template.yml"
name: Sync v0 template

on: deployment_status

concurrency: sync-v0-template

jobs:
  sync:
    if: github.event.deployment_status.state == 'success' && github.event.deployment.environment == vars.V0_TEMPLATE_ENVIRONMENT
    runs-on: ubuntu-latest
    steps:
      - name: Sync template
        env:
          V0_API_KEY: ${{ secrets.V0_API_KEY }}
          CHAT_ID: ${{ vars.V0_TEMPLATE_CHAT_ID }}
          SHA: ${{ github.event.deployment.sha }}
        run: |
          curl --fail-with-body -sS -X POST "https://api.v0.dev/v2/chats/$CHAT_ID/template/sync" \
            -H "Authorization: Bearer $V0_API_KEY" \
            -H "Content-Type: application/json" \
            -d "{\"expectedGitSha\":\"$SHA\"}"
```

`expectedGitSha` is optional. When set, v0 only syncs if production is on that commit, so a run can't pin a different deployment than the one that triggered it. If the template is already pinned to the production commit, the response has `changed: false` and no new version is published.

With the TypeScript SDK, the same call is `v0.chats.syncTemplate({ chatId, expectedGitSha })`. See the [API reference](/docs/api/v2/reference/chats/sync-chat-template) for the full request, response, and error statuses.

---

For a semantic overview of all documentation, see [/docs/sitemap.md](/docs/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/docs/agents.md](/docs/agents.md)