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

# Add a model file to a deployment

> Adds a model file the workspace uploaded (an upload of kind model) to the deployment, with no new release, and answers 202 with its entry. The entry reads adding until the deployment's workers can use the file, then ready, or failed. On a stopped deployment it reads ready once the upload is whole and matches its declared size and sha256, and the next start places the file. An upload sent in pieces may be added before its pieces land.
404 UPLOAD_NOT_FOUND is an upload that is not the deployment's workspace's, is not a model, is gone, or was sent in one piece whose file is not there at its declared size. Each 409 names why: MODEL_POLICY where the release's model policy is an allow list or blocks the file's name, MODEL_NAME_TAKEN where the release or the deployment already has a file at that folder and name, DEPLOYMENT_BUSY while the deployment is neither running nor stopped, MODEL_STORAGE_EXCEEDED where the release's models and the added files would need more storage than the deployment can be given, MODEL_LIST_TOO_LARGE where the deployment's model list would be longer than its workers can be given, and VOLUME_SHARED where the deployment's disk is mounted by another deployment. 503 SERVICE_UNAVAILABLE is also where another deployment of the same build's storage could not be read and none plainly mounts this deployment's disk; the same add may succeed if retried. A refusal adds nothing. The same add again (the same upload, folder and name) while its entry still reads adding is not MODEL_NAME_TAKEN: it starts that entry's work again and answers 202 with it, so a client may retry an add whose answer it did not get. An add that fails after writing its entry leaves it adding; the same add again starts it, or removing the entry frees the name.




## OpenAPI

````yaml /openapi-deploy.yaml post /v1/deployments/{id}/models
openapi: 3.0.3
info:
  title: Comfy Deploy API
  version: 0.1.0
  description: >
    Deploy takes an immutable release cut by Builder and runs it as a live
    autoscaling serverless endpoint.
servers:
  - url: https://platformapi.comfy.org/deploy
    description: Comfy Developer Platform
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /v1/deployments/{id}/models:
    parameters:
      - $ref: '#/components/parameters/PathID'
    post:
      summary: Add a model file to a deployment
      description: >
        Adds a model file the workspace uploaded (an upload of kind model) to
        the deployment, with no new release, and answers 202 with its entry. The
        entry reads adding until the deployment's workers can use the file, then
        ready, or failed. On a stopped deployment it reads ready once the upload
        is whole and matches its declared size and sha256, and the next start
        places the file. An upload sent in pieces may be added before its pieces
        land.

        404 UPLOAD_NOT_FOUND is an upload that is not the deployment's
        workspace's, is not a model, is gone, or was sent in one piece whose
        file is not there at its declared size. Each 409 names why: MODEL_POLICY
        where the release's model policy is an allow list or blocks the file's
        name, MODEL_NAME_TAKEN where the release or the deployment already has a
        file at that folder and name, DEPLOYMENT_BUSY while the deployment is
        neither running nor stopped, MODEL_STORAGE_EXCEEDED where the release's
        models and the added files would need more storage than the deployment
        can be given, MODEL_LIST_TOO_LARGE where the deployment's model list
        would be longer than its workers can be given, and VOLUME_SHARED where
        the deployment's disk is mounted by another deployment. 503
        SERVICE_UNAVAILABLE is also where another deployment of the same build's
        storage could not be read and none plainly mounts this deployment's
        disk; the same add may succeed if retried. A refusal adds nothing. The
        same add again (the same upload, folder and name) while its entry still
        reads adding is not MODEL_NAME_TAKEN: it starts that entry's work again
        and answers 202 with it, so a client may retry an add whose answer it
        did not get. An add that fails after writing its entry leaves it adding;
        the same add again starts it, or removing the entry frees the name.
      operationId: addDeploymentModel
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddDeploymentModelRequest'
      responses:
        '202':
          description: Accepted; the entry reads adding.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeploymentModel'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '503':
          $ref: '#/components/responses/KeyUnverified'
components:
  parameters:
    PathID:
      name: id
      in: path
      required: true
      schema:
        type: string
  schemas:
    AddDeploymentModelRequest:
      type: object
      required:
        - blobId
        - type
      properties:
        blobId:
          type: string
          description: The id of the workspace's upload holding the file.
        type:
          type: string
          description: The model folder the file goes in, such as loras or checkpoints.
        filename:
          type: string
          description: The file's name in that folder; the upload's own name where absent.
    DeploymentModel:
      type: object
      required:
        - id
        - type
        - filename
        - status
        - sizeBytes
      properties:
        id:
          type: string
        type:
          type: string
          description: The model folder the file is in.
        filename:
          type: string
        status:
          type: string
          enum:
            - adding
            - ready
            - failed
            - removing
          x-enum-varnames:
            - DeploymentModelAdding
            - DeploymentModelReady
            - DeploymentModelFailed
            - DeploymentModelRemoving
          description: >-
            adding until the deployment's workers can use the file, ready once
            they can, failed where it could not be added, and removing once a
            removal was asked.
        failure:
          type: string
          description: >-
            Why a failed file was not added, for the log; absent otherwise. Not
            for display: a surface says "<file> was not added to this
            deployment. Remove it and add it again."
        sizeBytes:
          type: integer
          format: int64
          description: The file's size as its upload declared it.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Machine-readable error code.
        message:
          type: string
          description: Human-readable detail.
  responses:
    BadRequest:
      description: >
        Invalid request (INVALID_REQUEST), or RELEASE_AND_SOURCE_BOTH when an
        update names both a release and a source deployment.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid token (UNAUTHORIZED)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >
        Caller's workspace does not own the resource (FORBIDDEN), or an API key
        was refused because its user may not use it, its workspace was deleted
        or blocked, or its account is on the free tier or is being deleted. The
        message says which.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: >
        Unknown id, or not in the caller's workspace (NOT_FOUND). An API key
        also gets this when its workspace no longer exists or its user is no
        longer a member.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: >
        The resource's current state forbids this request. The body's error
        names which state: CONFLICT, MODEL_STORAGE_EXCEEDED when the release's
        models need more storage than the deployment can be given,
        RELEASE_DELETED when the release the request names has been deleted,
        STALE_REVISION when another change moved the deployment past the
        revision an update was asked against, PENDING_UPDATE_EXISTS while
        another update waits, NO_EARLIER_REVISION when a deployment at revision
        1 is rolled back, CURRENT_RELEASE when a request to stop or delete one
        kept release names the release the deployment serves, or one of the
        models route's codes (MODEL_POLICY, MODEL_NAME_TAKEN, DEPLOYMENT_BUSY,
        MODEL_LIST_TOO_LARGE, VOLUME_SHARED).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    KeyUnverified:
      description: >
        The request could not be served now (SERVICE_UNAVAILABLE), and the same
        request may succeed if retried. Either a workspace API key could not be
        verified, because the key check gave no answer, or because the service
        was already checking as many keys as it will at once, overall or from
        the caller's address, which carries Retry-After; or the request ran past
        the service's request deadline, 30 seconds by default and 120 for a
        model add, and was cut off; or a model add could not read another
        deployment's storage to check which disk it mounts. The body's message
        says which.
      headers:
        Retry-After:
          description: >
            Seconds to wait before retrying; sent when the service refused the
            key check because too many were in flight.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: A workspace-scoped Cloud JWT.
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >
        A workspace API key, sent alone. The service checks it on every request
        and acts as the key's user in the key's workspace. A request carrying a
        key and a Bearer token is 400, and a value that is not a key's shape is
        401. A refused key answers 401, 403 or 404 with its message; a 503 means
        the key could not be checked right now, so retry.

````

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