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

# Completa un upload di immagine

> Passaggio 3 dell'upload di immagini: verifica il file caricato e rendi utilizzabile il suo image_id.

Passaggio tre del [caricamento di immagini](/it/api-reference/uploads/overview.md), dopo
il `PUT` sull'`upload_url` di
[`POST /images/uploads/prepare`](/it/api-reference/uploads/prepare). Chiamalo entro
un'ora. Samsa verifica il file — presente, esattamente `size_bytes`, al massimo
10 MB, un'immagine leggibile del `content_type` preparato, al massimo 32 megapixel —
e restituisce **`200 OK`** con l'`image_id`, `status: "completed"` e `width` e
`height` misurate.

Da quel momento usa l'`image_id` come sorgente di una modifica, di un'operazione
sulle immagini o di una generazione image-to-video.

> [!NOTE]
>
> Complete è **idempotente**: richiamarlo restituisce lo stesso risultato. Un file
> che non supera un controllo restituisce `422` e viene scartato — fai il `PUT` di un
> file valido sullo stesso `upload_url` finché è ancora valido e richiama complete.
> [`409 upload_in_progress`](/it/guides/errors#upload_in_progress) significa che
> un'altra chiamata complete è in corso: riprova tra qualche secondo. Richiede uno
> qualsiasi degli scope `images.edit`, `images.transform` o `videos.generate`.
> Gratuito.


## OpenAPI

````yaml api-reference/openapi.json POST /images/uploads/{image_id}/complete
openapi: 3.1.0
info:
  title: Samsa API
  description: >-
    The Samsa public REST API. Authenticate with an organization API key
    (`Authorization: Bearer samsa_sk_...`) or an OAuth 2.1 access token
    (`Authorization: Bearer samsa_at_...`). Errors follow a single envelope
    shape; every response carries an `X-Request-ID`.
  version: 1.0.0
servers:
  - url: https://api.samsa.ai/public/v1
security:
  - BearerAuth: []
paths:
  /images/uploads/{image_id}/complete:
    post:
      tags:
        - Images
      summary: Finish an image upload (verify the file, get a usable image_id)
      description: >-
        Step 3 of 3 (after `POST /images/uploads/prepare` and the PUT). Verifies
        the uploaded file — present, exactly the prepared `size_bytes`, at most
        10 MB, a readable image of the prepared `content_type`, at most 32
        megapixels — and returns the image with its measured `width` and
        `height`. From then on the `image_id` is usable as the source of edits,
        img2img, variations, resizes, upscales, background removals,
        vectorizations and image-to-video generations. Idempotent: calling it
        again returns the same result and changes nothing (a later PUT to the
        upload URL does not replace the completed image). A file that fails a
        check returns `422` and is discarded; PUT a valid file to the same
        `upload_url` while it is still valid and call complete again. An
        unknown, expired or another user's `image_id`, or an image that was not
        created by `POST /images/uploads/prepare`, returns `404`. Free: uploads
        cost no credits. Requires any one of the `images.edit`,
        `images.transform` or `videos.generate` scopes.
      operationId: complete_image_upload_images_uploads__image_id__complete_post
      parameters:
        - name: image_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Image Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicImageUploadComplete'
        '401':
          description: Missing, invalid, expired, or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '403':
          description: The API key lacks the required scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: Resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '409':
          description: Another request is completing this upload right now; retry shortly.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Request validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    PublicImageUploadComplete:
      properties:
        image_id:
          type: string
          format: uuid
          title: Image Id
          description: >-
            Use as the source `image_id` in edits, img2img, variations, resizes,
            upscales, background removals, vectorizations and image-to-video
            generations.
        status:
          type: string
          const: completed
          title: Status
          description: >-
            Always `completed`: the file is verified and the image can be used
            now. Thumbnails are built in the background.
        filename:
          type: string
          title: Filename
          description: The filename given at prepare.
        content_type:
          type: string
          title: Content Type
          description: The verified MIME type of the bytes.
        size_bytes:
          type: integer
          title: Size Bytes
          description: Size of the uploaded file in bytes.
        width:
          type: integer
          title: Width
          description: Width in pixels, measured from the bytes.
        height:
          type: integer
          title: Height
          description: Height in pixels, measured from the bytes.
      type: object
      required:
        - image_id
        - status
        - filename
        - content_type
        - size_bytes
        - width
        - height
      title: PublicImageUploadComplete
      description: >-
        `200` body for `POST /images/uploads/{image_id}/complete` — the usable
        image.
      examples:
        - content_type: image/png
          filename: christmas-card.png
          height: 1536
          image_id: 3f1c2b7e-8d4a-4c1e-9b2f-5a6d7e8f9a0b
          size_bytes: 4718592
          status: completed
          width: 2048
    ErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
      title: ErrorEnvelope
      description: The complete public error body — an ``error`` object wrapper (ADR §5).
    ErrorDetail:
      properties:
        type:
          type: string
          title: Type
          examples:
            - authentication_error
        code:
          type: string
          title: Code
          examples:
            - invalid_api_key
        message:
          type: string
          title: Message
          examples:
            - The provided API key is invalid, expired, or revoked.
        request_id:
          type: string
          title: Request Id
          examples:
            - 8f14e45fceea167a5a36dedd4bea2543
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
          description: Present on validation errors — names the offending field.
          examples:
            - aspect_ratio
      type: object
      required:
        - type
        - code
        - message
        - request_id
      title: ErrorDetail
      description: The ``error`` object of the public envelope (ADR §5).
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Organization API key (`Authorization: Bearer samsa_sk_...`) or OAuth 2.1
        access token (`Authorization: Bearer samsa_at_...`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.