Create Product Unit
Create a new product unit in the system. Product units represent individual instances of products that can be tracked and managed independently.
π Request Structureβ
Required Fieldsβ
- Either
productId
ORproductExternalId
must be provided (not both)productId
: Internal product IDproductExternalId
: External product ID
Optional Fieldsβ
description
- Description of the product unitexternalId
- External identifier for the product unitproductVariantId
- ID of a specific product variantextraFields
- Additional fields as key-value pairsimages
- Array of image URLs for the product unitdisabled
- Whether the unit is disabled (default: false)tags
- Tags associated with the product unituserGroupId
- UUID of the user group to associate with the unit
π Field Interpretationβ
- URLs in
images
must be valid HTTPS URLs externalId
must follow title string formattags
must be an array of title stringsuserGroupId
must be a valid UUIDdisabled
defaults to false if not providedextraFields
accepts any key-value pairs
π€ Request Formatβ
POST /api/v1/units
Content-Type: application/json
Authorization: ONLIVESITE Credential:ONLIVEAccessKeyId, Signature=CalculatedSignature
{
"productId": "PROD-12345",
"description": "A high-quality wireless mouse",
"externalId": "EXT-UNIT-12345",
"productVariantId": "VARIANT-001",
"images": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"disabled": false,
"tags": ["electronics", "wireless", "mouse"],
"extraFields": {
"color": "red",
"size": "L"
},
"userGroupId": "550e8400-e29b-41d4-a716-446655440000"
}
π₯ Response Formatβ
Success Responseβ
HTTP/1.1 201 Created
Content-Type: application/json
{
"externalId": "EXT-UNIT-12345",
"productId": "PROD-12345",
"productVariantId": "VARIANT-001",
"productExternalId": null,
"description": "A high-quality wireless mouse",
"images": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"organizationId": "123e4567-e89b-12d3-a456-426614174000",
"disabled": false,
"userGroupId": "550e8400-e29b-41d4-a716-446655440000",
"extraFields": {
"color": "red",
"size": "L"
}
}
Error Responsesβ
Invalid Request (400 Bad Request)β
{
"statusCode": 400,
"message": "Invalid input",
"errors": [
{
"field": "productId",
"message": "Either productId or productExternalId must be provided"
}
]
}
Authentication Error (401 Unauthorized)β
{
"statusCode": 401,
"message": "Invalid or missing authorization credentials"
}
Product Not Found (404 Not Found)β
{
"statusCode": 404,
"message": "Referenced product does not exist"
}