What you’ll learn

• How to batch-create categories and topics
• How to verify the new hierarchy with /categories/all

Endpoints used

POST /categories/batch-create · GET /categories/all

# taxonomy_seed.py
#
# 1) Create three categories, each with two topics
# 2) List everything back to confirm

import os, requests, json
API = "https://sdk.senso.ai/api/v1"
HDR = {"X-API-Key": os.environ["SENSO_KEY"]}

# 1) WORKSPACE – batch create
payload = {
    "categories": [
        {
            "name": "Product",
            "description": "Product documentation",
            "topics": [
                {"name": "Installation"}, {"name": "Troubleshooting"}
            ]
        },
        {
            "name": "Compliance",
            "topics": [
                {"name": "Regulation A"}, {"name": "Regulation B"}
            ]
        },
        {
            "name": "Marketing",
            "topics": [
                {"name": "Brand Voice"}, {"name": "Campaign Assets"}
            ]
        }
    ]
}

created = requests.post(
    f"{API}/categories/batch-create",
    headers=HDR,
    json=payload
).json()
print("Created category_ids →", [c["category_id"] for c in created])

# 2) Verify
tree = requests.get(f"{API}/categories/all", headers=HDR).json()
print("\nCurrent taxonomy:\n", json.dumps(tree, indent=2))

Run:

export SENSO_KEY=your_api_key
python taxonomy_seed.py