Add New Product Unit
Registers equipment the customer already owns as a product unit located at one of their addresses.
/api/integration/customer/add-new-product-unit'Request
curl -X POST "https://uat.integration.cl.sodtrack-shared.sodtrack.com/api/integration/customer/add-new-product-unit'" \
-H "Authorization: Bearer $SODTRACK_TOKEN"Base URL: https://uat.integration.cl.sodtrack-shared.sodtrack.com Β· other environments
Responses
{
"productUnit": {
"id": 9871,
"serialNumber": "7788001122336"
}
}Error responses for this endpoint follow the shared error reference.
Purpose
Registers equipment the customer already owns as a product unit located at one of their addresses.
Use it when your system detects an installed asset that Sodtrack does not know yet (for example, a pool the provider finds while executing a repair) and you need it tracked before putting it under a maintenance plan.
The unit is identified by product (productSku or productId) and placed at an address (addressId). The unit's owner is derived from the address: Sodtrack resolves the customer associated with it, so you do not send a customer identifier. The serial number is generated by Sodtrack and returned in the response.
This endpoint only creates the unit. To start its maintenance cycle, call Start Maintenance Plan afterwards with the returned productUnit.id.
Field Definitions
π¦ Product
| Field | Type | Required | Description |
|---|---|---|---|
product | object | β | Selector of the catalog product the unit is an instance of. |
product.type | string | β | How the product is referenced. One of productSku, productId. |
product.value | string | β | Value matching product.type: the product SKU, or the Sodtrack product ID as a string. |
productSerialNumber is not accepted here: this endpoint creates the unit, so it has no serial number to be identified by yet.
π Address
| Field | Type | Required | Description |
|---|---|---|---|
address | object | β | Customer address where the unit stays. The unit's owner is derived from it. |
address.type | string | β | How the address is referenced. Only addressId is currently supported; addressReference is reserved for future use. |
address.value | string | β | Sodtrack address ID as a string. Must be a positive integer. |
The address must belong to a customer and have a customer associated. Provider or sales channel addresses are rejected. To obtain valid address IDs for a customer, use Get Customer.
Example Request (by product SKU)
{
"product": {
"type": "productSku",
"value": "SKU-PISCINA-001"
},
"address": {
"type": "addressId",
"value": "12345"
}
}
Example Request (by product ID)
{
"product": {
"type": "productId",
"value": "87"
},
"address": {
"type": "addressId",
"value": "12345"
}
}
Response Example
200 OK
{
"productUnit": {
"id": 9871,
"serialNumber": "7788001122336"
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
productUnit | object | The product unit created for the customer. |
productUnit.id | number | Unique Sodtrack product unit ID. Use it as productUnit.value when starting the maintenance plan. |
productUnit.serialNumber | string | Serial number generated for the unit by Sodtrack. Format is EAN-13: 13 numeric digits, the last one a check digit. |
Error Responses
| HTTP Status | Error | Description |
|---|---|---|
400 Bad Request | ADDRESS_REFERENCE_NOT_SUPPORTED | address.type was sent as addressReference. Resolution by external address reference is not yet supported; use addressId. |
400 Bad Request | Invalid addressId: {value} | address.value is not a positive integer. |
400 Bad Request | Address {id} not found | No Sodtrack address exists with that ID. |
400 Bad Request | Address {id} is not a customer address | The address exists but is not associated to a customer entity. |
400 Bad Request | Address {id} has no customer associated | The address is a customer address but has no customer linked to it. |
400 Bad Request | Invalid productId: {value} | product.value is not a positive integer when product.type is productId. |
400 Bad Request | Product not found in the product module: sku={value} | No catalog product matches the given SKU. |
400 Bad Request | (validation messages) | One or more fields are missing or invalid. The body carries message as an array of strings, one per failed validation. |
406 Not Acceptable | PRODUCT_UNIT.SERIAL_NUMBER_ALREADY_IN_USE | The generated serial number collided with an existing one. Rare; retry the request. |
4xx | (forwarded) | Any other rejection from the product module. The original status and message are forwarded as-is. |
401 Unauthorized | β | Authentication token missing or expired. |
403 Forbidden | β | The API key or origin is not authorized. |
502 Bad Gateway | Error in createProductUnitForCustomer: {message} | The product module is unavailable or failed. Safe to retry. |
500 Internal Server Error | β | Unexpected server error. Contact Sodtrack support. |
Business Rules & Constraints
Product resolution
-
When
product.typeisproductSku, the SKU is resolved against the product catalog. If no product matches exactly, the request fails withProduct not found in the product module. -
When
product.typeisproductId, the value is used directly and must be a positive integer; it is not verified against the catalog before the unit is created, so an unknown ID surfaces as a rejection forwarded from the product module. -
productSerialNumberis not a validproduct.typefor this endpoint.
Address and ownership
-
Only
addressIdresolves today. TheaddressReferencetype exists in the contract but fails explicitly instead of being silently ignored, because Sodtrack addresses have no external reference field yet. -
The customer is derived from the address, never sent by the caller: the address must be a customer address with a customer associated, or the request fails.
-
The address is stored on the unit as a plain reference; changing the customer's address later does not move the unit.
Unit creation
-
The serial number is generated by Sodtrack as an EAN-13 code (13 digits with check digit); it cannot be supplied by the caller.
-
Every call creates a new unit. There is no idempotency key: repeating the same request registers the same equipment twice.
-
The unit is created with no maintenance cycle. Starting it is a separate call to Start Maintenance Plan.
Errors and retries
- Failures are not swallowed: a
4xxmeans nothing was created and the request should be corrected, while a502means the product module failed and the call can be retried.
Data and format
-
All identifiers are sent as strings inside the
{ type, value }selectors, even when they are numeric IDs. -
All timestamps follow the ISO 8601 format (UTC) where applicable.