---
title: "Returns SpanAnnotationSearch."
method: POST
path: "/search/span_annotation"
tags: ["search"]
---

# Returns SpanAnnotationSearch.

`POST /search/span_annotation`

## Request body

- QueryRequestSpanColumns
  - `project_id` integer, required — Project the search runs in
  - `search_query` string — Full-text query
  - `filter` FilterSpanColumnsInput, required
    - `id` string, required — Unique id of this node within the filter tree
    - `items` union[], required — Child expressions and/or nested filter nodes
      - union
        - FilterExpressionSpanColumns
          - `id` string, required — Unique id of this expression within the filter tree
          - `column` union, required — The column to filter on: an enum member, or an int id referring to a project-metadata column
            - 'SP_SPAN_TEXT' | 'SP_CODE_ID_LIST_RECURSIVE' | 'SP_USER_ID' | 'SP_MEMO_CONTENT' | 'SP_SOURCE_SOURCE_DOCUMENT_NAME' | 'SP_TAG_ID_LIST_RECURSIVE' | 'SP_FOLDER_ID_LIST_RECURSIVE'
            - integer
          - `operator` union, required — The comparison operator applied to the column
            - 'ID_EQUALS' | 'ID_NOT_EQUALS'
            - 'NUMBER_EQUALS' | 'NUMBER_NOT_EQUALS' | 'NUMBER_GT' | 'NUMBER_LT' | 'NUMBER_GTE' | 'NUMBER_LTE'
            - 'STRING_CONTAINS' | 'STRING_EQUALS' | 'STRING_NOT_EQUALS' | 'STRING_STARTS_WITH' | 'STRING_ENDS_WITH'
            - 'ID_LIST_CONTAINS' | 'ID_LIST_NOT_CONTAINS'
            - 'IDLR_CONTAINS' | 'IDLR_NOT_CONTAINS' | 'IDLR_CONTAINS_RECURSIVE'
            - 'LIST_CONTAINS' | 'LIST_NOT_CONTAINS'
            - 'DATE_EQUALS' | 'DATE_GT' | 'DATE_LT' | 'DATE_GTE' | 'DATE_LTE'
            - 'BOOLEAN_EQUALS' | 'BOOLEAN_NOT_EQUALS'
            - 'ATTACHED_OBJECT_TYPE_EQUALS' | 'ATTACHED_OBJECT_TYPE_NOT_EQUALS' — Filters on the attached object's type (a single AttachedObjectType value).
            - 'ATTACHED_OBJECT_EQUALS' | 'ATTACHED_OBJECT_NOT_EQUALS' — Compares an attached object as a (type, id) pair. The column is a tuple ``(type_expr, id_expr)`` and the value is a two-element list ``[type, id]`` (e.g. ``["tag", "5"]``). Filtering by the raw id alone is meaningless because ids collide across entity types (tag 5, code 5, sdoc 5 are different objects), so the type is always part of the comparison.
            - 'SPAN_ANNOTATION_CONTAINS' | 'SPAN_ANNOTATION_NOT_CONTAINS' — Filters by a single span annotation, given as a [code_id, span_text] pair. The column is an aggregated 2-D array of ``[code_id, span_text]`` string pairs (e.g. ``subquery_dict.SPAN_ANNOTATIONS``), so membership is tested by checking whether the pair is an element of that array.
          - `value` union, required — The value the column is compared against
            - boolean
            - string
            - integer
            - string[]
            - array[]
              - …
        - FilterSpanColumnsInput — recursive
    - `logic_operator` 'or' | 'and', required — This tells our filter how to combine multiple column expressions.
  - `sorts` SortSpanColumns[] — Ordered sort expressions; empty means the entity's default sort
    - `column` union, required — The column to sort by: an enum member, or an int id referring to a project-metadata column
      - 'SP_SPAN_TEXT' | 'SP_CODE_ID_LIST_RECURSIVE' | 'SP_USER_ID' | 'SP_MEMO_CONTENT' | 'SP_SOURCE_SOURCE_DOCUMENT_NAME' | 'SP_TAG_ID_LIST_RECURSIVE' | 'SP_FOLDER_ID_LIST_RECURSIVE'
      - integer
    - `direction` 'asc' | 'desc', required — Sort direction. `apply` appends `.nulls_last()` so rows missing a value sink to the bottom regardless of direction.
  - `group_by` GroupConfigSpanColumns
    - `field` 'SP_SPAN_TEXT' | 'SP_CODE_ID_LIST_RECURSIVE' | 'SP_USER_ID' | 'SP_MEMO_CONTENT' | 'SP_SOURCE_SOURCE_DOCUMENT_NAME' | 'SP_TAG_ID_LIST_RECURSIVE' | 'SP_FOLDER_ID_LIST_RECURSIVE', required
    - `date_granularity` 'day' | 'week' | 'month' | 'year' — Bucket size used when grouping a date column.
  - `group_key` string, nullable — Key of the single group to drill into (requires `group_by`). Both must be set or both omitted.
  - `page_number` integer — Zero-based page index
  - `page_size` integer — Number of rows per page

## Response `200`

Successful Response

- PageSpanAnnotationRow
  - `items` SpanAnnotationRow[], required — The rows on the requested page
    - `id` integer, required — ID of the SpanAnnotation
    - `span_text` string, required — The SpanText the SpanAnnotation spans.
    - `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
    - `user_id` integer, required — User the SpanAnnotation belongs to
    - `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
      - `memo_ids` integer[] — IDs of the Memos attached to the SourceDocument
    - `tag_ids` integer[], required — The TagIDs of the SourceDocument.
    - `memo_ids` integer[], required — The IDs of the Memos attached to the Annotation.
  - `total_results` integer, required — Total number of matching rows (unpaginated), used for pagination

## Other responses

- `422` — Validation Error

## Changes

- **2026-08-20** `28b2f0e8bc01` — 4 breaking, 3 warning, 11 info
  - added the new required request property `project_id`
  - removed the enum value `SP_CODE_ID` of the request property `filter/items/items/anyOf[subschema #1: FilterExpression[SpanColumns]]/column/anyOf[subschema #1: SpanColumns]/`
  - removed the enum value `SP_CODE_ID` of the request property `sorts/items/column/anyOf[subschema #1: SpanColumns]/`
  - removed the required property `data` from the response with the `200` status
  - …14 more
- **2026-08-04** `7d9df729f4fc` — 1 breaking, 2 info
  - removed the required property `data/items/memo` from the response with the `200` status
  - added the optional property `data/items/sdoc/memo_ids` to the response with the `200` status
  - added the required property `data/items/memo_ids` to the response with the `200` status
- **2026-08-03** `fab14ec2229b` — 1 breaking, 1 warning, 1 info
  - removed the required property `data/items/memo_ids` from the response with the `200` status
  - removed the optional property `data/items/sdoc/memo_ids` from the response with the `200` status
  - added the required property `data/items/memo` to the response with the `200` status
- …earlier changes not shown

[Full history](https://skmtc.dev/uhh-lt/apis/discourse-analysis-tool-suite-api/changes/search/span_annotation/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/a84d27ef7a0d/schema)
