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

# Upload Analysis File

<Info>
  Attaches a <strong>document to an existing analysis</strong> (e.g. a report for a
  [PCD analysis](/public-api/en/concepts/pcd-analysis_en)). It is the companion step to
  `POST /v0/analysis/disability`.
</Info>

## Overview

* **Method:** `POST`
* **Path:** `/v0/analysis/files`
* **OperationId:** `public_upload_analysis_file_v0_analysis_files_post`
* **Authentication:** `x-api-key` header

<OpenAPIPlayground openapi="/public-api/openapi.json" operationId="public_upload_analysis_file_v0_analysis_files_post" />

### Main fields

| Field           | Required | Meaning                                                  |
| --------------- | -------- | -------------------------------------------------------- |
| `analysis_id`   | yes      | Identifier (UUID) of the analysis to attach the file to. |
| `name`          | yes      | File name (with extension).                              |
| `document_type` | yes      | Document type (`AnalysisDocumentTypeEnum`).              |
| `mime_type`     | yes      | Declared MIME type (enum).                               |
| `file_base64`   | yes      | Binary file content encoded in **base64**.               |

<Note>
  The file content goes **inline in the body**, in base64 — not `multipart/form-data`. Make
  sure `mime_type` matches the actual file content.
</Note>

### Request example

```bash theme={null}
curl -X POST "https://public-api.salu.com.vc/dev/routes/v0/analysis/files" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $SALU_PUBLIC_API_KEY" \
  --data '{
    "analysis_id": "ANALYSIS_UUID",
    "name": "report.pdf",
    "document_type": "MEDICAL_REPORT",
    "mime_type": "application/pdf",
    "file_base64": "JVBERi0xLjQK..."
  }'
```


## OpenAPI

````yaml POST /v0/analysis/files
openapi: 3.1.0
info:
  title: Public API v0
  description: API publica da Salu para integracoes de SST.
  version: 0.1.0
servers:
  - url: https://public-api.salu.com.vc/dev/routes
    description: Development
  - url: https://public-api.salu.com.vc/prd/routes
    description: Production
security: []
paths:
  /v0/analysis/files:
    post:
      tags:
        - Analysis
        - Analysis
      summary: Public Upload Analysis File
      operationId: public_upload_analysis_file_v0_analysis_files_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicApiUploadAnalysisFileRequest'
        required: true
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiUploadAnalysisFileResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    PublicApiUploadAnalysisFileRequest:
      properties:
        analysis_id:
          type: string
          format: uuid
          title: ID da Análise
        name:
          type: string
          title: Nome do arquivo (com extensão)
        document_type:
          $ref: '#/components/schemas/AnalysisDocumentTypeEnum'
          title: Tipo do documento
        mime_type:
          $ref: '#/components/schemas/DocumentMimeTypesEnum'
          title: MIME type declarado
        file_base64:
          type: string
          title: Conteúdo do arquivo em base64
          description: Conteúdo binário do arquivo codificado em base64.
      additionalProperties: false
      type: object
      required:
        - analysis_id
        - name
        - document_type
        - mime_type
        - file_base64
      title: PublicApiUploadAnalysisFileRequest
    PublicApiUploadAnalysisFileResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          title: Name
        file_path:
          type: string
          title: File Path
        mimetype:
          type: string
          title: Mimetype
        document_type:
          $ref: '#/components/schemas/AnalysisDocumentTypeEnum'
      type: object
      required:
        - id
        - name
        - file_path
        - mimetype
        - document_type
      title: PublicApiUploadAnalysisFileResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AnalysisDocumentTypeEnum:
      type: string
      enum:
        - DISABILITY_MEDICAL_REPORT
        - DISABILITY_CLASSIFICATION
        - MEDICAL_CERTIFICATE
      title: AnalysisDocumentTypeEnum
      description: Document types specifically for analysis workflows.
    DocumentMimeTypesEnum:
      type: string
      enum:
        - application/pdf
        - image/jpeg
        - image/png
        - image/jpeg
      title: DocumentMimeTypesEnum
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````