---
title: "Query documents with natural language"
method: POST
path: "/documents.answerQuestion"
tags: ["Documents"]
---

# Query documents with natural language

`POST /documents.answerQuestion`

This method allows asking direct questions of your documents – where possible an answer will be provided. Search results will be restricted to those accessible by the current access token. Note that "AI answers" must be enabled for the workspace.

## Request body

- object
  - `query` string
  - `userId` string, uuid — Any documents that have not been edited by the user identifier will be filtered out
  - `collectionId` string, uuid — A collection to search within
  - `documentId` string, uuid — A document to search within
  - `statusFilter` 'draft' | 'archived' | 'published' — Any documents that are not in the specified status will be filtered out
  - `dateFilter` 'day' | 'week' | 'month' | 'year' — Any documents that have not been updated within the specified period will be filtered out

## Response `200`

OK

- object
  - `documents` Document[]
    - `id` string, uuid — Unique identifier for the object.
    - `collectionId` string, uuid — Identifier for the associated collection.
    - `parentDocumentId` string, uuid — Identifier for the document this is a child of, if any.
    - `title` string — The title of the document.
    - `fullWidth` boolean — Whether this document should be displayed in a full-width view.
    - `emoji` string — An emoji associated with the document.
    - `text` string — The text content of the document, contains markdown formatting
    - `urlId` string — A short unique ID that can be used to identify the document as an alternative to the UUID
    - `collaborators` User[]
      - `id` string, uuid — Unique identifier for the object.
      - `name` string — The name of this user, it is migrated from Slack or Google Workspace when the SSO connection is made but can be changed if neccessary.
      - `avatarUrl` string, uri — The URL for the image associated with this user, it will be displayed in the application UI and email notifications.
      - `email` string, email — The email associated with this user, it is migrated from Slack or Google Workspace when the SSO connection is made but can be changed if neccessary.
      - `role` 'admin' | 'member' | 'viewer' | 'guest'
      - `isSuspended` boolean — Whether this user has been suspended.
      - `lastActiveAt` string, date-time — The last time this user made an API request, this value is updated at most every 5 minutes.
      - `createdAt` string, date-time — The date and time that this user first signed in or was invited as a guest.
    - `pinned` boolean — Whether this document is pinned in the collection
    - `template` boolean — Whether this document is a template
    - `templateId` string, uuid — Unique identifier for the template this document was created from, if any
    - `revision` number — A number that is auto incrementing with every revision of the document that is saved
    - `createdAt` string, date-time — The date and time that this object was created
    - `createdBy` User
      - `id` string, uuid — Unique identifier for the object.
      - `name` string — The name of this user, it is migrated from Slack or Google Workspace when the SSO connection is made but can be changed if neccessary.
      - `avatarUrl` string, uri — The URL for the image associated with this user, it will be displayed in the application UI and email notifications.
      - `email` string, email — The email associated with this user, it is migrated from Slack or Google Workspace when the SSO connection is made but can be changed if neccessary.
      - `role` 'admin' | 'member' | 'viewer' | 'guest'
      - `isSuspended` boolean — Whether this user has been suspended.
      - `lastActiveAt` string, date-time — The last time this user made an API request, this value is updated at most every 5 minutes.
      - `createdAt` string, date-time — The date and time that this user first signed in or was invited as a guest.
    - `updatedAt` string, date-time — The date and time that this object was last changed
    - `updatedBy` User
      - `id` string, uuid — Unique identifier for the object.
      - `name` string — The name of this user, it is migrated from Slack or Google Workspace when the SSO connection is made but can be changed if neccessary.
      - `avatarUrl` string, uri — The URL for the image associated with this user, it will be displayed in the application UI and email notifications.
      - `email` string, email — The email associated with this user, it is migrated from Slack or Google Workspace when the SSO connection is made but can be changed if neccessary.
      - `role` 'admin' | 'member' | 'viewer' | 'guest'
      - `isSuspended` boolean — Whether this user has been suspended.
      - `lastActiveAt` string, date-time — The last time this user made an API request, this value is updated at most every 5 minutes.
      - `createdAt` string, date-time — The date and time that this user first signed in or was invited as a guest.
    - `publishedAt` string, date-time, nullable — The date and time that this object was published
    - `archivedAt` string, date-time — The date and time that this object was archived
    - `deletedAt` string, date-time, nullable — The date and time that this object was deleted
  - `policies` Policy[]
    - `id` string, uuid — Unique identifier for the object this policy references.
    - `abilities` object
      - `create` boolean
      - `read` boolean
      - `update` boolean
      - `delete` boolean
      - `restore` boolean
      - `star` boolean
      - `unstar` boolean
      - `share` boolean
      - `download` boolean
      - `pin` boolean
      - `unpin` boolean
      - `move` boolean
      - `archive` boolean
      - `unarchive` boolean
      - `createChildDocument` boolean
  - `search` SearchResult
    - `id` string, uuid
    - `query` string — The user-provided search query
    - `answer` string — An answer to the query, if possible
    - `source` 'api' | 'app' — The source of the query
    - `createdAt` string, date-time — The date and time that this object was created

## Other responses

- `401` — The API key is missing or otherwise invalid.
- `403` — The current API key is not authorized to perform this action.
- `429` — The request was rate limited.

## Changes

- **2024-10-18** `fdf2ec9c9df4` — 1 info
  - added the non-success response with the status `429`
- **2024-10-11** `624d6e7c6532` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/defaulr/apis/outline-api/changes/documents.answerQuestion/post.md)

---

[API](https://skmtc.dev/defaulr/apis/outline-api.md) · [All operations](https://skmtc.dev/defaulr/apis/outline-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/defaulr/outline-api/revisions/fdf2ec9c9df4/schema)
