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

# Update a workflow

> PUT /v1/workflows/{id}

Changing the `definition` mints a NEW version rather than editing the old one, so a run that is already going keeps executing the definition it started with, and `version=` still fetches what ran.


## OpenAPI

````yaml openapi.json PUT /v1/workflows/{id}
openapi: 3.0.0
info:
  title: Infery Gateway
  description: >-
    Infery Inference Gateway — OpenAI-compatible API for LLMs, embeddings,
    images, audio, and video
  version: '1.0'
  contact: {}
servers:
  - url: https://api.infery.ai
    description: Production
  - url: http://localhost:3001
    description: Local
security: []
tags: []
paths:
  /v1/workflows/{id}:
    put:
      tags:
        - Workflows
      summary: Update workflow (creates new version if definition changed)
      description: >-
        Every field is optional and only what is sent is written. A request
        carrying a `definition` appends a NEW version (`latestVersion` + 1) and
        leaves the old one readable by `?version=`; a request with only
        `name`/`description` updates the row and leaves `latestVersion` alone.
        There is no way to overwrite an existing version. The definition goes
        through the same write-boundary schema as create, so the same refusals
        apply (`pipeline_timeout_seconds`, `condition_in_container_body`,
        `sub_pipeline` cycles and invisible references). Requires EDIT access: a
        caller who can see the workflow but only holds `read` gets 403, while a
        caller who cannot see it at all gets 404. Running workflows are not
        affected — a run that already resolved its definition keeps it.
      operationId: PipelinesController_update[0]
      parameters:
        - name: id
          required: true
          in: path
          description: Workflow UUID.
          schema:
            example: b0e9f2a4-2b1a-4c7d-9a3e-1f5c8d2e4b60
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePipelineDto'
      responses:
        '200':
          description: Updated. `version` is the new latest.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineWriteResultDto'
        '400':
          description: The definition failed the schema or the validator.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '401':
          description: Unauthorized — invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '403':
          description: >-
            Visible to this caller, but read-only for them
            (`pipeline_forbidden`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '404':
          description: No such workflow in this workspace, or not visible to this caller.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    UpdatePipelineDto:
      type: object
      properties:
        name:
          type: string
          description: >-
            New name. Omit to leave it unchanged — this is a partial update, not
            a replacement.
          maxLength: 120
        description:
          type: string
          description: New description. Omit to leave it unchanged.
          maxLength: 2000
        definition:
          type: object
          additionalProperties: true
          description: >-
            The workflow document: its `steps`, their bindings, and the `inputs`
            it declares. Validated by `parsePipelineDef` at this boundary, so a
            malformed definition is a 400 here and is never stored. The step
            union is defined in Zod (`schemas/pipeline-definition.schema.ts`)
            rather than as a class, which is why this is published as a
            free-form object rather than a modelled schema — read that file for
            the authoritative shape.


            Supplying it creates a NEW VERSION rather than editing the current
            one — earlier versions stay readable by `version`.
    PipelineWriteResultDto:
      type: object
      properties:
        id:
          type: string
          description: Workflow UUID. Unchanged by an update.
          example: b0e9f2a4-2b1a-4c7d-9a3e-1f5c8d2e4b60
        version:
          type: number
          description: >-
            The version this write left as latest. Always 1 from `POST`. From
            `PUT` it is the previous latest + 1 when the request carried a
            `definition`, and the UNCHANGED previous latest when it did not.
          example: 2
        name:
          type: string
          description: The workflow name after the write.
          example: Weekly report
      required:
        - id
        - version
        - name
    ErrorResponseDto:
      type: object
      properties:
        error:
          description: >-
            The error envelope. Every non-2xx response from this API has this
            shape, so a client can parse failures without branching on the
            endpoint.
          allOf:
            - $ref: '#/components/schemas/ErrorDetailDto'
      required:
        - error
    ErrorDetailDto:
      type: object
      properties:
        message:
          type: string
          example: Model not found
          description: Human-readable error message
        type:
          type: string
          example: invalid_request_error
          description: Error category
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - quota_exceeded
            - rate_limit_error
            - server_error
        code:
          type: string
          example: model_not_found
          nullable: true
          description: >-
            Stable machine-readable error code. Branch on this rather than on
            `message`, which is prose and may be reworded.
        param:
          type: string
          example: model
          nullable: true
          description: >-
            Name of the request parameter that triggered the error. `null` when
            the error is not attributable to one field.
        job_id:
          type: string
          example: job_1hR9xTPZqK4mVLc2nJ7fY5wB
          description: >-
            Handle to work that is ALREADY RUNNING AND ALREADY BILLED, present
            on the few errors that carry one. When it is here, this is not a
            failure to retry — retrying pays twice. Collect the result from `GET
            /v1/images/jobs/{job_id}`, which serves every durable media job
            regardless of modality.


            Two situations produce it. A media generation that outruns the
            gateway's wait answers `504` with `code: "job_timeout"` and keeps
            working. And `POST /v1/audio/speech` answers **500** with `code:
            "artifact_unreadable"` when the speech was generated and settled but
            could not be read back from storage — the audio exists and is paid
            for; only this response failed.


            Declared here rather than per-endpoint because the rule is about the
            FIELD, not the status: if this is present, there is a paid-for
            result to collect. It was undeclared until now, so a client
            generated from this document could not see the one field that
            recovers money already spent.
      required:
        - message
        - type
        - code
        - param
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key in format: Bearer inf_***'

````