> ## Documentation Index
> Fetch the complete documentation index at: https://ravion-b90c0359-siddharth-eng-4903.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Force-release a stack's Terraform state lock

> Release a state lock that outlived the run holding it, so the stack can
run again. Only stacks that store their Terraform state in Ravion can be
unlocked this way; a stack pointed at a state backend you manage yourself
returns 422. An active run on the stack still holds its lock legitimately,
and the request returns 409 naming that run — wait for it to complete, or
cancel it. The `force` parameter covers the one exception. Unlocking
discards a state write that the interrupted run had reserved and never
finished; state from completed operations is untouched. Unlocking an
already-unlocked stack succeeds and changes nothing.



## OpenAPI

````yaml https://api.ravion.com/openapi.yaml post /stacks/{id}/unlock
openapi: 3.0.0
info:
  title: Ravion
  version: 0.0.0
servers:
  - url: https://api.ravion.com
security:
  - BearerAuth: []
tags:
  - name: Projects
  - name: Environments
  - name: Pipelines
  - name: PipelineRuns
  - name: TerraformResources
  - name: TerraformExecutionSummaries
  - name: PipelineStepExecutions
  - name: AwsCloudWatch
  - name: PipelineVersions
  - name: Organizations
  - name: Stacks
  - name: StackWorkspaces
  - name: Auth
  - name: OAuth
  - name: User
  - name: Health
  - name: Memberships
  - name: ServiceAccounts
  - name: AwsDefaultNetworks
  - name: AwsAccounts
  - name: ApiKeys
  - name: ExecutionEnvironments
  - name: ModuleDefinitions
  - name: ModuleVersions
  - name: ModuleInstances
  - name: DefaultValueDefinitions
  - name: DefaultValues
  - name: CodeSources
  - name: Github
  - name: Gitlab
  - name: Git
  - name: Values
  - name: Deployments
  - name: DeploymentResources
  - name: InfrastructureEvents
  - name: WebSocket
  - name: Describe
  - name: Reports
paths:
  /stacks/{id}/unlock:
    post:
      tags:
        - Stacks
      summary: Force-release a stack's Terraform state lock
      description: >-
        Release a state lock that outlived the run holding it, so the stack can

        run again. Only stacks that store their Terraform state in Ravion can be

        unlocked this way; a stack pointed at a state backend you manage
        yourself

        returns 422. An active run on the stack still holds its lock
        legitimately,

        and the request returns 409 naming that run — wait for it to complete,
        or

        cancel it. The `force` parameter covers the one exception. Unlocking

        discards a state write that the interrupted run had reserved and never

        finished; state from completed operations is untouched. Unlocking an

        already-unlocked stack succeeds and changes nothing.
      operationId: UnlockStack
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
        - description: >-
            Release the lock while a run is still active on the stack. This
            covers a run that never completes and does not respond to
            cancellation, which is not expected behaviour. That run keeps going,
            and its state write is refused once the lock is gone, so the run
            fails and any cloud resources it already changed go unrecorded.
            State from completed operations is untouched. Cancel the run first
            whenever cancellation succeeds.
          in: query
          name: force
          schema:
            nullable: true
            type: boolean
      responses:
        '200':
          content:
            application/json:
              schema:
                additionalProperties: false
                properties:
                  data:
                    $ref: '#/components/schemas/Stack.Lock'
                required:
                  - data
                type: object
          description: The request has succeeded.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: You are not authenticated
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: You do not have permission to access this resource.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: The server cannot find the requested resource.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: The request conflicts with the current state of the server.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: Client error
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: Server error
components:
  schemas:
    Stack.Lock:
      additionalProperties: false
      description: The state lock on a stack whose Terraform state Ravion stores.
      properties:
        lockId:
          description: Identifier of the current lock.
          type: string
        locked:
          description: >-
            True while the state is locked. Terraform holds the lock for the
            duration of every operation that touches state, including `plan`.
          type: boolean
        lockedAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          description: When the current lock was taken.
        lockedBy:
          description: >-
            The principal that took the current lock, as recorded by the state
            backend.
          type: string
        pipelineRunId:
          description: >-
            The pipeline run that took the current lock. Absent for a lock taken
            outside a pipeline run.
          type: string
        stackId:
          description: The stack ID.
          type: string
        stepExecutionId:
          description: >-
            The pipeline step execution that took the current lock. Absent for a
            lock taken outside a pipeline run.
          type: string
        workspaceName:
          description: >-
            Name of the Ravion-hosted workspace holding this stack's Terraform
            state.
          type: string
      required:
        - stackId
        - workspaceName
        - locked
      type: object
    Errors.UserFacingErrorData:
      additionalProperties: false
      description: |-
        User-facing error presentation data.
        This is what the API returns to the frontend after formatting ErrorData
        using CEL templates from the error registry.

        Used for both:
        - Error fields on domain models (e.g., PipelineRun.error)
        - API error response bodies (HTTP 4xx/5xx responses)
      properties:
        action:
          allOf:
            - $ref: '#/components/schemas/Errors.Action'
          description: Optional action to help resolve the error
        code:
          description: Full error code, e.g., "Ravion:Pipeline:NOT_FOUND"
          type: string
        description:
          description: Additional description with more details
          type: string
        details:
          description: Structured details rendered as user-facing sections.
          items:
            $ref: '#/components/schemas/Errors.UserFacingErrorDetailSection'
          type: array
        isInternal:
          description: >-
            Indicates whether this error is internal (only set when
            ShowInternal=true).

            This allows SUPERADMINs to identify internal errors while viewing
            full details.
          type: boolean
        message:
          description: Main error message (required)
          type: string
        metadata:
          additionalProperties: {}
          description: >-
            Error params/metadata. Stripped for internal errors unless
            superadmin.
          type: object
        requestId:
          description: Request ID for correlating errors with server logs.
          type: string
      required:
        - code
        - message
      type: object
    UtcDateTime:
      description: UTC RFC3339 timestamp with a required Z suffix
      format: date-time
      pattern: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z$
      type: string
      x-go-type: apitypes.UTCDateTime
      x-go-type-import:
        name: apitypes
        path: ravion/api-go/pkg/apitypes
    Errors.Action:
      additionalProperties: false
      description: Action to help user resolve the error
      properties:
        label:
          description: Button/link label text
          type: string
        url:
          description: URL to navigate to for resolution
          type: string
      required:
        - label
        - url
      type: object
    Errors.UserFacingErrorDetailSection:
      additionalProperties: false
      description: Structured user-facing error detail section.
      properties:
        items:
          description: List of detail values for this section.
          items:
            type: string
          type: array
        object:
          additionalProperties: {}
          description: Structured detail payload for object rendering.
          type: object
        render:
          description: Rendering hint for clients. Valid values are list or object.
          type: string
        title:
          description: Detail section title shown in the UI.
          type: string
      required:
        - title
        - render
      type: object
  securitySchemes:
    BearerAuth:
      scheme: Bearer
      type: http

````