> ## Documentation Index
> Fetch the complete documentation index at: https://docs.contractag.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Fields: Get

Retrieve the latest extraction result for a previously submitted document, optionally filtered to a specific page.

<Note>
  The API Playground above uses the endpoint to send live requests and inspect
  responses without leaving the docs.
</Note>

***

## Request

* **Method:** `GET`
* **URL:** `https://api.contractag.dev/fields/{document_id}`
* **Query Parameters:**
  * `page` — Optional. 1-indexed page number to filter by.
* **Headers:**
  * `x-api-key: YOUR_API_KEY` (optional)

```bash theme={null}
curl -X GET https://api.contractag.dev/fields/doc_123 \
  -H "x-api-key: $CONTRACTAG_API_KEY"
```

To filter by page:

```bash theme={null}
curl "https://api.contractag.dev/fields/doc_123?page=2" \
  -H "x-api-key: $CONTRACTAG_API_KEY"
```

***

## Response

When no `page` parameter is provided, returns all fields:

```json theme={null}
{
  "documentId": "doc_123",
  "pages": 12,
  "fields": [
    {
      "name": "purchaser_name",
      "page": 1,
      "bbox": { "x": 142.3, "y": 258.9, "w": 210.5, "h": 24.2 },
      "confidence": 0.97
    }
  ],
  "createdAt": "2024-09-10T07:21:37.524Z"
}
```

When `page` is specified, returns fields for that page only:

```json theme={null}
{
  "documentId": "doc_123",
  "pages": 12,
  "fields": [
    {
      "name": "special_conditions",
      "page": 2,
      "bbox": { "x": 64.1, "y": 481.0, "w": 482.8, "h": 96.5 },
      "confidence": 0.85
    }
  ],
  "createdAt": "2024-09-10T07:21:37.524Z"
}
```

> Responses include coordinates and confidence only. Render bounding boxes over the source PDF to view the underlying text.

### Errors

* `404` — Document ID not found or expired (default retention is 30 days).
* `410` — Document purged; re-upload required.
* `422` — Invalid page parameter.
* `429` — Rate limit exceeded; see response headers for reset window.


## OpenAPI

````yaml GET /fields/{document_id}
openapi: 3.1.0
info:
  title: Contractag API
  version: 0.3.0
servers:
  - url: https://api.contractag.dev
security: []
paths:
  /fields/{document_id}:
    get:
      summary: Fetch contract field detections
      operationId: fields_get_fields__document_id__get
      parameters:
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            title: Document Id
        - name: page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Page
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldsGetResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    FieldsGetResponse:
      properties:
        documentId:
          type: string
          title: Documentid
        pages:
          type: integer
          title: Pages
        fields:
          items:
            $ref: '#/components/schemas/FieldDetection'
          type: array
          title: Fields
        createdAt:
          type: string
          format: date-time
          title: Createdat
      type: object
      required:
        - documentId
        - pages
        - fields
        - createdAt
      title: FieldsGetResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FieldDetection:
      properties:
        name:
          type: string
          title: Name
        page:
          type: integer
          title: Page
        bbox:
          $ref: '#/components/schemas/BoundingBox'
        confidence:
          type: number
          title: Confidence
      type: object
      required:
        - name
        - page
        - bbox
        - confidence
      title: FieldDetection
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    BoundingBox:
      properties:
        x:
          type: number
          title: X
        'y':
          type: number
          title: 'Y'
        w:
          type: number
          title: W
        h:
          type: number
          title: H
      type: object
      required:
        - x
        - 'y'
        - w
        - h
      title: BoundingBox

````