Skip to main content
All changes are tracked on the BSV blockchain for complete audit trail and transparency.
Subcategory 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}/subcategory/{SUBCATEGORY_ID}" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F "name=Smartphones Updated" \
  -F "action=CHANGE" \
  -F "description=Updated mobile devices subcategory" \
  -F "file=@new_subcategory_image.jpg"

Request

HTTP Method

PUT

URL

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

Path Parameters

ParameterTypeRequiredDescription
COMPANY_IDstring (UUID)Company identifier
CATEGORY_IDstring (UUID)Parent category identifier
SUBCATEGORY_IDstring (UUID)Subcategory identifier

Headers

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

Request Body (multipart/form-data)

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

Update Actions

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

Response

Success Response (200)

{
  "status": "success",
  "data": {
    "imageId": "img_new_2b3c4d5e-6f7g-8h9i-0j1k-2l3m4n5o6p7q"
  },
  "changes": {
    "name": {
      "from": "Smartphones",
      "to": "Smartphones Updated"
    },
    "description": {
      "from": "Mobile devices and smartphones",
      "to": "Updated mobile devices subcategory"
    },
    "imageId": {
      "from": "img_old_456",
      "to": "img_new_2b3c4d5e-6f7g-8h9i-0j1k-2l3m4n5o6p7q"
    }
  },
  "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": "Subcategory not found",
  "code": "SUBCATEGORY_NOT_FOUND",
  "timestamp": "2025-08-02T10:30:00Z"
}

Update Examples

Change Subcategory Information

async function updateSubcategoryInfo(companyId, categoryId, subcategoryId, 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}/subcategory/${subcategoryId}`,
    {
      method: 'PUT',
      headers: { 'X-API-Key': 'YOUR_API_KEY' },
      body: formData
    }
  );

  return response.json();
}

Deactivate Subcategory

async function deactivateSubcategory(companyId, categoryId, subcategoryId, 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}/subcategory/${subcategoryId}`,
    {
      method: 'PUT',
      headers: { 'X-API-Key': 'YOUR_API_KEY' },
      body: formData
    }
  );

  return response.json();
}

Best Practices

  • Always provide the current name when updating
  • Consider impact on existing objects in subcategory
  • Use DEACTIVATE instead of REMOVE when possible
  • Test changes in staging environment first
  • Document reasons for subcategory changes
  • Notify users of significant changes
  • Monitor system after updates
  • Maintain consistent naming conventions

Next Steps