Importing Recipients and Orders
Import recipients into a group and synchronize their order positions. See the API Explorer for available endpoints and parameters.
Prerequisites
Connect the customer's account using the Authorization Code flow in the Authentication guide. Request the Recipients scope (oa_receivers) for groups, recipients, attributes, and orders.
1. Prepare a Group and Global Attributes
Recipients belong to a group. List groups and let the customer choose one, or create a group. Store its group_id for subsequent requests.
Create any global attributes before importing recipients. Attribute names must exist, and their types must match your values. Supported types are text, number, gender, and date.
Use GET /attributes to list global attributes and POST /attributes to create them. Do not pass a group_id when creating an attribute.
2. Import Recipients
Choose the endpoint that matches your synchronization strategy:
| Endpoint | Behavior |
|---|---|
POST /groups/{group_id}/receivers/upsert | Create a recipient if its email is new to the group; otherwise update it. |
POST /groups/{group_id}/receivers/upsertplus | Upsert recipients and add or remove tags. It can also increment or decrement numeric global attributes. |
POST /groups/{group_id}/receivers/insert | Insert new recipients; do not use for updating existing data. |
PUT /groups/{group_id}/receivers/update | Update existing recipients; unknown recipients are skipped. |
For large imports, use batches of around 500 recipients. This is a practical starting point: smaller requests are easier to monitor and retry, and less likely to time out.
Track each recipient against its source record and save the per-recipient results after each response so the import can resume safely.
This example creates a new, inactive recipient. It assumes firstname is a global attribute.
POST https://rest.cleverreach.com/v3/groups/{group_id}/receivers/upsert
Authorization: Bearer <access_token>
Content-Type: application/json
[
{
"email": "alex@example.org",
"source": "My Shop",
"registered": 1700000000,
"activated": 0,
"global_attributes": {
"firstname": "Alex"
},
"tags": ["shop.customer"]
}
]
For a new recipient awaiting confirmation, send registered with a Unix timestamp and activated: 0, then follow the Double Opt-In guide. An activation timestamp in activated activates the recipient immediately.
If you omit registered, activated, and deactivated, a new recipient can be created as active. For existing recipients, omit status fields unless you intend to change the status. In particular, deactivated: 0 can reactivate a recipient.
3. Import Order Positions
An order is stored as one or more positions associated with a recipient:
| Method | Endpoint | Use |
|---|---|---|
| Batch | orders array in a recipient upsert | Import order positions together with recipient data. |
| Single position | POST /receivers/{pool_id}/orders or POST /groups/{group_id}/receivers/{pool_id}/orders | Add an order position for an existing recipient. |
{pool_id} is the recipient ID or email address. To read order positions, use the corresponding global or group-specific GET endpoint.
Add an orders array to a recipient object in the upsert request:
{
"email": "alex@example.org",
"orders": [
{
"order_id": "shop-order-123",
"product": "Example product",
"product_id": "sku-456",
"price": 9.99,
"quantity": 2,
"currency": "EUR",
"stamp": 1700000000,
"source": "My Shop"
}
]
}
| Field | Required | Description |
|---|---|---|
order_id | Yes | Your external order ID. Update and delete endpoints use the API's internal ID. |
product | Yes | Product name. |
product_id | No | Your product or SKU ID. |
price | No | Price per item; defaults to 0. |
quantity | No | Number of items; defaults to 1. |
currency | No | Currency code; defaults to EUR. |
stamp | No | Order time as a Unix timestamp; defaults to the current time. |
mailing_id | No | Mailing ID for conversion tracking. |
source | No | Shop or other source name. |
4. Check Results and Synchronize
Batches can partially succeed. Inspect each recipient's result, including any log entries, and retry only entries reported as failed after correcting their data. If a timeout leaves the outcome unclear, reconcile the affected data before resending it. The API does not guarantee duplicate prevention for order positions, so do not blindly retry uncertain order imports.
Read recipient data with GET /groups/{group_id}/receivers or GET /groups/{group_id}/receivers/{pool_id}. The list endpoint supports status, email, and ID filters, and uses zero-based page and pagesize pagination. For large lists, use last_id to fetch recipients with a higher ID, ordered by ID; page is ignored in this mode. Continue with the last ID returned until the response is empty.
Optional: Webhooks
Subscribe to recipient events to learn about changes made in CleverReach. Webhook registration requires the Webhook scope (oa_webhooks); recipient API calls still require oa_receivers. See Configure Webhooks.