This guide explains how to use Crystallize Mass Operations to import customers and orders at scale. Mass Operations allow you to perform thousands of actions—like creating customers and registering historical orders—using a single declarative JSON file.
You can find the raw JSON examples here:
The customer/upsert intent is the most efficient way to import customer data because it is idempotent: it creates the customer if they don't exist and updates them if they do.
identifier: A unique string to identify the customer (usually an email or an ID from your legacy system).type: Either individual or organization.firstName / lastName: The persona details.addresses: An array containing billing and shipping objects.middleName / companyName: Optional metadata.Example Operation:
{
"intent": "customer/upsert",
"identifier": "customer-123",
"firstName": "Jane",
"lastName": "Doe",
"email": "jane.doe@example.com",
"type": "individual",
"addresses": [
{
"type": "billing",
"street": "123 Commerce St",
"city": "Oslo",
"country": "Norway"
}
]
}
{
"intent": "customer/upsert",
"identifier": "customer-123",
"firstName": "Jane",
"lastName": "Doe",
"email": "jane.doe@example.com",
"type": "individual",
"addresses": [
{
"type": "billing",
"street": "123 Commerce St",
"city": "Oslo",
"country": "Norway"
}
]
}
Importing orders usually involves either registering a new order intent or upserting historical order data.
order/register: Used for active orders where you want Crystallize to handle the standard order logic.order/upsert: Best for migrating legacy data where you need to preserve original IDs and timestamps.sku, name, quantity, and price.identifier.Example Operation:
{
"intent": "order/upsert",
"customer": {
"identifier": "customer-123"
},
"cart": [
{
"sku": "product-sku-1",
"name": "Eco-friendly Chair",
"quantity": 1,
"price": {
"gross": 150,
"net": 120,
"currency": "EUR"
}
}
],
"total": {
"gross": 150,
"net": 120,
"currency": "EUR"
},
"payment": [
{
"provider": "stripe",
"stripe": {
"orderId": "ch_12345"
}
}
]
}{
"intent": "order/upsert",
"customer": {
"identifier": "customer-123"
},
"cart": [
{
"sku": "product-sku-1",
"name": "Eco-friendly Chair",
"quantity": 1,
"price": {
"gross": 150,
"net": 120,
"currency": "EUR"
}
}
],
"total": {
"gross": 150,
"net": 120,
"currency": "EUR"
},
"payment": [
{
"provider": "stripe",
"stripe": {
"orderId": "ch_12345"
}
}
]
}One of the most powerful features of Mass Operations is the ability to use _ref. This allows you to create a customer and immediately reference them in an order within the same file.
{
"version": "0.0.1",
"operations": [
{
"_ref": "newCustomer",
"intent": "customer/upsert",
"identifier": "jane-doe-ref",
"firstName": "Jane"
},
{
"intent": "order/upsert",
"customer": {
"identifier": "{{ newCustomer.identifier }}"
},
"cart": [...]
}
]
}
{
"version": "0.0.1",
"operations": [
{
"_ref": "newCustomer",
"intent": "customer/upsert",
"identifier": "jane-doe-ref",
"firstName": "Jane"
},
{
"intent": "order/upsert",
"customer": {
"identifier": "{{ newCustomer.identifier }}"
},
"cart": [...]
}
]
}
upsert over create. This allows you to re-run the same file if a network error occurs without creating duplicate records.operationLogs query if a task shows as "Complete with errors" to see exactly which SKU or Customer ID caused the issue.