# agility pull

> Source: https://agilitycms.com/docs/developers/cli-pull

`agility pull` downloads an Agility instance to local files: models, containers, content, page templates, pages, assets, galleries, sitemaps and URL redirections. Use it for a local snapshot, a backup, or to check an instance's models in CI. It only reads from the instance.

Checked against `@agility/cli` 1.2.1. For the options every command shares, sign-in and exit codes, see the [CLI command reference](/docs/developers/cli-reference).

## Usage

```bash
agility pull --sourceGuid=<guid> [options]
```

From `agility pull --help`:

```text
agility pull

Pull your Agility instance locally.
```

## Required settings

| Setting | How to provide it |
| --- | --- |
| Instance | `--sourceGuid`, or `AGILITY_GUID` in a `.env` file |
| Locales | `--locales`, `AGILITY_LOCALES` in a `.env` file, or leave both out to use every locale on the instance |
| Channel | `--channel`; defaults to `website` |
| Sign-in | A browser sign-in, or a Personal Access Token with `--token` or `AGILITY_TOKEN` |

## Options

| Option | Default | What it does in a pull |
| --- | --- | --- |
| `--sourceGuid` | from `.env` | The instance to download. One GUID per run |
| `--locales` | auto-detected | Comma-separated locale codes to download |
| `--channel` | `website` | The channel whose sitemap is downloaded |
| `--elements` | all | Comma-separated subset of `Models,Galleries,Assets,Containers,Content,Templates,Pages,Sitemaps,UrlRedirections`. `--elements=Models` downloads only model definitions |
| `--models` | none | Comma-separated model reference names. With `--models` and no `--models-with-deps`, only model definitions are downloaded |
| `--models-with-deps` | none | Comma-separated model reference names, plus everything they depend on |
| `--fullPull` | `false` | Ignores the stored content sync tokens, downloads all content items and pages again, and removes local content and page files that no longer exist on the instance |
| `--token` | none | Personal Access Token. Falls back to `AGILITY_TOKEN` |
| `--headless` | `false` | Logs to a file only, with no console output |
| `--verbose` | `true` | Writes all logs to the console |

`pull --help` also lists `--targetGuid`, `--pages`, `--containers`, `--preflight`, `--jsonSummary`, `--overwrite` and `--autoPublish`. They apply to sync and push, not to a pull.

## Incremental downloads

Content items and pages are downloaded with the Content Sync SDK, using the instance's **preview** API key, so the download holds the latest saved version of each item, published or not. The first pull downloads everything; later pulls into the same folder download only what changed, using a sync token stored per locale:

```text
agility-files/{guid}/{locale}/state/sync.json
```

Models, containers, templates, galleries and assets are compared with the instance on every pull, whatever the sync token says. Use `--fullPull` when the local copy may be stale, for example after copying an `agility-files` folder from another machine. (A full re-pull logs its progress with the older wording `--reset=true`.)

## Where the files go

```text
agility-files/{guid}/
├── models/            # one JSON file per model, named by model ID
├── containers/
├── templates/
├── galleries/
├── assets/
└── {locale}/          # content items, pages, sitemaps, URL redirections, sync state
```

The folder is created in the current working directory. In 1.2.1 there is no option to change it.

## Examples

```bash
# Everything, every locale
agility pull --sourceGuid="abc123-u"

# One locale
agility pull --sourceGuid="abc123-u" --locales="en-us"

# Models only (fast; useful for checking model changes in CI)
agility pull --sourceGuid="abc123-u" --elements="Models"

# Start over: ignore stored sync tokens and re-download content and pages
agility pull --sourceGuid="abc123-u" --fullPull

# In CI: token from a secret, file-only logging, pinned version
AGILITY_TOKEN="$AGILITY_TOKEN" npx @agility/cli@1.2.1 pull \
  --sourceGuid="$AGILITY_GUID" --elements="Models" --headless
```

## Exit behavior

- Exits `0` when every part of the download succeeded, and `1` when any part failed.
- In 1.2.1, if sign-in fails or a required setting is missing, `pull` stops without setting a failing exit code. In a pipeline, check that the files you need exist before using them, for example `test -n "$(ls agility-files/$AGILITY_GUID/models/*.json)"`.

## Related

- [sync and push](/docs/developers/cli-sync): copy one instance into another
- [verify](/docs/developers/cli-verify): compare a synced target with its source
- [Agility CLI](/docs/developers/cli): concepts, mappings and troubleshooting
- [Test Your Agility Integration in CI](/docs/developers/test-agility-integration-in-ci): use a models-only pull to catch model drift

---

## Related pages

- [Content Fetch API](https://agilitycms.com/docs/developers/content-fetch-api.md)
- [Content Sync API](https://agilitycms.com/docs/developers/content-sync-api.md)
- [Content Management API](https://agilitycms.com/docs/developers/content-management-api.md)
- [GraphQL API](https://agilitycms.com/docs/developers/graphql-api.md)
- [CLI - CI/CD Integration Guide](https://agilitycms.com/docs/developers/cli-ci-cd-integration-guide.md)
- [Testing on Swagger](https://agilitycms.com/docs/developers/testing-on-swagger.md)
- [GraphQL & Rest API Filtering](https://agilitycms.com/docs/developers/graphql-operators.md)
- [AgilityCLI (Command Line Interface)](https://agilitycms.com/docs/developers/cli.md)
- [Personal Access Tokens](https://agilitycms.com/docs/developers/personal-access-tokens.md)
- [Content Delivery & CDN Architecture](https://agilitycms.com/docs/developers/content-delivery-and-cdn-architecture.md)
- [Typed GraphQL with TypeScript and Next.js](https://agilitycms.com/docs/developers/typed-graphql-typescript-nextjs.md)
- [Image Transformation Reference](https://agilitycms.com/docs/developers/image-transformation-reference.md)
- [Fetch API Status Codes and Caching](https://agilitycms.com/docs/developers/fetch-api-status-codes-and-caching.md)
- [Field Types and What the APIs Return](https://agilitycms.com/docs/developers/field-types-api-reference.md)
- [Content Sync Explained](https://agilitycms.com/docs/developers/content-sync-explained.md)
- [Agility CLI Command Reference](https://agilitycms.com/docs/developers/cli-reference.md)
- [CLI Reference: agility sync and push](https://agilitycms.com/docs/developers/cli-sync.md)
- [CLI Reference: agility reverse-sync](https://agilitycms.com/docs/developers/cli-reverse-sync.md)
- [CLI Reference: agility workflows](https://agilitycms.com/docs/developers/cli-workflows.md)
- [CLI Reference: agility login and logout](https://agilitycms.com/docs/developers/cli-login-logout.md)
- [Test Your Agility Integration in CI](https://agilitycms.com/docs/developers/test-agility-integration-in-ci.md)
- [CLI Reference: agility verify](https://agilitycms.com/docs/developers/cli-verify.md)
- [Create a Personal Access Token](https://agilitycms.com/docs/developers/create-personal-access-token.md)

Index of every docs page: https://agilitycms.com/docs/llms.txt
