Skip to main content
All changes are tracked on the BSV blockchain for complete audit trail and transparency.
Category updates create new blockchain transactions for traceability. You can modify name, description, status, and image.

Endpoint

curl -X PUT "https://api.g2cplatform.com/api/v2/object/{COMPANY_ID}/category/{CATEGORY_ID}" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F "name=Electronics Updated" \
  -F "action=CHANGE" \
  -F "description=Updated electronic devices category" \
  -F "file=@new_category_image.jpg"

Request

HTTP Method

PUT

URL

https://api.g2cplatform.com/api/v2/object/{COMPANY_ID}/category/{CATEGORY_ID}

Path Parameters

ParameterTypeRequiredDescription
COMPANY_IDstring (UUID)Company identifier
CATEGORY_IDstring (UUID)Category identifier

Headers

X-API-Key: YOUR_API_KEY
Content-Type: multipart/form-data

Request Body (multipart/form-data)

FieldTypeRequiredDescription
namestringUpdated category name
actionstringUpdate action type
descriptionstringUpdated description (max 2048 chars)
filefileNew category image file

Update Actions

ActionDescription
CHANGEChange category name/description
ACTIVATEActivate a deactivated category
DEACTIVATEDeactivate category (no new objects)
REMOVERemove category and all data

Response

Success Response (200)

{
  "status": "success",
  "data": {
    "imageId": "img_new_1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p"
  },
  "changes": {
    "name": {
      "from": "Electronics",
      "to": "Electronics Updated"
    },
    "description": {
      "from": "Electronic devices and components",
      "to": "Updated electronic devices category"
    },
    "imageId": {
      "from": "img_old_123",
      "to": "img_new_1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p"
    }
  },
  "timestamp": "2025-08-02T10:30:00Z"
}

Error Responses

400 Bad Request

{
  "error": "Invalid update action",
  "code": "INVALID_ACTION",
  "details": {
    "action": ["Action must be one of: CHANGE, ACTIVATE, DEACTIVATE, REMOVE"]
  },
  "timestamp": "2025-08-02T10:30:00Z"
}

404 Not Found

{
  "error": "Category not found",
  "code": "CATEGORY_NOT_FOUND",
  "timestamp": "2025-08-02T10:30:00Z"
}

409 Conflict

{
  "error": "Category name already exists",
  "code": "CATEGORY_NAME_EXISTS",
  "timestamp": "2025-08-02T10:30:00Z"
}

Update Examples

Change Category Information

async function updateCategoryInfo(companyId, categoryId, name, description) {
  const formData = new FormData();
  formData.append('name', name);
  formData.append('action', 'CHANGE');
  formData.append('description', description);

  const response = await fetch(
    `https://api.g2cplatform.com/api/v2/object/${companyId}/category/${categoryId}`,
    {
      method: 'PUT',
      headers: { 'X-API-Key': 'YOUR_API_KEY' },
      body: formData
    }
  );

  return response.json();
}

Update Category Image

async function updateCategoryImage(companyId, categoryId, imageFile) {
  const formData = new FormData();
  formData.append('name', 'Current Name'); // Name is required
  formData.append('action', 'CHANGE');
  formData.append('file', imageFile);

  const response = await fetch(
    `https://api.g2cplatform.com/api/v2/object/${companyId}/category/${categoryId}`,
    {
      method: 'PUT',
      headers: { 'X-API-Key': 'YOUR_API_KEY' },
      body: formData
    }
  );

  return response.json();
}

Deactivate Category

async function deactivateCategory(companyId, categoryId, name) {
  const formData = new FormData();
  formData.append('name', name);
  formData.append('action', 'DEACTIVATE');

  const response = await fetch(
    `https://api.g2cplatform.com/api/v2/object/${companyId}/category/${categoryId}`,
    {
      method: 'PUT',
      headers: { 'X-API-Key': 'YOUR_API_KEY' },
      body: formData
    }
  );

  return response.json();
}

Action Types Explained

Purpose: Modify category name, description, or image Impact:
  • Updates category metadata
  • Preserves all subcategories and objects
  • Creates audit trail on blockchain Usage: Regular updates and improvements
Purpose: Reactivate a previously deactivated category Impact:
  • Changes status from delisted to active
  • Allows new object creation again
  • Restores full functionality Usage: Restore categories after temporary deactivation
Purpose: Temporarily disable a category Impact:
  • Changes status to delisted
  • Prevents new object creation
  • Existing objects remain accessible Usage: Temporary suspension or deprecation
Purpose: Permanently delete category and all data Impact:
  • Deletes category, subcategories, and all objects
  • Removes all associated files
  • Creates deletion record on blockchain Usage: Complete cleanup (irreversible)

Best Practices

  • Always provide the current name when updating
  • Test changes in staging environment first
  • Backup important data before REMOVE actions
  • Use DEACTIVATE instead of REMOVE when possible
  • Optimize images before upload (under 1MB recommended)
  • Use consistent aspect ratios
  • Keep backup of original images
  • Consider impact on existing UI layouts
  • Document reasons for category changes
  • Notify users of significant changes
  • Plan updates during low-usage periods
  • Monitor system after major changes

Next Steps