Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt

Use this file to discover all available pages before exploring further.

Sub-categories live under a category and group related offers. They support soft-delete, version tracking, and audit logging. For the full sub-categories documentation integrated with the Categories API, see the Categories API reference. All sub-categories support soft-delete (a deletedAt timestamp is set instead of permanent removal), version tracking (the version field auto-increments on every update), and audit logging (before/after snapshots are recorded for every CRUD operation).

Base path

/api/v1/sub-categories

List sub-categories

GET /api/v1/sub-categories
Returns a paginated list of sub-categories for the tenant, ordered by ordinal ascending. Optionally filter by parent category. By default, soft-deleted sub-categories are excluded.

Query Parameters

ParameterTypeRequiredDescription
categoryIdstringNoFilter by parent category ID.
limitintegerNoMaximum results per page. Default 25.
cursorstringNoCursor for keyset pagination.
includeDeletedstringNoSet to "true" to include soft-deleted sub-categories.

Response 200

{
  "data": [
    {
      "id": "sub_01",
      "tenantId": "t_001",
      "categoryId": "cat_01",
      "name": "Premium Cards",
      "description": "High-tier credit card products",
      "icon": "",
      "status": "active",
      "ordinal": 0,
      "version": 1,
      "deletedAt": null,
      "customFields": [],
      "category": { "id": "cat_01", "name": "Acquisition" },
      "_count": { "offers": 12 },
      "createdAt": "2026-03-10T12:00:00.000Z",
      "updatedAt": "2026-03-10T12:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 3,
    "limit": 25,
    "hasMore": false,
    "nextCursor": null
  }
}

Create a sub-category

POST /api/v1/sub-categories

Request Body

FieldTypeRequiredDescription
categoryIdstringYesParent category ID.
namestringYesSub-category name.
descriptionstringNoOptional description.
iconstringNoIcon identifier.
statusenumNo"active" (default), "draft", "paused", "archived".
ordinalinteger (>= 0)NoSort order. Default 0.
customFieldsarrayNoCustom field definitions (same schema as categories).

Example

curl -X POST https://playground.kaireonai.com/api/v1/sub-categories \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: my-tenant" \
  -d '{
    "categoryId": "cat_credit_cards",
    "name": "Premium Cards",
    "description": "High-tier credit card products",
    "status": "active"
  }'

Response 201

Returns the created sub-category with its parent category relation, version: 1, and deletedAt: null. An audit log entry is created with a create action.

Error codes

CodeReason
400Validation error (missing categoryId or name).
401Missing or invalid API key / session.
403Insufficient role (requires editor or admin).
409A sub-category with that name already exists.

Update a sub-category

PUT /api/v1/sub-categories
Updates an existing sub-category. Only provided fields are changed. The version field is auto-incremented and a before/after audit snapshot is recorded.

Request Body

FieldTypeRequiredDescription
idstringYesSub-category ID to update.
All other fields from the create schema are accepted as optional.

Response 200

Returns the updated sub-category object with the incremented version.

Error codes

CodeReason
400Validation error or missing id.
401Missing or invalid API key / session.
403Insufficient role.
409A sub-category with that name already exists.

Delete a sub-category (soft-delete)

DELETE /api/v1/sub-categories?id={subCategoryId}
Soft-deletes a sub-category by setting its deletedAt timestamp. The version is incremented.

Query Parameters

ParameterTypeRequiredDescription
idstringYesSub-category ID to delete.

Response 200

{
  "success": true
}

Error codes

CodeReason
400Missing id, entity not found, or entity already deleted.
401Missing or invalid API key / session.
403Insufficient role.
To restore a soft-deleted sub-category, use POST /api/v1/restore?entityType=subCategory&id={subCategoryId} (admin only).

Role requirements

MethodMinimum role
GETviewer
POSTeditor
PUTeditor
DELETEeditor