Skip to main content

Brand Management API

The Brand Management API allows you to manage brand information in the Nilo platform. These endpoints help you create, update, and retrieve brand data, including brand details and status.

Understanding Brands

Brands in Nilo represent the manufacturers or trademark owners of products:

  • Brand Structure

    • Unique internal code for identification
    • Name and image for display
    • Weight for controlling display order
    • Status for enabling/disabling visibility
    • Optional metadata for additional information
  • Brand Hierarchy

    • Independent entities not tied to categories
    • Can be associated with multiple products
    • Maintain their own status and visibility
    • Support batch operations for bulk updates

Important Considerations

  1. Unique Codes: Each brand requires a unique internal code for identification
  2. Image Management: Brand images should follow specific format and size guidelines
  3. Weight System: Controls the order of appearance in listings and searches
  4. Status Control: Brands can be enabled or disabled without deletion
  5. Batch Operations: Support for bulk updates to manage multiple brands efficiently

Single Brand Operations

Create Brand

POST/brand

Create a new brand in the Nilo platform. This endpoint is used to register all brand details including:

  • Brand information (name, internal code)
  • Brand image and weight

Request Body Parameters

ParameterTypeRequiredDescription
namestringYesBrand name
internalCodestringYesBrand code (unique identifier)
weightintegerNoOrder positioning in listings
imagestringNoURL of brand image

Request Body Example

{
"name": "Marca 1",
"internalCode": "1235",
"weight": 1,
"image": "/qa/brand/12442.png"
}

Response Codes

CodeDescription
200Brand created successfully
404Brand not found

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
name: "Marca 1",
internalCode: "1235",
weight: 1,
image: "/qa/brand/12442.png",
};

