---
title: "Ground claims"
method: POST
path: "/v1/documents/ground"
tags: ["Documents"]
---

# Ground claims

`POST /v1/documents/ground`

## Request

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

Finds where each of your claims or targets appears in a document.

- **Body:** the document service's request for this operation. [Ground](/docs/ndi/ground) lists its options and result.
- **`source`:** a `url`, a `parse_result` of one of your own jobs, or a `workspace_file` you uploaded. Upload one with `POST /v1/documents/upload-grants`.
- **Billing:** admitted only with reserved free/prepaid credit or explicitly enabled pay-as-you-go. Execution stops at its funded limit. Final credits are charged once after successful completion. A job that fails or is cancelled before completion is not charged.
- **Retries:** the same `Idempotency-Key` with the same body returns the same job. With a different body, it answers `409`.

## Query parameters

- `wait_seconds` integer

## Headers

- `Idempotency-Key` string

## Request body

- DocumentGroundRequest: `targets` is the text to find in the source. Each target is resolved to its locations in the document.
  - `corpus_sources` WorkspaceFileSource[]: Workspace files the run can see besides `source`.
    - `file_id` string, uuid, required: File id from GET /v1/workspaces/{workspace_id}/files.
    - `type` 'workspace_file'
    - `workspace_id` string, uuid, required: Workspace that owns the file.
  - `name` string, nullable: Optional display name for the run.
  - `options` DocumentGroundOptions
    - `include_previews` boolean: When true, matches include cropped_image_url for visual regions. Fetch with the same API key.
    - `max_matches` integer: Maximum matches to return per target, ranked best-first. An HTML source is capped the same way, but only visible rendered text is matched: text hidden by its own style attribute, a hidden or aria-hidden attribute, or an unopened <dialog> is never returned. Hiding that comes from a stylesheet or a media query is not evaluated. A hint ranks the visible occurrence nearest that nearby text first; without a hint, rank 1 is the first visible occurrence.
    - `minimum_semantic_score` number, nullable: Drop semantic matches below this score. Exact and normalized matches are unaffected.
    - `require_visual_region` boolean: When true, only matches that have a visual region are kept. Not supported by the current runtime.
    - `use_word_level_grounding` boolean: Experimental. Match targets against word-level OCR bboxes. PDF sources only. Targets shorter than 2 normalized characters return status failed with error needle_too_short.
  - `project_id` string, uuid, nullable: Caller-minted grouping id; jobs submitted together share it. Not a server-side resource.
  - `source` object, required: One of three kinds: - **A URL:** `{"type":"url","url":"https://...","file_name":"a.pdf"}` - **A parse of one of your jobs:** `{"type":"parse_result","job_id":"..."}` - **A workspace file:** `{"type":"workspace_file","workspace_id":"...","file_id":"..."}`
  - `targets` GroundTarget[], nullable: Quoted strings to locate, up to 30. Exactly one of claims or targets must be set.
    - `hint` string, nullable: Nearby free-text context that helps disambiguate a repeated quote.
    - `id` string, required: Caller-defined id echoed on the matching result target.
    - `page_hints` integer[], nullable: Optional 1-based pages to search first.
    - `semantic` boolean: When true, find this quote by meaning, not only as a literal string. When false, the matcher looks for the quoted text.
    - `sheet` string, nullable: Workbook tab to search. Ignored for non-spreadsheet sources.
    - `text` string, required: Quoted string to locate in the source.

## Response `200`

The job finished within `wait_seconds`, or this is a replay of its Idempotency-Key.

