Batch
This endpoint allows you to send a batch of actions for processing contacts.
Batch
POST
https://api.carts.guru/contacts/v1/batch
Headers
Name
Type
Description
authorization
string
See Authorization page for example.
Request Body
Name
Type
Description
actions
array
An array of actions matching the sample objects below which contain either a delete, create, or update property.
{
data: {
batchId: "1234asdf1234"
}
}
{
errors: [
"siteId" is required,
"optoutEmail" must be a boolean
]
}
{
errors: [
status: 401,
message: 'UNAUTHORIZED'
]
}
Authorized Actions
{
"actions": [
{
"create": {
// At least one of the three identifiers is REQUIRED
// email, phoneNumber, accountId
email: String // The contact's email
phoneNumber: String // The contact's phone number
accountId: String //The contact's accountId on your platform
firstname: Optional (String) // The contact's first name
lastname: Optional (String) // The contact's last name
optoutEmail: Optional (Boolean) // true if they are opted out.
optoutSms: Optional (Boolean) // true if they are opted out.
addresses: Optional (Array of Objects) - Addresses of the contact.
ex:
[
{
title
line1
line2
city
zipcode
country - Required if passing in addresses.
}
]
}
}
]
}
{
actions: [
{
delete: {
// Only one of these three, will error if you provide more than one
email: The contact's email
phoneNumber: The contact's phone number
accountId: The contact's accountId on your platform
}
}
}
At least one of the three identifiers is required:
email
phoneNumber
accountId
{
actions: [{
update: {
email: Identifying (String), // The contact's email
phoneNumber: Identifying (String), // The contact's phone number
accountId: Identifying (String), // The contact's accountId on your platform
firstname: Optional (String), // The contact's first name
lastname: Optional (String), // The contact's last name
optoutEmail: Optional (Boolean), // if they are opted out, false if they are opted in
optoutSms: Optional (Boolean), // if they are opted out, false if they are opted in
addresses: [{ // Addresses of the contact.
// You can pass a list of addresses in
// the following format
title: Optional (String), // The contact's first name
line1: Optional (String),
line2: Optional (String),
city: Optional (String),
zipcode :Optional (String),
country: Require(String)
}
]
}
}]
}
Code samples
import fetch from 'node-fetch'
const res = await fetch(`https://api.carts.guru/contacts/v1/batch`, {
method: 'POST',
headers: {
'content-type': 'application/json',
authorization: 'Basic c8l0ZS0xOjE1ODQwMzc4MTI6Q2wwWHNoVHLaUFdHaDR0ZkZpVkdlbFlaMUxpeDdtdVR6SnBDUndHZlgydz0='
},
body: JSON.stringify({
actions: [
{ delete: { email: 'hi@carts.guru' } },
{ delete: { phoneNumber: '41343432413' } },
{ delete: { accountId: 'accountId-1' } },
{
create: {
phoneNumber: '14158888888',
email: 'bobsburgers@carts.guru',
firstname: 'bob',
lastname: 'burger'
}
},
{
update: {
accountId: '7777777',
email: 'bern777@carts.guru',
phoneNumber: '14157777777',
firstname: 'Bern'
}
}
]
})
})
Last updated