> ## 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.

# Complete a model upload

> Finalize a prepared model after uploading its images to the presigned URLs.

Step two of the presigned upload flow. After `PUT`-ing each file to the URLs from
[`POST /models/prepare`](/api-reference/model-training/prepare), call this endpoint
with the `uploaded_keys` (the R2 keys you uploaded, in order — first = cover). Samsa
validates the keys and starts processing, returning **`202 Accepted`**. Poll
[`GET /models/{id}/status`](/api-reference/model-training/status) until `completed`.
Requires the `models.write` scope.

<Note>
  Pass a `webhook_url` here to be notified when the model reaches a terminal status
  instead of polling. See [Webhooks](/guides/webhooks).
</Note>


## OpenAPI

````yaml api-reference/openapi.json POST /models/{model_id}/complete
openapi: 3.1.0
info:
  title: Samsa API
  description: >-
    The Samsa public REST API. Authenticate with an organization API key as a
    bearer token (`Authorization: Bearer samsa_sk_...`). 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:
  /models/{model_id}/complete:
    post:
      tags:
        - Models
      summary: Finalize a prepared model after uploading its images
      description: >-
        Completes the presigned flow: validates the uploaded R2 keys (correct
        prefix and present) and starts processing. Requires the `models.write`
        scope.
      operationId: complete_model_models__model_id__complete_post
      parameters:
        - name: model_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Model Id
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicModelCompleteRequest'
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicModelCreateAccepted'
        '401':
          description: Missing, invalid, expired, or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '402':
          description: The organization has no usable subscription.
          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: >-
            Model not found (unknown id, another organization, deleted, or not
            public).
          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'
        '503':
          description: Model creation is disabled on this deployment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
components:
  schemas:
    PublicModelCompleteRequest:
      properties:
        uploaded_keys:
          items:
            type: string
          type: array
          maxItems: 10
          minItems: 1
          title: Uploaded Keys
          description: The R2 keys you uploaded, in order (first = cover).
        webhook_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Webhook Url
          description: >-
            Optional https webhook notified once on terminal status (signed per
            the webhook signature scheme; see the webhooks docs).
          examples:
            - https://example.com/webhooks/samsa
      type: object
      required:
        - uploaded_keys
      title: PublicModelCompleteRequest
      description: >-
        `POST /models/{id}/complete` body — finalize after uploading to
        presigned URLs.
    PublicModelCreateAccepted:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: The created model's id — poll `GET /models/{id}/status`.
        status:
          $ref: '#/components/schemas/PublicModelStatus'
          description: 'Initial status: `pending` (create) or `processing` (complete).'
          examples:
            - pending
        estimated_credits:
          type: integer
          title: Estimated Credits
          description: Credits the finished job will cost (model creation is free = 0).
          examples:
            - 0
      type: object
      required:
        - id
        - status
        - estimated_credits
      title: PublicModelCreateAccepted
      description: >-
        `202` body for `POST /models` and `POST /models/{id}/complete` (ADR
        §7.1).
    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).
    PublicModelStatus:
      type: string
      enum:
        - pending
        - processing
        - completed
        - failed
      title: PublicModelStatus
      description: >-
        Public model creation / readiness status — the lower-cased internal
        status.
    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 as a bearer token: `Authorization: Bearer
        samsa_sk_...`.

````