- DocumentJob: The document service job, with artifact links rewritten for Drex and cost set to its recorded customer wallet charge. Pending or unknown cost is null. Upstream service tariffs are separate.
  - `job_id` string, uuid, required
  - `kind` 'parse' | 'split' | 'classify' | 'extract' | 'ground', required
  - `status` 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled', required
  - `result` unknown
  - `credits` integer, nullable: Credits the job used; final once `usage_final` is true. Drex charges the job's final billable usage once, at the USD price pinned when it was admitted (see Models & pricing). `credits` is the document service's usage count, not a multiplier for the per-page or per-target price. A failed job is never charged, including when it produced partial results. A job cancelled before completion is not charged, including delivered parts.
  - `usage_final` boolean
  - `timing` DocumentTiming: Original server-side Parse service timing, in milliseconds. Total includes preparation, NDI queueing/processing and active final result preparation. Upload, browser network/rendering and idle time awaiting another client read are excluded. The first usable published preview and final result use the same origin. Missing measurements remain null. Historical jobs can omit timing.
    - `received_at` string, date-time, required: When the original Parse handler received its request, before authentication and admission. Replays preserve this origin.
    - `observed_at` string, date-time, required: Server time of this timing snapshot.
    - `completed_at` string, date-time, nullable, required: First time the service prepared the terminal response, preserved across subsequent reads.
    - `elapsed_ms` integer, nullable, required: Current server elapsed estimate, or frozen total_ms once completed.
    - `total_ms` integer, nullable, required: Frozen service duration: preparation_ms + queue_ms + ndi_processing_ms + result_preparation_ms. Null until completed. delivery_wait_ms is excluded.
    - `first_response_ms` integer, nullable, required: Original request to first usable preview publication on the server. For atomic delivery, equals total_ms. Null if not measured; browser rendering and transport are excluded.
    - `breakdown` DocumentTimingBreakdown, required
      - `preparation_ms` integer, nullable, required: Original Drex request receipt to NDI job creation, including authentication, admission, source checks and internal submission.
      - `queue_ms` integer, nullable, required: NDI job creation to its processing start.
      - `ndi_processing_ms` integer, nullable, required: NDI processing start to finish, including document finalization.
      - `result_preparation_ms` integer, nullable, required: Active result-read request work after NDI finishes, including internal transfer, funding settlement and result preparation.
      - `delivery_wait_ms` integer, nullable, required: Idle interval after NDI finishes and before the request that prepares the final result begins. Excluded from total_ms; reopening a completed job does not inflate processing time.
      - `document_finalization_ms` integer, nullable, required: All requested previews being saved to NDI finishing; included inside ndi_processing_ms, not an additional summand. Null if publication milestones were not measured.
  - `cost` DocumentCost
    - `currency` 'USD', required
    - `pricing_version` string, required
    - `total_usd` string, required: Exact decimal USD wallet charge.
    - `lines` DocumentCostLine[], required
      - `operation` 'parse' | 'split' | 'classify' | 'extract' | 'ground', required
      - `quantity` integer, required
      - `unit` 'page' | 'target', required
      - `execution` 'fresh' | 'reused', required
      - `unit_price_usd` string, required
      - `amount_usd` string, required
      - `reuse_reason` string, nullable, required

## Other responses

- `202`: The job was created and hasn't finished: its `status` is `queued` or `running`. Poll `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`).
- `409`: The Idempotency-Key was already used for a different request (`conflict_error`, code `idempotency_conflict`).
- `413`: The request body is over 1,000,000 bytes (`invalid_request_error`, code `payload_too_large`).
- `422`: The body is not valid JSON, names a source the account doesn't own (code `invalid_source`), or the document service refused it (`invalid_request_error`).
- `429`: Over the account's requests per minute for document routes, or the document service is throttling this account (`rate_limit_error`); or the free or low-balance prepaid account already has 50 unfinished document jobs and browser runs (code `job_limit_reached`, wait for one to finish).
- `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`: Document billing is not configured (code `document_billing_not_configured`), the job is not confirmed yet (code `job_pending`; retry with the same key), or the document service is unavailable.
- `504`: The document service timed out (`upstream_error`).
- `529`: The public API is paused (code `service_disabled`) (`overloaded`).

---

[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)
