v1.0.0
OpenAPI 3.1.0

Sync a collection from a source

US region

Client Libraries

Sync a collection from a source

​

Watch a folder in one of your collection sources, and have Customer.io load each new file in the folder into the collection. Customer.io saves and deletes rows by key, the same way as a write operation, so the collection needs a key field. A collection can have exactly one sync.

Each time Customer.io checks the folder, it loads new files in alphabetical order of their paths, up to 2,000 files at a time. Customer.io remembers the last file it loaded and only loads files whose paths sort after it. Name your files so that newer files sort later, like by starting each name with the date (2026-11-03-products.csv). Customer.io never loads a file whose path sorts before the last file it loaded, or a file that you overwrite at a path it already loaded. To send changed rows, write a new file.

Customer.io checks each file before it saves any of the file's rows. Customer.io loads the valid rows and records rejected rows, which you can look up with list rejected sync rows. If two rows in a file have the same key, Customer.io loads the first one and rejects the second. If Customer.io can't load a whole file, like when the file is too large or isn't JSON or CSV, the sync's state becomes failed, and Customer.io tries that file again at each later check. To get the sync going again, overwrite the file with one that Customer.io can load, or delete the file.

To change a sync, send it again. If you change only poll_hours, the sync keeps its place. If you change the source or the prefix, the sync starts over from the first file in the folder.

Path Parameters
  • collection_id
    Type: integer
    required

    The identifier for a collection.

Body
application/json
  • source_id
    Type: string
    required

    The id of the source to read files from.

  • poll_hours
    Type: integer
    min:  
    1
    max:  
    24

    How often Customer.io checks the folder for new files, in hours.

  • prefix
    Type: string
    max length:  
    1024

    The folder to watch, relative to the source's own prefix, like daily/. Customer.io adds a trailing / if you leave it off. Leave out prefix to watch every file the source can read. The folder can't leave the source's prefix, so it can't contain .. or \.

Responses
  • application/json
  • 400

    Your plan doesn't include collections.

  • 404

    The collection id does not exist.

  • 422

    Customer.io couldn't accept the sync, like when the collection has no key field or the source doesn't exist.

  • application/json
Request Example for put/v1/collections/{collection_id}/sync
{
  "source_id": "01JD8X4Q6R2W7N3K5M9P1T0VZC",
  "poll_hours": 1,
  "prefix": "daily/"
}
{
  "sync": {
    "collection_id": 12,
    "created_at": "2026-11-02T15:00:00Z",
    "last_error": {
      "at": "2026-11-02T15:31:31Z",
      "message": "could not read daily/2026-11-02.csv: fetch failed: HTTP 403 status"
    },
    "last_file": {
      "applied_at": "2026-11-02T15:31:31Z",
      "path": "daily/2026-11-02.csv",
      "version": "1793630000123456"
    },
    "next_run_at": "2026-11-02T16:31:31Z",
    "poll_hours": 1,
    "prefix": "daily/",
    "source_id": "01JD8X4Q6R2W7N3K5M9P1T0VZC",
    "state": "active",
    "updated_at": "2026-11-02T15:31:31Z"
  }
}