# Content Sync API

> Source: https://agilitycms.com/docs/developers/content-sync-api

The Content Sync API makes it easy to keep a content cache or copy of Agility content so it can be readily accessible to your digital solution without calling home to Agility.

## Use Cases

- You need to support an offline mode and access content without making an API call to Agility.
- You want to reduce the amount of REST API calls made to Agility.
- You want so synchronize content from the CMS to another system such Redis Cache.
- You are running a Server-Side Rendered (SSR)web app and you want to cache your content locally, reducing latency for retrieving content.
- You are using a Static Site Generator (SSG) and you don't want to have to re-source all of your content on each build.
- You have a client-side Single Page Application, and want to cache content in local storage in the browser.

## How it Works

The Sync API endpoint is part of the Content Fetch API and is available for all customers.

These are the general steps a developer would need to synchronize content from Agility CMS to another system.

**Step one**: Setup a Webhook in Agility so that you can be notified when changes to our CMS are made.

**Step two**: When a webhook request is received, make a call to the Sync API :

```
curl -X GET "https://api.aglty.io/4582b5fa-u/fetch/en-us/sync/items?syncToken=0&pageSize=500" -H "accept: application/json" -H "APIKey: xxxxxxxxxx"
```

Your first call to the API will have a `syncToken` of `0`. 

The above call will return all content from the CMS in a paginated manner (up to 500 items per request by default; set `pageSize` to change it), and provide the next `syncToken` to use.

**Step three**: Save the results into a local filesystem, database, or Redis Cache

**Step four**: Continue to query to the Sync API until no results are returned or `syncToken=0`- this means you are up to date.

**Step five:** Store the last `syncToken` you had, so that the next time you call the API you'll get the content that has changed since your last `syncToken`

## Using a Sync SDK

Agility CMS provides a JS SDK to handle syncing and managing for your sync token as well as providing interfaces for storing and accessing previously synced content.

[Sync Content using the JS SDK](https://agilitycms.com/docs/javascript/content-sync-js-sdk)

---

## Related pages

- [Content Fetch API](https://agilitycms.com/docs/developers/content-fetch-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 pull](https://agilitycms.com/docs/developers/cli-pull.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
