Skip to Content
Heuristic documentation

Add a category

POST
/v1/products/{productId}/categories

At the top level (parentId null) or under a category holding no features. Choose a new uuid as id so that a retry is safe: a repeat answers the same category's add change; an id anything else holds is refused. Product Owners and Admins only; Viewers are refused. It answers the hierarchy change it stored (what changed, who and when), which undo_hierarchy_change reverses. Values a person sets have origin user and are kept by later knowledge base reads and rebuilds. Ids that are unknown, deleted or another product's are not found; a place that breaks the tree's rules (a category never holds both subcategories and features, never goes under itself) is refused (conflict, with the rule in details.rule and, for moves and merges, the allowed places in details.allowed). Send the version from get_hierarchy as expectedVersion to be refused (conflict) when the hierarchy changed since you read it; every answer carries the version after the change. For many changes at once use apply_hierarchy_changes.

Authorization

headerAuthorizationBearer <token>

An OAuth access token for the person who allowed your tool: register a client, then the authorization code flow with PKCE (S256). Send it as Authorization: Bearer <token> on every route that needs a signed-in person. Calls with a token are limited per person, across all their apps, to 120 calls a minute and 10,000 a UTC day; calls that start AI runs or knowledge base reads (creating an organization, starting a knowledge base read, rebuilding categories, retrying topics or rechecking) also to 10 a minute and 200 a UTC day. Over a limit a call answers 429 rate_limited with Retry-After and details.retryAfter in seconds, and changes nothing.

Path Parameters

productId*string

A Heuristic id: a uuid, in any case (it is read in lower case). Anything else answers 400 validation_error.

Formatuuid

Query Parameters

expectedVersion?string

Optional: the version from get_hierarchy you planned from; refused (conflict) when the hierarchy changed since.

Request Body

application/json
  1. body

The new category. parentId is the category to put it under, or null for the top level.

id?string

A Heuristic id: a uuid, in any case (it is read in lower case). Anything else answers 400 validation_error.

Formatuuid
title*string

The category's title, 1 to 100 characters on one line.

Match^[^\u0000-\u001f\u007f-\u009f\u2028\u2029]*$
Length1 <= length <= 100
description?|

What the category covers; empty or null for none.

Match^[^\u0000-\u001f\u007f-\u009f\u2028\u2029]*$
Lengthlength <= 250
parentId*|

A Heuristic id: a uuid, in any case (it is read in lower case). Anything else answers 400 validation_error.

Formatuuid

Response Body

Added earlier with the same id

application/json
  1. response
data*
meta*
Example Request
curl -X POST 'https://staging.heuristic.app/v1/products/497f6eca-6276-4993-bfeb-53cbbbba6f08/categories' \  -H 'Authorization: Bearer <access token>' \  -H 'Content-Type: application/json' \  -d '{  "title": "string",  "parentId": "70850378-7d3c-4f45-91b7-942d4dfbbd43"}'
Example Response
{  "data": {    "change": {      "id": "string",      "kind": "edit",      "subject": {        "type": "category",        "id": "string",        "title": "string"      },      "details": {        "fields": [          {            "field": "title",            "before": "string",            "after": "string"          }        ],        "from": {          "id": "string",          "title": "string"        },        "to": {          "id": "string",          "title": "string"        },        "into": {          "id": "string",          "title": "string"        },        "categories": 0,        "features": 0,        "parent": {          "id": "string",          "title": "string"        },        "other": {          "id": "string",          "title": "string"        },        "stepCount": 0,        "steps": [          {            "step": 0,            "kind": "edit",            "subject": {              "type": "category",              "id": "string",              "title": "string"            },            "details": {              "fields": [                {                  "field": "title",                  "before": "string",                  "after": "string"                }              ],              "from": {                "id": "string",                "title": "string"              },              "to": {                "id": "string",                "title": "string"              },              "into": {                "id": "string",                "title": "string"              },              "categories": 0,              "features": 0,              "parent": {                "id": "string",                "title": "string"              },              "other": {                "id": "string",                "title": "string"              }            }          }        ]      },      "undoesChangeId": "string",      "undoneAt": "string",      "createdAt": "string",      "createdBy": {        "id": "string",        "name": "string"      },      "via": "web",      "app": {        "clientId": "string",        "name": "string"      }    },    "version": "string"  },  "meta": {    "property1": null,    "property2": null  }}