Add New Product Unit

Registers equipment the customer already owns as a product unit located at one of their addresses.

POST/api/integration/customer/add-new-product-unit'

Request

cURL
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

Add New Product Unit
{
  "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

FieldTypeRequiredDescription
productobjectβœ…Selector of the catalog product the unit is an instance of.
product.typestringβœ…How the product is referenced. One of productSku, productId.
product.valuestringβœ…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

FieldTypeRequiredDescription
addressobjectβœ…Customer address where the unit stays. The unit's owner is derived from it.
address.typestringβœ…How the address is referenced. Only addressId is currently supported; addressReference is reserved for future use.
address.valuestringβœ…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)

code
{
  "product": {
    "type": "productSku",
    "value": "SKU-PISCINA-001"
  },
  "address": {
    "type": "addressId",
    "value": "12345"
  }
}

Example Request (by product ID)

code
{
  "product": {
    "type": "productId",
    "value": "87"
  },
  "address": {
    "type": "addressId",
    "value": "12345"
  }
}

Response Example

200 OK

code
{
  "productUnit": {
    "id": 9871,
    "serialNumber": "7788001122336"
  }
}

Response Fields

FieldTypeDescription
productUnitobjectThe product unit created for the customer.
productUnit.idnumberUnique Sodtrack product unit ID. Use it as productUnit.value when starting the maintenance plan.
productUnit.serialNumberstringSerial number generated for the unit by Sodtrack. Format is EAN-13: 13 numeric digits, the last one a check digit.

Error Responses

HTTP StatusErrorDescription
400 Bad RequestADDRESS_REFERENCE_NOT_SUPPORTEDaddress.type was sent as addressReference. Resolution by external address reference is not yet supported; use addressId.
400 Bad RequestInvalid addressId: {value}address.value is not a positive integer.
400 Bad RequestAddress {id} not foundNo Sodtrack address exists with that ID.
400 Bad RequestAddress {id} is not a customer addressThe address exists but is not associated to a customer entity.
400 Bad RequestAddress {id} has no customer associatedThe address is a customer address but has no customer linked to it.
400 Bad RequestInvalid productId: {value}product.value is not a positive integer when product.type is productId.
400 Bad RequestProduct 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 AcceptablePRODUCT_UNIT.SERIAL_NUMBER_ALREADY_IN_USEThe 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 GatewayError 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.type is productSku, the SKU is resolved against the product catalog. If no product matches exactly, the request fails with Product not found in the product module.

  • When product.type is productId, 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.

  • productSerialNumber is not a valid product.type for this endpoint.

Address and ownership

  • Only addressId resolves today. The addressReference type 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 4xx means nothing was created and the request should be corrected, while a 502 means 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.