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

# Replace environment state and its reset baseline



## OpenAPI

````yaml /api-reference/openapi.json put /api/sessions/{sessionId}/environments/{environmentId}/state
openapi: 3.1.0
info:
  title: Archal API
  version: 1.0.0
  summary: >-
    Stateful testing environments with separate lifecycle and provider-scoped
    credentials
  description: >-
    Use a workspace credential for lifecycle operations. Each created
    environment returns a short-lived provider-shaped credential for its
    isolated data plane; the workspace credential is never forwarded to or
    accepted by provider-compatible endpoints.
servers:
  - url: https://api.archal.ai
security: []
paths:
  /api/sessions/{sessionId}/environments/{environmentId}/state:
    put:
      summary: Replace environment state and its reset baseline
      operationId: replaceEnvironmentState
      parameters:
        - name: sessionId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
        - name: environmentId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 80
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
          text/sql:
            schema:
              type: string
              minLength: 1
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    const: true
                  sessionId:
                    type: string
                  environmentId:
                    type: string
                  format:
                    enum:
                      - json
                      - sql
                  baselineUpdated:
                    const: true
                required:
                  - ok
                  - sessionId
                  - environmentId
                  - format
                  - baselineUpdated
                additionalProperties: false
        '400':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '401':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '403':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '404':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '409':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '413':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '415':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '429':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '500':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '502':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
        '503':
          description: The request was rejected
          headers:
            X-Request-Id:
              description: Request correlation identifier
              schema:
                type: string
            Retry-After:
              description: Seconds to wait before retrying when present
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                type: object
                properties:
                  ok:
                    type: boolean
                  error:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  issues:
                    type: array
                    items:
                      type: object
                      properties:
                        path:
                          type: string
                        message:
                          type: string
                      required:
                        - path
                        - message
                      additionalProperties: true
                additionalProperties: true
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Archal workspace API key
      description: Used by lifecycle, catalog, and state endpoints

````