> ## 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.

# Compare explicit prior state with current state



## OpenAPI

````yaml /api-reference/openapi.json post /api/sessions/{sessionId}/environments/{environmentId}/state/diff
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/diff:
    post:
      summary: Compare explicit prior state with current state
      operationId: diffEnvironmentState
      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
              properties:
                source:
                  type: string
                  const: explicit
                before: {}
                maxChanges:
                  type: integer
                  minimum: 1
                  maximum: 1000
              required:
                - source
                - before
              additionalProperties: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  schema:
                    type: string
                    const: archal.environment-state-diff
                  version:
                    type: number
                    const: 1
                  sessionId:
                    type: string
                    minLength: 1
                  environmentId:
                    type: string
                    minLength: 1
                    maxLength: 80
                  beforeSha256:
                    type: string
                    pattern: ^[a-f0-9]{64}$
                  afterSha256:
                    type: string
                    pattern: ^[a-f0-9]{64}$
                  changed:
                    type: boolean
                  totalChanges:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  returnedChanges:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  truncated:
                    type: boolean
                  changes:
                    type: array
                    items:
                      type: object
                      properties:
                        op:
                          type: string
                          enum:
                            - add
                            - remove
                            - replace
                        path:
                          type: string
                        before: {}
                        after: {}
                      required:
                        - op
                        - path
                      additionalProperties: false
                required:
                  - schema
                  - version
                  - sessionId
                  - environmentId
                  - beforeSha256
                  - afterSha256
                  - changed
                  - totalChanges
                  - returnedChanges
                  - truncated
                  - changes
                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
        '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

````