---
title: "Returns all SourceDocument IDs that match the query parameters."
method: POST
path: "/analysis/code_occurrences"
tags: ["analysis"]
---

# Returns all SourceDocument IDs that match the query parameters.

`POST /analysis/code_occurrences`

## Query parameters

- `project_id` integer, required
- `code_id` integer, required
- `return_children` boolean, required

## Request body

- integer[]

## Response `200`

Successful Response

- CodeOccurrence[]
  - `sdoc` SourceDocumentRead, required
    - `filename` string, required — Filename of the SourceDocument
    - `name` string, required — User-defined name of the document (default is the filename)
    - `doctype` 'text' | 'image' | 'video' | 'audio', required
    - `project_id` integer, required — Project the SourceDocument belongs to
    - `id` integer, required — ID of the SourceDocument
    - `created` string, date-time, required — The created timestamp of the SourceDocument
    - `updated` string, date-time, required — Updated timestamp of the SourceDocument
    - `folder_id` integer, required — ID of the Folder this SourceDocument belongs to
  - `code` CodeRead, required
    - `name` string, required — Name of the Code
    - `color` string, required — Color of the Code
    - `description` string — Description of the Code
    - `parent_id` integer, nullable — Parent of the Code
    - `enabled` boolean — While false, the code is neither created in pre-processing nor shown in the UI (except in settings to enable it again)
    - `id` integer, required — ID of the Code
    - `project_id` integer, required — Project the Code belongs to
    - `created` string, date-time, required — Created timestamp of the Code
    - `updated` string, date-time, required — Updated timestamp of the Code
    - `is_system` boolean, required — Is the Code a system code
    - `memo_ids` integer[], required — Memo IDs attached to the Code
  - `text` string, required — A text span of the SourceDocument annotated with the Code.
  - `count` integer, required — The number of occurrences of the text span annotated with the Code in the SourceDocument.

## Other responses

- `422` — Validation Error

## Changes

- **2026-07-15** `bd1187f3520e` — 1 breaking, 2 warning
  - the request's body type changed from `object` to `array`
  - removed the request property `doctypes`
  - removed the request property `user_ids`
- **2026-07-15** `1af5a8046f20` — 3 breaking, 2 info
  - added the new required request property `doctypes`
  - added the new required request property `user_ids`
  - the request's body type changed from `array` to `object`
  - added the optional property `detail/items/ctx` to the response with the `422` status
  - …1 more
- **2026-04-13** `fbbe054a012a` — 1 breaking, 1 info
  - the response property `items/code/description` became optional for the status `200`
  - the `description` response's property default value `` was added for the status `200`
- **2025-09-18** `c5b78916c4e5` — 2 info
  - the response property `items/sdoc/name` became required for the status `200`
  - response property `items/sdoc/name` list-of-types was narrowed by removing types `null` from media type `application/json` of response `200`
- **2025-09-16** `4b87af097afc` — 1 breaking
  - added the new required `query` request parameter `return_children`

[Full history](https://skmtc.dev/uhh-lt/apis/discourse-analysis-tool-suite-api/changes/analysis/code_occurrences/post.md)

---

[API](https://skmtc.dev/uhh-lt/apis/discourse-analysis-tool-suite-api.md) · [All operations](https://skmtc.dev/uhh-lt/apis/discourse-analysis-tool-suite-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/uhh-lt/discourse-analysis-tool-suite-api/revisions/2a7bef9e5b1f/schema)
