Ecommerce data integration
Sync orders from your ecommerce platform to Subrite with the custom orders API. Covers credentials, authentication, the create or update order endpoint, error codes and best practices.
This guide explains how to integrate your ecommerce platform with Subrite to sync order data. This integration allows you to:
- Sync order history from your platform to Subrite
- Enable order history viewing for members
- Support analytics and segmentation based on order data
Prerequisites#
Before you begin, you'll need:
- A
sourceId: a unique identifier for your integration - A JWT token: for authenticating API requests
- Member IDs from Subrite that match your customers
Contact the Subrite team to obtain these credentials.
API overview#
The Ecommerce Data API allows you to create and update orders in Subrite. Each order must be associated with a valid Subrite member ID.
Base URL#
https://api.subrite.com/Authentication#
All API requests must include the following header:
Authorization: Bearer <your-jwt-token>Endpoints#
Create or update an order#
Creates a new order or updates an existing one in Subrite. If an order with the same sourceId and sourceRef already exists, it will be updated.
POST /api/v1/custom-ordersRequest body#
{
"sourceId": "string", // Required: Your integration's source ID
"sourceRef": "string", // Required: Your platform's order ID
"memberId": "string", // Required: Subrite member ID
"totalPrice": number, // Required: Order total before VAT
"totalPriceVat": number, // Required: Order total including VAT
"currency": "string", // Required: ISO 4217 currency code (ex. NOK, EUR, USD, GBP)
"orderTime": "datetime", // Optional: ISO 8601 datetime format
"items": [ // Required: Array of order items
{
"productId": "string",
"productName": "string",
"categoryId": "string",
"categoryName": "string",
"quantity": number,
"price": number,
"priceVat": number,
"customPropertyValues": {} // Optional: Additional item data (needs setup in Subrite before use)
}
],
"customPropertyValues": {} // Optional: Additional order data (needs setup in Subrite before use)
}Order fields:
| Field | Type | Required | Description |
|---|---|---|---|
sourceId | string | Yes | Your integration's source ID |
sourceRef | string | Yes | Your platform's order ID |
memberId | string | Yes | Subrite member ID |
totalPrice | number | Yes | Order total before VAT |
totalPriceVat | number | Yes | Order total including VAT |
currency | string | Yes | ISO 4217 currency code (for example NOK, EUR, USD, GBP) |
orderTime | datetime | No | ISO 8601 datetime format |
items | array | Yes | Array of order items |
customPropertyValues | object | No | Additional order data (needs setup in Subrite before use) |
Each entry in items has these fields:
| Field | Type |
|---|---|
productId | string |
productName | string |
categoryId | string |
categoryName | string |
quantity | number |
price | number |
priceVat | number |
customPropertyValues | object |
The item customPropertyValues field is optional and holds additional item data. It needs setup in Subrite before use.
Response#
{
"id": "string",
"orderTime": "string",
"memberId": "string",
"sourceId": "string",
"sourceRef": "string",
"totalPrice": number,
"totalPriceVat": number,
"currency": "string",
"customPropertyValues": {},
"items": [
{
"id": "string",
"sequence": number,
"productId": "string",
"productName": "string",
"categoryId": "string",
"categoryName": "string",
"quantity": number,
"price": number,
"priceVat": number,
"customPropertyValues": {}
}
]
}Error handling#
The API uses standard HTTP status codes and returns error details in the response body:
{
"error": {
"code": "string",
"message": "string",
"details": {}
}
}Common error codes:
| Status code | Meaning |
|---|---|
400 | Bad Request: invalid input data |
401 | Unauthorized: invalid or missing authentication |
403 | Forbidden: insufficient permissions |
500 | Internal Server Error |
Best practices#
- Member ID matching: Ensure you have a reliable way to match your customers with Subrite member IDs.
- Order updates: Use the same
sourceRefwhen updating an existing order. - Error handling: Implement proper error handling and retry logic.
- Data validation: Validate all data before sending it to the API.
- Rate limiting: Respect API rate limits and implement appropriate throttling.
Support#
If you need help with the integration, contact the Subrite support team at support@subrite.no.