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

# Carica una nuova versione del documento

> Carica un file come JSON in base64. Effettua la deduplicazione tramite checksum SHA256: se lo stesso contenuto esiste già per questo artefatto, restituisce la versione esistente (200) invece di crearne una nuova (201). Rimuove le versioni più vecchie oltre le 10 per artefatto.



## OpenAPI

````yaml post /api/v1/v-ciso/organizations/{organizationid}/workflows/{workflowid}/documents/{artifactid}/versions
openapi: 3.1.0
info:
  title: Aegister API
  version: 1.0.5
servers: []
security: []
paths:
  /api/v1/v-ciso/organizations/{organizationid}/workflows/{workflowid}/documents/{artifactid}/versions:
    post:
      tags:
        - Cyber Assurance • Documents
      summary: Upload a new document version
      description: >-
        Upload a file as base64 JSON. **Allowed formats:** PDF, Word
        (.doc/.docx), Excel (.xls/.xlsx), images (image/*) and video (video/*);
        other types are rejected with 400. **Maximum size:** 10 MB (decoded),
        else 413. Deduplicates by SHA256 checksum — if the same content already
        exists for this artifact, returns the existing version (200) instead of
        creating a new one (201). Trims old versions beyond 10 per artifact. The
        returned `path` is what you attach as a control/task answer's
        `evidence`.
      operationId: create-document-version
      parameters:
        - in: path
          name: artifactid
          schema:
            type: string
          description: Artifact ID (e.g. control ID like 'A.5.1').
          required: true
        - in: path
          name: organizationid
          schema:
            type: integer
          description: Organization ID.
          required: true
        - in: path
          name: workflowid
          schema:
            type: string
          description: Workflow ID.
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentVersionUpload'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/DocumentVersionUpload'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/DocumentVersionUpload'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 0
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - []
                  data:
                    type: object
                    required:
                      - id
                      - artifact_id
                      - original_name
                      - size
                      - content_type
                      - source
                      - created_by
                      - created_at
                      - download_url
                    properties:
                      id:
                        type: integer
                        description: Document version ID.
                      artifact_id:
                        type: string
                        description: Artifact identifier (e.g. control ID like 'A.5.1').
                      original_name:
                        type: string
                        description: Original filename as uploaded.
                      size:
                        type: integer
                        description: File size in bytes.
                      content_type:
                        type: string
                        description: MIME type (e.g. 'application/pdf').
                      source:
                        type: string
                        description: Upload source (e.g. 'attached', 'evidence_upload').
                      created_by:
                        type: string
                        description: Email or username of the uploader.
                      created_at:
                        type: string
                        format: date-time
                        description: Upload timestamp.
                      download_url:
                        type: string
                        format: uri-reference
                        description: Relative URL to download this version.
                    additionalProperties: false
          description: Duplicate detected — existing version returned.
        '201':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 0
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - []
                  data:
                    type: object
                    required:
                      - id
                      - artifact_id
                      - original_name
                      - size
                      - content_type
                      - source
                      - created_by
                      - created_at
                      - download_url
                    properties:
                      id:
                        type: integer
                        description: Document version ID.
                      artifact_id:
                        type: string
                        description: Artifact identifier (e.g. control ID like 'A.5.1').
                      original_name:
                        type: string
                        description: Original filename as uploaded.
                      size:
                        type: integer
                        description: File size in bytes.
                      content_type:
                        type: string
                        description: MIME type (e.g. 'application/pdf').
                      source:
                        type: string
                        description: Upload source (e.g. 'attached', 'evidence_upload').
                      created_by:
                        type: string
                        description: Email or username of the uploader.
                      created_at:
                        type: string
                        format: date-time
                        description: Upload timestamp.
                      download_url:
                        type: string
                        format: uri-reference
                        description: Relative URL to download this version.
                    additionalProperties: false
          description: New version created.
        '400':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 1
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - - Missing content
                        - Invalid base64 content
                        - Unsupported file type
          description: ''
        '401':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 1
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - - 9153
          description: ''
        '404':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 1
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - []
          description: ''
        '413':
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: integer
                    description: |-
                      Any value different from 0 indicates an error.  
                      More details can be found in `messages`.
                    minimum: 0
                    maximum: 0
                    examples:
                      - 1
                  messages:
                    type: array
                    description: >-
                      If `error` is `1`, contains zero or more details on the
                      error.
                    examples:
                      - - File too large. Maximum size is 10 MB.
          description: ''
      security:
        - ApiKeyAuth: []
        - ApiKeyQueryParam: []
components:
  schemas:
    DocumentVersionUpload:
      type: object
      properties:
        filename:
          type: string
          description: Original filename.
        content:
          type: string
          description: Base64-encoded file content.
        content_type:
          type: string
          default: application/pdf
          description: MIME type.
        source:
          type: string
          default: attached
          description: Upload source tag.
      required:
        - content
        - filename
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Aegister-Token
    ApiKeyQueryParam:
      type: apiKey
      in: query
      name: X-Aegister-Token

````