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

# bazable sync

> Pull latest contract from Bazable Cloud

Pulls the latest contract from Bazable Cloud and overwrites the local `bazable.config.json`.

<Warning>
  `sync` overwrites your local `bazable.config.json`. Commit any local contract changes first, or push them with [`bazable push`](/commands/push).
</Warning>

## Usage

```bash theme={null}
bazable sync
```

## Options

<ParamField query="--version" type="number">
  Fetch a specific contract version instead of the latest.
</ParamField>

<ParamField query="-t, --token" type="string">
  Use a specific access token (headless mode, no browser authentication). Useful in CI.
</ParamField>

## Prerequisites

* Your `bazable.config.json` must contain a `cloudProjectId` (set automatically by the first [`bazable push`](/commands/push)).
* You must be authenticated. If you are not logged in, the command starts the [device-code flow](/cloud/device-auth) automatically. In CI, use `--token` to authenticate headlessly.

## What it does

<Steps>
  <Step title="Check authentication">
    If no stored token exists (and no `--token` is provided), starts the device-code flow.
  </Step>

  <Step title="Fetch the contract">
    Retrieves the contract data from the cloud. Gets the latest version by default, or the specified `--version`.
  </Step>

  <Step title="Overwrite the local contract">
    Your local `bazable.config.json` is replaced with the fetched version. All endpoints, schemas, base URLs, and the `projectName` are updated.
  </Step>

  <Step title="Handle missing versions">
    If the requested version does not exist, a clear error is shown.
  </Step>
</Steps>

## Examples

<CodeGroup>
  ```bash Latest version theme={null}
  bazable sync
  ```

  ```bash Rollback theme={null}
  bazable sync --version 1
  ```

  ```bash CI (headless) theme={null}
  bazable sync --token $BAZABLE_TOKEN
  ```
</CodeGroup>

<Tip>
  For a live development loop, use [`bazable watch`](/cloud/watch) instead of running `sync` manually. It opens a real-time WebSocket to the cloud and auto-applies contract updates the moment they are pushed.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.