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

# Update a procedure

> Updates a procedure's name, trigger, steps or status. Properties you leave out keep their value, but `steps` replaces all steps. Enabling needs every action the steps mention to exist and be enabled. Changes apply to the live agent at once; publishing an older draft can undo them.



## OpenAPI

````yaml /api-v2-openapi.json patch /agents/{agentId}/procedures/{procedureId}
openapi: 3.1.0
info:
  title: Chatbase API v2
  version: 2.0.0
  description: >-
    Chatbase API v2 - A robust, structured API for managing agents,
    conversations, and the helpdesk.
servers:
  - url: https://www.chatbase.co/api/v2
    description: Chatbase API v2
security: []
paths:
  /agents/{agentId}/procedures/{procedureId}:
    patch:
      tags:
        - Procedures
      summary: Update a procedure
      description: >-
        Updates a procedure's name, trigger, steps or status. Properties you
        leave out keep their value, but `steps` replaces all steps. Enabling
        needs every action the steps mention to exist and be enabled. Changes
        apply to the live agent at once; publishing an older draft can undo
        them.
      operationId: updateProcedure
      parameters:
        - schema:
            type: string
            minLength: 1
            description: The agent ID
            example: 5QHA6VB-DIAbBhxwqxfdi
          required: true
          description: The agent ID
          name: agentId
          in: path
        - schema:
            type: string
            format: uuid
            description: The procedure ID
            example: b1d47c2e-5a3f-4e8b-9c1d-2f6a7b8c9d0e
          required: true
          description: The procedure ID
          name: procedureId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateProcedureBody'
      responses:
        '200':
          description: The updated procedure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Procedure'
        '400':
          description: >-
            The request body failed schema validation. Inspect the `details`
            object in the error response for field-level errors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: VALIDATION_INVALID_BODY
                  message: Invalid request
        '401':
          description: >-
            No Authorization header present. Provide a valid API key as a Bearer
            token in the Authorization header: `Authorization: Bearer
            <api-key>`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: AUTH_MISSING_API_KEY
                  message: Authentication required
        '403':
          description: >-
            The plan does not allow API access, or enabling the procedure would
            exceed its procedure limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                SUBSCRIPTION_API_RESTRICTED_PLAN:
                  summary: >-
                    Your current plan does not include API access. Upgrade to
                    the Basic plan or higher to use the API.
                  value:
                    error:
                      code: SUBSCRIPTION_API_RESTRICTED_PLAN
                      message: A Basic plan or higher is required to access the API
                PROCEDURE_LIMIT_REACHED:
                  summary: >-
                    Enabling this procedure would exceed the number of enabled
                    procedures per agent that the current plan allows.
                  value:
                    error:
                      code: PROCEDURE_LIMIT_REACHED
                      message: >-
                        You have reached the maximum number of enabled
                        procedures for your plan. Disable another procedure or
                        upgrade.
        '404':
          description: >-
            No procedure matches the provided `procedureId` on this agent, or it
            does not belong to the authenticated account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: PROCEDURE_NOT_FOUND
                  message: Procedure not found
        '409':
          description: The new name is taken, or the procedure cannot be enabled yet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                PROCEDURE_NAME_TAKEN:
                  summary: >-
                    Procedure names are unique within an agent, ignoring case.
                    Choose a different `name`.
                  value:
                    error:
                      code: PROCEDURE_NAME_TAKEN
                      message: A procedure with this name already exists on this agent
                PROCEDURE_CHANGE_NOT_ALLOWED:
                  summary: >-
                    The procedure cannot be enabled while an action it mentions
                    is missing or disabled. The message names those actions.
                  value:
                    error:
                      code: PROCEDURE_CHANGE_NOT_ALLOWED
                      message: This change is not allowed for this procedure
        '429':
          description: >-
            Rate limit exceeded. Check the `X-RateLimit-Reset` response header
            for the Unix epoch seconds when the limit resets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: RATE_LIMIT_TOO_MANY_REQUESTS
                  message: Too many requests, please try again later
        '500':
          description: >-
            An unhandled server error occurred. If the issue persists, contact
            support with the `x-request-id` response header value for debugging.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: Something went wrong, please try again
        '503':
          description: >-
            Chatbase is undergoing scheduled maintenance and the API is
            temporarily rejecting requests. This is transient; retry after a
            short delay. Requests are rejected before any data is read or
            written, so no partial changes are applied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: SERVICE_UNDER_MAINTENANCE
                  message: >-
                    The API is temporarily unavailable for scheduled
                    maintenance, please try again later
      security:
        - bearerAuth: []
