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

# File Upload

> Upload files for AI detection and receive dashboard links

<Badge color="green">Current</Badge>

<Update label="File Upload" description="Current version">
  File uploads accept documents as multipart form data and return per-file results. Use them when you want Pangram to extract text from files and create dashboard-backed AI detection results.
</Update>

## POST /

Upload one or more files for AI detection.

```
POST https://file-external.api.pangram.com
```

This endpoint must receive `multipart/form-data` with a form field named `files`. Requests without that field return `422 Unprocessable Entity` with `Field required` for `body.files`.

### Request

Send the request as `multipart/form-data`.

When using cURL, do not set the `Content-Type` header yourself. The `-F` flags add the multipart boundary automatically.

| Field                   | Type    | Required | Description                                                                                       |
| ----------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------- |
| `files`                 | file\[] | Yes      | Files to analyze. Include the `files` form field once per uploaded file.                          |
| `public_dashboard_link` | boolean | No       | Whether to create and return a public dashboard link for each uploaded file. Defaults to `false`. |

### Response

Returns a JSON array with one result object per uploaded file.

| Field                   | Type   | Description                                                                                 |
| ----------------------- | ------ | ------------------------------------------------------------------------------------------- |
| `public_dashboard_link` | string | Public dashboard URL for the uploaded file. Present when `public_dashboard_link` is `true`. |

### Example

```bash cURL theme={null}
curl -s -X POST https://file-external.api.pangram.com \
  -H "x-api-key: $PANGRAM_API_KEY" \
  -F "files=@modeling/deployments/test/test_document.docx" \
  -F "public_dashboard_link=true"
```

To upload multiple files, repeat the `files` form field:

```bash cURL theme={null}
curl -s -X POST https://file-external.api.pangram.com \
  -H "x-api-key: $PANGRAM_API_KEY" \
  -F "files=@path/to/first.docx" \
  -F "files=@path/to/second.pdf" \
  -F "public_dashboard_link=true"
```

**Example Response**

```json theme={null}
[
  {
    "public_dashboard_link": "https://www.pangram.com/history/123e4567-e89b-12d3-a456-426614174000"
  }
]
```

To print only the dashboard link:

```bash theme={null}
curl -s -X POST https://file-external.api.pangram.com \
  -H "x-api-key: $PANGRAM_API_KEY" \
  -F "files=@modeling/deployments/test/test_document.docx" \
  -F "public_dashboard_link=true" \
  | jq -r '.[0].public_dashboard_link'
```

## Errors

| Status Code                  | Description                                                                                                             |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `400 Bad Request`            | The multipart request is missing a file or includes invalid form data.                                                  |
| `401 Unauthorized`           | The `x-api-key` is missing or invalid.                                                                                  |
| `402 Payment Required`       | The account has insufficient credits.                                                                                   |
| `413 Payload Too Large`      | The upload exceeds the maximum supported file size.                                                                     |
| `415 Unsupported Media Type` | The uploaded file type is not supported.                                                                                |
| `422 Unprocessable Entity`   | The `files` field is missing, the form data is invalid, or Pangram could not extract valid text from the uploaded file. |
| `500 Internal Server Error`  | There was an error processing the upload.                                                                               |


## OpenAPI

````yaml openapi/file-upload.json POST /
openapi: 3.1.0
info:
  title: Pangram File Upload API
  version: 1.0.0
  description: Upload files for AI detection and dashboard-backed results.
servers:
  - url: https://file-external.api.pangram.com
security: []
paths:
  /:
    post:
      summary: Upload files
      description: Upload one or more files as multipart form data for AI detection.
      operationId: uploadFiles
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - files
              properties:
                files:
                  type: array
                  description: >-
                    Files to analyze. Send this form field once per uploaded
                    file.
                  items:
                    type: string
                    format: binary
                public_dashboard_link:
                  type: boolean
                  description: >-
                    Whether to create and return a public dashboard link for
                    each uploaded file.
                  default: false
            encoding:
              files:
                style: form
                explode: true
                contentType: application/octet-stream
      responses:
        '200':
          description: Per-file upload results.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FileUploadResult'
              example:
                - public_dashboard_link: >-
                    https://www.pangram.com/history/123e4567-e89b-12d3-a456-426614174000
        '400':
          description: >-
            The multipart request is missing a file or includes invalid form
            data.
        '401':
          description: The x-api-key is missing or invalid.
        '402':
          description: The account has insufficient credits.
        '413':
          description: The upload exceeds the maximum supported file size.
        '415':
          description: The uploaded file type is not supported.
        '422':
          description: >-
            The files field is missing, the form data is invalid, or Pangram
            could not extract valid text from the uploaded file.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              example:
                detail:
                  - type: missing
                    loc:
                      - body
                      - files
                    msg: Field required
                    input: null
        '500':
          description: There was an error processing the upload.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -s -X POST https://file-external.api.pangram.com \
              -H "x-api-key: $PANGRAM_API_KEY" \
              -F "files=@modeling/deployments/test/test_document.docx" \
              -F "public_dashboard_link=true"
components:
  schemas:
    FileUploadResult:
      type: object
      properties:
        public_dashboard_link:
          type: string
          format: uri
          description: Public dashboard URL for the uploaded file.
    ValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              loc:
                type: array
                items:
                  type: string
              msg:
                type: string
              input: {}
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````