---
title: "Automatic search"
method: POST
path: "/v1/workspaces/{id}/automatic-search"
tags: ["Workspaces"]
---

# Automatic search

`POST /v1/workspaces/{id}/automatic-search`

## Request

- Base URL: `https://console.nace.ai`
- URL: `https://console.nace.ai/v1/workspaces/{id}/automatic-search`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/nace/apis/drex-api/docs/v1/workspaces/:id/automatic-search/post.ts> (a function with typed inputs; its response is checked against the schema)

Answers one question from the workspace's ingested files: a quick fact search, or an agent that reads documents and queries tables. The result has `routing`, `output` and `output_job_id`. Successful Drex Search costs $0.10 per million input tokens and $0.50 per million output tokens across its models. The initiating account pays. Cached input is counted once; answer-cache hits, failed and cancelled searches are free. Read the charge in Usage Logs. Missing final usage remains pending.

## Path parameters

- `id` string, required

## Query parameters

- `wait_seconds` integer

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `query` string, required
  - `context` string: Background the answer takes as given. Leave it out for the workspace's `global_context`; `""` uses none.
  - `path_prefix` string: Search only the files under this folder.
  - `paths` string[]: Search exactly these files too, by path.
  - `output_schema` object: A JSON Schema the answer must follow; the result's `structured_answer` holds it.
  - `top_k` integer: How many evidences a fact answer cites.
  - `mode` 'auto' | 'fact' | 'agent'

## Response `200`

The job, finished within `wait_seconds`.

- WorkspaceJob: A job in a workspace (an ingestion, reconciliation, knowledge-graph build, automatic search, QA turn, file replace or delete, or workspace delete), passed through from the document service. Read it again with `GET /v1/documents/jobs/{id}`.
  - `job_id` string, uuid, required
  - `kind` string, required: The document service's job kind, such as `ingestion`, `reconciliation`, `kg_build`, `intelligent_search` (automatic search), `automatic_agent` (QA), `file_replace`, `file_delete` or `workspace_delete`.
  - `status` 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled', required
  - `workspace_id` string
  - `result` unknown

## Other responses

- `202`: The job, still running. Read it at `GET /v1/documents/jobs/{id}`.
- `401`: Missing or invalid API key (`authentication_error`, code `invalid_api_key`).
- `402`: The account has insufficient available funds (`insufficient_credit`) or an unpaid invoice (`payment_required`).
- `403`: A `paths` entry names a file the key can't read, or another key started the QA session (`permission_error`, code `access_denied`).
- `404`: No workspace with this id that the key may use (`not_found_error`, code `workspace_not_found`), or Workspaces are off on this deployment (`not_found`).
- `422`: The body or a parameter is invalid, or the document service refused it (`invalid_request_error`).
- `429`: Over the account's requests per minute, or over 60 searches and QA turns per account every 10 minutes (`rate_limit_error`, code `rate_limited`).
- `500`: Something failed on Drex's side (`internal_error`).
- `502`: The document service refused Drex's own request (`upstream_error`, code `ndi_refused_drex`). Retry later.
- `503`: The document service is unavailable (`service_unavailable`).

---

[API](https://skmtc.dev/nace/apis/drex-api.md) - [All operations](https://skmtc.dev/nace/apis/drex-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nace/apis/drex-api/revisions/a0e62d925a61?raw)
