# Find a product's categories, features and topics by name (/api/hierarchy/search)

`GET /v1/products/{productId}/search`

Operation name: `search`

Use this whenever the person names something ("the export feature", "Billing", "the SSO complaints") instead of reading the whole hierarchy. Matches category and feature titles and topic names containing the text, ignoring case; descriptions, insights and feedback text are not searched. Exact names first, then names starting with the text, then the rest, ties by name. Each hit's `path` is where it sits, top down, ending with its direct parent (categories, then a topic's feature); empty for a top-level category, a feature not in a category yet, or a topic in New opportunity. Merged and emptied topics are never found. `meta.total` counts every hit. `meta.version` is the hierarchy's version: send it as `expectedVersion` with a hierarchy change planned from a hit; `meta.feedbackVersion` is the feedback's: send it with a feedback change (for example `apply_feedback_changes`) planned from a topic hit. Read a category's branch with `get_hierarchy` and its `categoryId`, a topic with `get_topic`.

## Authentication

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.

Or: An API key, sent as `Authorization: Bearer ha_…` (keys made before the rename to Heuristic start `fsa_` and keep working). Keys are created only in the Heuristic web app and shown once. A personal key (Settings → Personal → My API keys) acts as its person in one of their organizations, with exactly their access there, checked on every call; its calls count toward the person's limits on calls through apps and agents, as described for OAuth tokens, and it can't change the person's account (their profile, organizations, invitations or connected apps). An organization key (Settings → Organization → API keys, created by Admins) acts for the organization, not a person: it can see and change every product and its feedback as an Admin can, but not people, product access, CRM connections or the organization's settings, and it can't delete a product; each organization key has its own limits, with the same numbers. Either kind is Full access or Read only (a change with a read-only key answers 403 `read_only_key`), reaches only its own organization (others answer 404), works on /v1 only, not on the MCP server, and can't create keys or manage the organization's API keys. Other refused calls answer 403 `api_key_not_allowed`. A wrong, expired or revoked key, or a disabled member's personal key, answers 401 `unauthorized`. A full-access key sends feedback: a personal key as its person, to the products they own; an organization key to any product of its organization; the record's `sentBy` names the key.

## Path parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `productId` | path | string | yes | A Heuristic id: a uuid, in any case (it is read in lower case). Anything else answers 400 `validation_error`. |

## Query parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `query` | query | string | yes | The text to find in names, 1 to 200 characters after surrounding spaces are removed. |
| `type` | query | string | no | Only this kind: `category`, `feature` or `topic`. Leave out to search all three. |
| `limit` | query | integer | no | How many hits to return, 1 to 40 (20 when left out). |
| `cursor` | query | string | no | The previous page's `meta.nextCursor`, with the same `query` and `type`; left out: the first page. |

## Responses

### 200

The hits

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "category",
              "feature",
              "topic"
            ]
          },
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "path": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "category",
                    "feature"
                  ]
                },
                "id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                }
              },
              "required": [
                "type",
                "id",
                "title"
              ]
            }
          }
        },
        "required": [
          "type",
          "id",
          "title",
          "path"
        ]
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "nextCursor": {
          "type": [
            "string",
            "null"
          ]
        },
        "total": {
          "type": "integer"
        },
        "version": {
          "type": "string"
        },
        "feedbackVersion": {
          "type": "string",
          "description": "The feedback's version (see `apply_feedback_changes`)."
        }
      },
      "required": [
        "nextCursor",
        "total",
        "version",
        "feedbackVersion"
      ]
    }
  },
  "required": [
    "data",
    "meta"
  ]
}
```

### 400

Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "details": {}
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
```

### 401

Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "details": {}
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
```

### 404

Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "details": {}
      },
      "required": [
        "code",
        "message"
      ]
    }
  },
  "required": [
    "error"
  ]
}
```

## Example request

```bash
curl "https://staging.heuristic.app/v1/products/{productId}/search?query=string" \
  -H "Authorization: Bearer <access token>"
```
