> ## 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: All

Upload a contract PDF and receive all detected fields in a single response.

<Note>
  Use the API Playground above to upload sample PDFs, tweak parameters, and
  inspect live responses without leaving the docs.
</Note>

***

## Request

* **Method:** `POST`
* **URL:** `https://api.contractag.dev/fields`
* **Headers:**
  * `x-api-key: YOUR_API_KEY` (optional)
* **Body:**
  * `file` — Required. PDF file upload.

```bash theme={null}
curl -X POST https://api.contractag.dev/fields \
  -H "x-api-key: $CONTRACTAG_API_KEY" \
  -F file=@/path/to/contract.pdf
```

### Upload Limits

* Maximum file size: 25 MB
* Accepted mime types: `application/pdf`
* Multi-page contracts supported (up to 150 pages)

***

## Response

```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"
}
```

### Field Object

| Property     | Description                                                    |
| ------------ | -------------------------------------------------------------- |
| `name`       | Machine-friendly field name (see Reference → Fields Included). |
| `page`       | 1-indexed page where the field was detected.                   |
| `bbox`       | Bounding box `{ x, y, w, h }` in PDF points.                   |
| `confidence` | Float 0–1 describing model confidence.                         |

> Contractag does not return raw text; overlay bounding boxes on the original PDF to display values.

### Status Codes

* `200` — Extraction completed and results returned.
* `400` — Invalid file or request parameters.
* `401` — Missing/invalid API key.
* `413` — File size exceeds limit.


## OpenAPI

````yaml POST /fields
openapi: 3.1.0
info:
  title: Contractag API
  version: 0.3.0
servers:
  - url: https://api.contractag.dev
security: []
paths:
  /fields:
    post:
      summary: Detect contract fields across all pages
      operationId: fields_all_fields_post
      parameters:
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_fields_all_fields_post'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldsAllResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_fields_all_fields_post:
      properties:
        file:
          type: string
          format: binary
          title: File
          description: PDF contract
      type: object
      required:
        - file
      title: Body_fields_all_fields_post
    FieldsAllResponse:
      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: FieldsAllResponse
    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

````