components:
  schemas:
    UpdateProcedureBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          pattern: ^[^\n\r]+$
          description: >-
            New name: 1 to 100 characters, no line breaks, unique within the
            agent
          example: Refund request
        trigger:
          type: string
          minLength: 1
          maxLength: 500
          description: When the agent should start the procedure, up to 500 characters
          example: The customer wants their money back
        steps:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - instruction
                  text:
                    type: string
                    minLength: 1
                    maxLength: 1000
                    pattern: ^[^\n\r]*$
                    description: >-
                      What the agent does, on one line. `@` plus an action name
                      in lowercase, with `-` written as `_`, mentions that
                      action; `{{variable}}` inserts a variable.
                    example: Ask for the order number, then call @get_order
                required:
                  - kind
                  - text
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - branch
                  branches:
                    type: array
                    items:
                      type: object
                      properties:
                        condition:
                          type: string
                          minLength: 1
                          maxLength: 500
                          pattern: ^[^\n\r]*$
                          description: When this branch runs
                          example: The order is older than 30 days
                        steps:
                          type: array
                          items:
                            type: object
                            properties:
                              kind:
                                type: string
                                enum:
                                  - instruction
                              text:
                                type: string
                                minLength: 1
                                maxLength: 1000
                                pattern: ^[^\n\r]*$
                                description: >-
                                  What the agent does, on one line. `@` plus an
                                  action name in lowercase, with `-` written as
                                  `_`, mentions that action; `{{variable}}`
                                  inserts a variable.
                                example: Ask for the order number, then call @get_order
                            required:
                              - kind
                              - text
                          minItems: 1
                      required:
                        - condition
                        - steps
                    minItems: 1
                    maxItems: 5
                  otherwise:
                    type: object
                    properties:
                      steps:
                        type: array
                        items:
                          type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - instruction
                            text:
                              type: string
                              minLength: 1
                              maxLength: 1000
                              pattern: ^[^\n\r]*$
                              description: >-
                                What the agent does, on one line. `@` plus an
                                action name in lowercase, with `-` written as
                                `_`, mentions that action; `{{variable}}`
                                inserts a variable.
                              example: Ask for the order number, then call @get_order
                          required:
                            - kind
                            - text
                        minItems: 1
                    required:
                      - steps
                    description: Runs when no condition matches
                required:
                  - kind
                  - branches
          minItems: 1
          description: >-
            Replaces all steps, so send the full list in order, including
            unchanged steps. An `instruction` step is one line; in it `@` plus
            an action name in lowercase, with `-` written as `_`, mentions that
            action (`Order-Issue` becomes `@order_issue`), and `{{variable}}`
            inserts one of the agent's variables. A `branch` step runs the
            instructions of its first matching condition (1 to 5), or else
            `otherwise`; a branch cannot contain another branch. Up to 15
            instruction steps in total, counting those inside branches.
        status:
          type: string
          enum:
            - enabled
            - disabled
          description: Turns the procedure on or off
    Procedure:
      allOf:
        - $ref: '#/components/schemas/ProcedureListItem'
        - type: object
          properties:
            steps:
              type: array
              items:
                $ref: '#/components/schemas/ProcedureStep'
              description: The steps in order.
          required:
            - steps
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
            message:
              type: string
              description: Human-readable error message
            details:
              type: object
              additionalProperties:
                type: string
              description: Field-level validation errors
          required:
            - code
            - message
      required:
        - error
    ProcedureListItem:
      type: object
      properties:
        id:
          type: string
          description: Procedure ID
        name:
          type: string
          description: Procedure name, unique within the agent
        status:
          type: string
          enum:
            - enabled
            - disabled
          description: Whether the agent can run the procedure.
        trigger:
          type: string
          description: When the agent should start the procedure
          example: The customer asks for a refund
        unavailableActions:
          type: array
          items:
            type: string
          description: >-
            Action mentions in the steps, such as `@refund_payment`, whose
            action is missing or disabled. While any is listed, the agent skips
            the procedure. It also skips the procedure on a channel where a
            mentioned action is switched off.
          example:
            - '@refund_payment'
      required:
        - id
        - name
        - status
        - trigger
        - unavailableActions
    ProcedureStep:
      oneOf:
        - $ref: '#/components/schemas/ProcedureInstructionStep'
        - $ref: '#/components/schemas/ProcedureBranchStep'
      discriminator:
        propertyName: kind
        mapping:
          instruction: '#/components/schemas/ProcedureInstructionStep'
          branch: '#/components/schemas/ProcedureBranchStep'
    ProcedureInstructionStep:
      type: object
      properties:
        kind:
          type: string
          enum:
            - instruction
        text:
          type: string
          description: >-
            What the agent does. `@` plus an action name in lowercase, with `-`
            written as `_`, mentions that action.
          example: Ask for the order number, then call @get_order
      required:
        - kind
        - text
    ProcedureBranchStep:
      type: object
      properties:
        kind:
          type: string
          enum:
            - branch
        branches:
          type: array
          items:
            type: object
            properties:
              condition:
                type: string
                description: When this branch runs
                example: The order is older than 30 days
              steps:
                type: array
                items:
                  $ref: '#/components/schemas/ProcedureStep'
            required:
              - condition
              - steps
        otherwise:
          type: object
          properties:
            steps:
              type: array
              items:
                $ref: '#/components/schemas/ProcedureStep'
          required:
            - steps
          description: Runs when no condition matches
      required:
        - kind
        - branches
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key from your account settings

````

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