fetch("https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/brand", {
method: "POST",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Get All Brands

GET/brand

Retrieve a paginated list of all brands. This endpoint is useful for:

  • Browsing through the brand catalog
  • Implementing pagination in your application
  • Filtering brands by enabled status

Query Parameters

ParameterTypeRequiredDescription
takenumberNoNumber of items per page (default: 50, max: 50)
pagestringNoPage number (default: 1)
enabledbooleanNoFilter brands by enabled status (true for active, false for inactive)
cursorstringNoCursor for pagination. First call use 0, then use the cursor from the previous response

Response Example

{
"data": [
{
"name": "Marca 1",
"internalCode": "1235",
"weight": 1,
"image": "/qa/brand/12442.png"
}
],
"page": {
"pageBased": {
"count": 100
},
"cursorBased": {
"hasNextPage": true,
"hasPreviousPage": false,
"firstCursor": "0",
"lastCursor": "49"
}
}
}

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
};

fetch(
"https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/brand?take=10&page=1&enabled=true",
{
method: "GET",
headers: headers,
}
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Upsert Brand

PUT/brand

Create or update a brand in the Nilo platform. This endpoint is useful when you need to:

  • Create a new brand if it doesn't exist
  • Update an existing brand with new information

Request Body Parameters

ParameterTypeRequiredDescription
namestringYesBrand name
internalCodestringYesBrand code (unique identifier)
weightintegerNoOrder positioning in listings
imagestringNoURL of brand image
enabledbooleanYesWhether the brand is active

Request Body Example

{
"name": "Marca 1",
"internalCode": "1235",
"weight": 1,
"image": "/qa/brand/12442.png",
"enabled": true
}

Response Codes

CodeDescription
200Brand upserted successfully
404Brand not found

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
name: "Marca 1",
internalCode: "1235",
weight: 1,
image: "/qa/brand/12442.png",
enabled: true,
};

fetch("https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/brand", {
method: "PUT",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Get Brand Details

GET/brand/{code}

Retrieve detailed information about a specific brand. This endpoint returns:

  • Brand metadata
  • Brand image and weight

Path Parameters

ParameterTypeDescription
codestringBrand internal code (unique identifier)

Response Example

{
"name": "Marca 1",
"internalCode": "1235",
"weight": 1,
"image": "/qa/brand/12442.png"
}

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
};

fetch("https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/brand/1235", {
method: "GET",
headers: headers,
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Update Brand

PUT/brand/{code}

Update an existing brand's information. This endpoint allows you to modify:

  • Brand name
  • Brand image
  • Brand weight for ordering

Path Parameters

ParameterTypeRequiredDescription
codestringYesBrand internal code (unique identifier)

Request Body Parameters

ParameterTypeRequiredDescription
namestringYesBrand name
weightintegerNoOrder positioning in listings
imagestringNoURL of brand image

Request Body Example

{
"name": "Updated Brand Name",
"weight": 2,
"image": "/qa/brand/updated-image.png"
}

Response Codes

CodeDescription
200Brand updated successfully
404Brand not found

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
name: "Updated Brand Name",
weight: 2,
image: "/qa/brand/updated-image.png",
};

fetch("https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/brand/1235", {
method: "PUT",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Change Brand Status

PUT/brand/{code}/status

Update the status of a brand. This endpoint allows you to:

  • Enable/disable a brand

Path Parameters

ParameterTypeRequiredDescription
codestringYesBrand internal code (unique identifier)

Request Body Parameters

ParameterTypeRequiredDescription
enabledbooleanYesWhether the brand should be enabled

Request Body Example

{
"enabled": true
}

Response Codes

CodeDescription
200Status updated successfully
404Brand not found

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
enabled: true,
};

fetch(
"https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/brand/1235/status",
{
method: "PUT",
headers: headers,
body: JSON.stringify(data),
}
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Batch Operations

Batch Upsert Brands

POST/batch/brand

Perform bulk operations on brands. This endpoint allows you to:

  • Upsert multiple brands (update or create if not exists)

The batch operation is processed asynchronously, meaning you'll receive an immediate acknowledgment of the request, and the updates will be processed in the background.

Request Body Parameters

ParameterTypeDescription
upsertarrayArray of brands to update or create if needed

Request Body Example

{
"upsert": [
{
"name": "Marca 1",
"internalCode": "1235",
"weight": 1,
"image": "/qa/brand/12442.png",
"enabled": true
}
]
}

Response Codes

CodeDescription
202Batch request accepted for processing
402Bad request

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
upsert: [
{
name: "Marca 1",
internalCode: "1235",
weight: 1,
image: "/qa/brand/12442.png",
enabled: true,
},
],
};

fetch(
"https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/batch/brand",
{
method: "POST",
headers: headers,
body: JSON.stringify(data),
}
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Best Practices

  1. Brand Management

    • Use consistent naming conventions
    • Maintain high-quality brand images
    • Implement proper status management
    • Keep brand information up to date
  2. Code Structure

    • Create meaningful internal codes
    • Use consistent code patterns
    • Document code conventions
    • Validate codes before use
  3. Image Handling

    • Use optimized image formats
    • Maintain consistent image dimensions
    • Implement image caching
    • Handle image updates efficiently
  4. Performance Optimization

    • Use batch operations for multiple updates
    • Implement proper caching strategies
    • Optimize image delivery
    • Monitor API usage patterns

Common Use Cases

  1. Initial Brand Setup

    • Create brand profiles
    • Upload brand images
    • Set initial weights
    • Configure brand status
  2. Brand Maintenance

    • Update brand information
    • Manage brand visibility
    • Adjust display order
    • Update brand images
  3. Bulk Operations

    • Import multiple brands
    • Update brand statuses
    • Modify brand weights
    • Sync brand data
  4. Brand Integration

    • Connect with product catalog
    • Implement brand filtering
    • Set up brand search
    • Configure brand display

Response Types

Success Response

{
"code": 200,
"message": "Operation successful",
"data": {
"name": "Example Brand",
"internalCode": "BRD-001",
"image": "/brands/example.png",
"enabled": true,
"weight": 1
}
}

Error Response Examples

Not Found

{
"code": 404,
"message": "Brand not found"
}

Validation Error

{
"code": 400,
"message": "Invalid brand data",
"errors": [
{
"field": "internalCode",
"message": "Internal code is required"
}
]
}

Duplicate Error

{
"code": 409,
"message": "Brand with this internal code already exists"
}

Implementation Guidelines

  1. Brand Creation

    • Validate required fields
    • Check for duplicate codes
    • Process brand images
    • Set default values
  2. Brand Updates

    • Verify brand existence
    • Handle partial updates
    • Manage image changes
    • Update timestamps
  3. Status Management

    • Handle status transitions
    • Update related products
    • Maintain audit logs
    • Notify relevant systems
  4. Batch Processing

    • Validate batch data
    • Handle partial failures
    • Implement rollback
    • Report batch results

Security

All API endpoints require two types of authentication:

  1. API Key in header: x-api-key
  2. Authorization token in header: Authorization

Required Permissions

For brand management endpoints, the following permissions are required:

  • For read operations: supplier/brand.read
  • For write operations: supplier/brand.write

Error Handling

  1. Input Validation

    • Validate all required fields
    • Check data types and formats
    • Verify image specifications
    • Validate internal codes
  2. Error Responses

    • Use appropriate HTTP status codes
    • Provide detailed error messages
    • Include field-level errors
    • Add error tracking codes
  3. Recovery Procedures

    • Handle network failures
    • Implement retry logic
    • Maintain data consistency
    • Log error details
  4. Monitoring

    • Track error rates
    • Monitor API performance
    • Alert on critical errors
    • Analyze error patterns