Write to a collection
Queue a change to a collection's rows and get a write id back right away, so large writes don't time out. Customer.io applies writes to a collection one at a time, in the order it receives them. Use look up a collection write to check the result.
Use mode to choose how to change the collection:
replaceremoves every row in the collection and adds the rows you send indataor at aurl. You can set the collection'skey_fieldin the same request.add,upsert,update, anddeletechange only the rows whose keys you send, so the collection needs a key field. Customer.io applies a keyed write all or nothing: if any row in the request is invalid, Customer.io doesn't change any rows.
- Type: integercollection
_id requiredThe identifier for a collection.
- Type: array object[]datarequired
Every row of the collection. This replaces the collection's current rows.
- enummodeconst:replacerequiredvalues
- replace
- Type: stringkey
_field The attribute that holds each row's unique key, like
sku, similar to a primary key in a database table. Set a key field to add, change, delete, or read individual rows without replacing the whole collection. Each row needs a unique, non-empty string or number in this attribute, up to 1,024 bytes.
- application/json
- 404
The collection
iddoes not exist. - 422
Customer.io couldn't accept the write. The response explains what to fix. For a keyed write, each error's
source.pointernames the failed row, like/data/attributes/data/1. - application/json
{
"data": [
{
"sku": "A-100",
"price": 19
},
{
"sku": "A-101",
"price": 24
}
],
"mode": "upsert"
}
{
"write": {
"id": "01JD8X4Q6R2W7N3K5M9P1T0VZC",
"state": "queued"
}
}Customer.io queued the write.