> ## Documentation Index
> Fetch the complete documentation index at: https://botpress-pb-update-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# patchState

> Updates the [State](#schema_state) object by setting the values of the parameters passed.



## OpenAPI

````yaml /runtime-openapi.json patch /v1/chat/states/{type}/{id}/{name}
openapi: 3.0.0
info:
  title: Botpress Runtime API
  description: API for Botpress Runtime
  version: 1.112.0
servers:
  - url: https://api.botpress.cloud
security:
  - BearerAuth: []
tags:
  - name: documented
  - name: experimental
paths:
  /v1/chat/states/{type}/{id}/{name}:
    patch:
      tags:
        - Endpoints
      description: >-
        Updates the [State](#schema_state) object by setting the values of the
        parameters passed.
      operationId: patchState
      parameters:
        - name: type
          in: path
          description: Represents the resource type that the state is related to
          required: true
          schema:
            type: string
            enum:
              - conversation
              - user
              - bot
              - integration
              - workflow
        - name: id
          in: path
          description: >-
            Id of the State which will be either the botId, the userId or the
            conversationId
          required: true
          schema:
            type: string
        - name: name
          in: path
          description: Name of the State which is declared inside the bot definition
          required: true
          schema:
            type: string
        - name: x-bp-authenticated-principal
          in: header
          description: Authenticated principal. Injected by the authentication middleware.
          required: true
          schema:
            type: string
        - name: x-bot-id
          in: header
          description: Bot id
          required: true
          schema:
            type: string
        - name: x-integration-id
          in: header
          description: Integration id
          required: false
          schema:
            type: string
        - name: x-integration-alias
          in: header
          description: Integration alias
          required: false
          schema:
            type: string
        - name: x-real-ip
          in: header
          description: Caller's IP address. Injected by the edge proxy.
          required: false
          schema:
            type: string
      requestBody:
        $ref: '#/components/requestBodies/patchStateBody'
      responses:
        '200':
          $ref: '#/components/responses/patchStateResponse'
        default:
          $ref: '#/components/responses/patchStateResponse'
components:
  requestBodies:
    patchStateBody:
      description: State content
      content:
        application/json:
          schema:
            type: object
            properties:
              payload:
                type: object
                additionalProperties: true
                description: Payload is the content of the state defined by your bot.
              expiry:
                type: number
                minimum: 1
                maximum: 2592000000
                nullable: true
                description: >-
                  Expiry of the [State](#schema_state) in milliseconds. The
                  state will expire if it is idle for the configured value. By
                  default, a state doesn't expire.
            required:
              - payload
            title: patchStateBody
            additionalProperties: false
  responses:
    patchStateResponse:
      description: >-
        Returns the updated [State](#schema_state) object if a valid identifier
        was provided. Returns an [an error](#errors) otherwise
      content:
        application/json:
          schema:
            type: object
            properties:
              state:
                $ref: '#/components/schemas/State'
            required:
              - state
            title: patchStateResponse
            additionalProperties: false
  schemas:
    State:
      type: object
      properties:
        id:
          type: string
          minLength: 28
          maxLength: 36
          description: Id of the [State](#schema_state)
        createdAt:
          type: string
          format: date-time
          description: Creation date of the [State](#schema_state) in ISO 8601 format
        updatedAt:
          type: string
          format: date-time
          description: Updating date of the [State](#schema_state) in ISO 8601 format
        botId:
          type: string
          minLength: 28
          maxLength: 36
          description: Id of the [Bot](#schema_bot)
        conversationId:
          type: string
          minLength: 28
          maxLength: 36
          description: Id of the [Conversation](#schema_conversation)
        userId:
          type: string
          minLength: 28
          maxLength: 36
          description: Id of the [User](#schema_user)
        name:
          type: string
          maxLength: 200
          description: >-
            Name of the [State](#schema_state) which is declared inside the bot
            definition
        type:
          type: string
          enum:
            - conversation
            - user
            - bot
            - integration
            - workflow
          description: >-
            Type of the [State](#schema_state) represents the resource type
            (`conversation`, `user`, `bot`, `integration` or `workflow`) that
            the state is related to
        payload:
          type: object
          additionalProperties: true
          description: Payload is the content of the state defined by your bot.
        expiry:
          type: number
          minimum: 1
          description: >-
            Expiry of the state in milliseconds. The state will expire if it is
            idle for the configured value. Absent if no expiry is set.
        expiresAt:
          type: string
          format: date-time
          description: >-
            Expiration date of the ${ref.state} in ISO 8601 format. Absent if no
            expiry is set.
      required:
        - id
        - createdAt
        - updatedAt
        - botId
        - name
        - type
        - payload
      description: >-
        The state object represents the current payload. A state is always
        linked to either a bot, a conversation or a user.
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````