Asset API Reference

Complete API reference for product asset endpoints in Omnium, including CRUD operations and image uploads.

This page documents the public API endpoints for managing product assets in Omnium.

Base URL: /api/products

Authentication: All endpoints require authentication. Read operations require ProductRead access; write operations require ProductAdmin access.


Endpoints Overview

MethodEndpointDescription
GET/Assets/GetAssetsGet assets by IDs
POST/Assets/AddAssets/{skuId}Add assets to a product
POST/Assets/UpdateAssetsUpdate asset metadata
DELETE/Assets/DeleteAssetsDelete assets from products
POST/AddProductImageAdd image from URL (legacy)

Get Assets

Retrieve assets by their IDs.

GET /api/products/Assets/GetAssets?assetIds={id1}&assetIds={id2}

Parameters

ParameterTypeRequiredDescription
assetIdsList<string>YesAsset IDs to retrieve (query parameter array)

Response

[
  {
    "assetId": "product-image-001",
    "url": "https://cdn.example.com/products/image.jpg",
    "externalUrl": "https://supplier.com/original.jpg",
    "fileName": "image.jpg",
    "name": "Product Image",
    "description": "Front view",
    "altText": "Blue shirt front view",
    "purpose": "gallery",
    "sortOrder": 1,
    "isMainImage": true,
    "assetType": "image",
    "contentType": "image/jpeg",
    "length": 245678,
    "created": "2024-01-15T10:30:00Z",
    "modified": "2024-01-15T10:30:00Z"
  }
]

Status Codes

CodeDescription
200Assets found and returned
404No asset IDs provided or assets not found

Add Assets

Add assets to a product. Existing assets with matching asset IDs are replaced.

POST /api/products/Assets/AddAssets/{skuId}?isAddedToVariant={boolean}
Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
skuIdstringYesProduct ID, SKU, or variant SKU
isAddedToVariantboolNoIf true, add to matching variant instead of parent

Request Body

[
  {
    "externalUrl": "https://supplier.com/images/front.jpg",
    "isMainImage": true,
    "altText": "Product front view",
    "sortOrder": 1,
    "purpose": "gallery"
  },
  {
    "externalUrl": "https://supplier.com/images/back.jpg",
    "altText": "Product back view",
    "sortOrder": 2,
    "purpose": "gallery"
  }
]

Asset Fields

FieldTypeDescription
assetIdstringUnique identifier (auto-generated if not provided)
externalUrlstringURL to download and store
isMainImageboolSet as main product image
namestringDisplay name
descriptionstringAsset description
altTextstringAlt text for images
purposestringAsset purpose
sortOrderintDisplay order
propertiesList<PropertyItem>Custom key-value metadata

Status Codes

CodeDescription
200Assets added successfully
404Product or variant not found

Example: Add to Variant

POST /api/products/Assets/AddAssets/SKU-BLUE?isAddedToVariant=true
Content-Type: application/json
 
[
  {
    "externalUrl": "https://supplier.com/blue-variant.jpg",
    "isMainImage": true
  }
]

Update Assets

Update metadata for existing assets without re-uploading files.

POST /api/products/Assets/UpdateAssets
Content-Type: application/json

Request Body

[
  {
    "assetId": "product-image-001",
    "altText": "Updated alt text",
    "description": "Updated description",
    "sortOrder": 2,
    "isMainImage": false
  }
]

Updatable Fields

FieldUpdate Behavior
nameSet to empty string to clear
descriptionSet to empty string to clear
altTextSet to empty string to clear
purposeSet to empty string to clear
sortOrderAny value updates
propertiesEntire list replaced
isMainImageUpdates main image designation
externalUrlNew URL with forceUpload: true triggers re-upload

Status Codes

CodeDescription
200Assets updated successfully
404No asset IDs provided or products not found

Force Re-upload

To re-upload an asset with a new external URL:

[
  {
    "assetId": "product-image-001",
    "externalUrl": "https://new-supplier.com/updated-image.jpg",
    "forceUpload": true
  }
]

Delete Assets

Delete assets from products and storage.

DELETE /api/products/Assets/DeleteAssets?assetIds={id1}&assetIds={id2}

Parameters

ParameterTypeRequiredDescription
assetIdsList<string>YesAsset IDs to delete

Status Codes

CodeDescription
200Assets deleted successfully
400No asset IDs provided
404Products with assets not found

Deleting assets permanently removes files from storage, including preview images. This action cannot be undone.


Add Product Image (Legacy)

Add an image to a product from a URL. This is a simplified endpoint for adding a single image.

POST /api/products/AddProductImage?url={imageUrl}&productId={productId}

Parameters

ParameterTypeRequiredDescription
urlstringYesExternal image URL
productIdstringYesTarget product ID

Behavior

  1. Downloads image from external URL
  2. Uploads to Omnium storage
  3. Adds to product's assets
  4. Sets as main image if first asset

Status Codes

CodeDescription
200Image added successfully
400Could not upload file

Common Use Cases

Add Product with Assets

Include assets when creating or updating a product:

POST /api/products
Content-Type: application/json
 
{
  "productId": "shirt-001",
  "name": "Blue Cotton Shirt",
  "mainImageUrl": "https://supplier.com/shirt-main.jpg",
  "assets": [
    {
      "externalUrl": "https://supplier.com/shirt-main.jpg",
      "isMainImage": true,
      "altText": "Blue shirt front view"
    },
    {
      "externalUrl": "https://supplier.com/shirt-back.jpg",
      "altText": "Blue shirt back view",
      "sortOrder": 2
    }
  ]
}

Replace Main Image

Update an existing asset to become the main image:

POST /api/products/Assets/UpdateAssets
Content-Type: application/json
 
[
  {
    "assetId": "product-image-002",
    "isMainImage": true
  }
]

Bulk Asset Update

Update multiple assets across products:

POST /api/products/Assets/UpdateAssets
Content-Type: application/json
 
[
  {
    "assetId": "product-image-001",
    "altText": "Updated alt text 1",
    "purpose": "hero"
  },
  {
    "assetId": "product-image-002",
    "altText": "Updated alt text 2",
    "purpose": "thumbnail"
  }
]

Error Handling

All endpoints return standard HTTP status codes. Error responses include a message:

{
  "message": "Products with asset ids not found"
}
StatusDescription
400Bad Request - Invalid parameters
401Unauthorized - Missing or invalid authentication
403Forbidden - Insufficient permissions
404Not Found - Asset or product doesn't exist
500Server Error - Internal error, retry later

Business Customer Assets

Assets can also be attached to business customers. These endpoints follow a similar pattern:

MethodEndpointDescription
GET/api/BusinessCustomer/{id}/Assets/GetAssetsGet customer assets
POST/api/BusinessCustomer/{id}/Assets/AddAssetAdd asset from stream
POST/api/BusinessCustomer/{id}/Assets/AddAssetsAdd multiple assets
POST/api/BusinessCustomer/{id}/Assets/UpdateAssetsUpdate customer assets
DELETE/api/BusinessCustomer/{id}/Assets/DeleteAssetsDelete customer assets

Add Asset from Binary Stream

Upload a file directly as binary data:

POST /api/BusinessCustomer/{businessCustomerId}/Assets/AddAsset?fileName=document.pdf
Content-Type: application/octet-stream
 
[binary file data]

This endpoint accepts raw binary data in the request body, useful for:

  • Browser file uploads
  • Programmatic file creation
  • Integration with external systems