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

# Syncs

> A sync is a connection to an API. Sequin uses a credential to access the API and collections to specify the data you want to sync. The data from your sync is stored in a stream for consumption.

In Sequin, an instance of a connection to an API is called a **sync**. Sequin uses a **credential** (e.g. an access token) to access the API.

Here are some examples of things you can sync:

* A Salesforce account
* A HubSpot sandbox
* A Shopify store
* A Stripe account

<Tip>
  You can create syncs to your API account or to your customers' API accounts.
</Tip>

When you initially start a sync, Sequin backfills the data from the API to the stream. You can configure how far back in time the backfill goes by setting the `max_age_days` parameter.

<ResponseField name="max_age_days" type="integer">
  The maximum age of data from the API that will be backfilled.
</ResponseField>

Once a collection is backfilled, Sequin begins change detection on the data. Inserts, updates, and deletes are detected and published to the stream. This process runs either in real-time or in batch mode.

<ResponseField name="sync_frequency" type="string">
  The frequency at which Sequin will check for changes to the API. `continuous` or `4h`.
</ResponseField>

## Streams

Each sync belongs to a stream. Data from backfills and change-data-capture is stored in a stream for consumption via [consumers](/streams/consume/overview).

```bash theme={null}
curl https://api.sequin.io/v1/http-consumers/{id}/next?batch_size=10
```

```json 200 OK theme={null}
[
  {
    "ack_token": "NjA1",
    "record": {
      "sync_id": "my-sync-id",
      "collection_id" : "stripe:subscription",
      "upstream_id": "sub_tognkns00nj",
      "updated_idx": 2745327037,
      "upstream_created_at": "2024-11-10T18:38:00.070453Z",
      "upstream_updated_at": "2024-11-10T18:38:00.070453Z",
      "data": {
        "id": "sub_tognkns00nj",
        "object": "subscription",
        "billing": "charge_automatically",
        // …
      }
    }
  },
  // ...
]
```

## Management API[](#management-api "Direct link to Management API")

Everything you can do in the Sequin console you can do via Sequin's [Management API](/management-api). This empowers you to write code that starts syncs, manages consumers, or anything else.

You'll use the Management API if you're programmatically connecting to your customers' API accounts. For example, if you're building a product that syncs data from your customers' Salesforce accounts to your app, you'll use the Management API to capture credentials and spin up syncs for each customer.

You can also use the Management API to integrate Sequin into your development and CI/CD workflows.

There's a lot you can do with the Management API. Here's a sampling of some common tasks:

### List syncs[](#list-syncs "Direct link to List syncs")

[List all the syncs](/management-api/syncs/list) in your account:

```shell theme={null}
curl --request GET \
  --url https://api.sequin.io/v1/syncs \
  --header 'Authorization: Bearer <YOUR_API_KEY>'
```

### Add a credential[](#todo "Direct link to Mutate data")

[Add a credential](/management-api/credentials/create) to your account:

```shell theme={null}
curl --request POST \
  --url https://api.sequin.io/v1/credentials \
  --header 'Content-Type: application/json' \
           'Authorization: Bearer <YOUR_API_KEY>' \
  --data '{
    "kind": "stripe_oauth2",
    "access_token": "sk_live_7eC39HqLyjWDarjtT1zdp7dc",
    "oauth_app_id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8",
    "metadata": { "custom_property": 42 }
  }'
```

### Create a sync[](#todo "Direct link to Mutate data")

[Create a new sync](/management-api/syncs/create) using the credential you just created:

```shell theme={null}
curl --request POST
  --url https://api.sequin.io/v1/syncs
  --header 'Content-Type: application/json' \
           'Authorization: Bearer <YOUR_API_KEY>' \
  --data '{
    "provider": "stripe",
    "name": "Choam Corp - Stripe Production",
    "collection_ids": ["stripe:customer", "stripe:invoice"],
    "rate_limit": {
      "allowed_requests": 100,
      "interval": 60,
      "max_concurrent_requests": 0
    },
    "credential_id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8",
    "metadata": { "custom_property": 42 }
  }'
```
