# Query across event types

## `POST /v1/events/query`

Filter by shared event columns or event type, and page the results. Requires the `read` scope.

```json
{
  "tags": [
    "Events"
  ],
  "operationId": "query-events",
  "summary": "Query across event types",
  "description": "Filter by shared event columns or event type, and page the results. Requires the `read` scope.",
  "x-retainer-scope": "read",
  "parameters": [],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "search": {
              "description": "Keywords within this object only, matched by Postgres full-text search over its label and searchable fields. Every word must match, as a whole word or the start of one (\"Dan\" finds \"Dana\"); accents are ignored.",
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "filter": {
              "description": "Filter by a shared event column or by type. The type filter supports eq, neq, and in.",
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "sort": {
              "maxItems": 3,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string",
                    "enum": [
                      "occurredAt",
                      "channel",
                      "externalId",
                      "id",
                      "createdAt",
                      "updatedAt"
                    ]
                  },
                  "direction": {
                    "default": "asc",
                    "type": "string",
                    "enum": [
                      "asc",
                      "desc"
                    ]
                  }
                },
                "required": [
                  "field"
                ],
                "additionalProperties": false
              }
            },
            "limit": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "cursor": {
              "type": "string"
            },
            "include": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "relationReferences"
                ]
              }
            },
            "linked": {
              "description": "Event types only: events directly attached to this record, as a participant, about it, or through one of the event's own relation fields (link: field).",
              "type": "object",
              "properties": {
                "record": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "link": {
                  "type": "string",
                  "enum": [
                    "participant",
                    "about",
                    "field"
                  ]
                }
              },
              "required": [
                "record"
              ],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "example": {
          "filter": {
            "type": "conversation"
          },
          "limit": 10
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Successful response.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/EventPage"
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "default": {
      "$ref": "#/components/responses/ApiError"
    }
  }
}
```

[Full OpenAPI contract](/openapi.json)
