• Overview
    • Enforce Policy as Code
    • Infrastructure as Code
    • Inject Secrets into Terraform
    • Integrate with Existing Workflows
    • Manage Kubernetes
    • Manage Virtual Machine Images
    • Multi-Cloud Deployment
    • Network Infrastructure Automation
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
  • Registry
  • Tutorials
    • About the Docs
    • Intro to Terraform
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
    • Terraform Tools
    • CDK for Terraform
    • Glossary
  • Community
GitHubTerraform Cloud
Download

    Terraform Cloud and Enterprise

  • Overview
  • Plans and Features
  • Getting Started
    • API Docs template
    • Overview
    • Account
    • Agent Pools
    • Agent Tokens
    • Applies
    • Audit Trails
    • Comments
    • Configuration Versions
    • Cost Estimates
    • Feature Sets
    • Invoices
    • IP Ranges
    • Notification Configurations
    • OAuth Clients
    • OAuth Tokens
    • Organizations
    • Organization Memberships
    • Organization Tags
    • Organization Tokens
    • Plan Exports
    • Plans
    • Policies
    • Policy Checks
    • Policy Sets
    • Policy Set Parameters
      • Modules
      • Providers
      • Private Provider Versions and Platforms
      • GPG Keys
    • Runs
      • Run Tasks
      • Stages and Results
      • Custom Integration
    • Run Triggers
    • SSH Keys
    • State Versions
    • State Version Outputs
    • Subscriptions
    • Team Access
    • Team Membership
    • Team Tokens
    • Teams
    • User Tokens
    • Users
    • Variables
    • VCS Events
    • Workspaces
    • Workspace-Specific Variables
    • Workspace Resources
    • Variable Sets
      • Overview
      • Module Sharing
      • Organizations
      • Runs
      • Settings
      • Terraform Versions
      • Users
      • Workspaces
    • Changelog
    • Stability Policy
    • Overview
    • Creating Workspaces
    • Naming
    • Terraform Configurations
      • Overview
      • Managing Variables
      • Overview
      • VCS Connections
      • Access
      • Drift Detection
      • Notifications
      • SSH Keys for Modules
      • Run Triggers
      • Run Tasks
    • Terraform State
    • JSON Filtering
    • Remote Operations
    • Viewing and Managing Runs
    • Run States and Stages
    • Run Modes and Options
    • UI/VCS-driven Runs
    • API-driven Runs
    • CLI-driven Runs
    • The Run Environment
    • Installing Software
    • Users
    • Teams
    • Organizations
    • Permissions
    • Two-factor Authentication
    • API Tokens
      • Overview
      • Microsoft Azure AD
      • Okta
      • SAML
      • Linking a User Account
      • Testing
    • Overview
    • GitHub.com
    • GitHub.com (OAuth)
    • GitHub Enterprise
    • GitLab.com
    • GitLab EE and CE
    • Bitbucket Cloud
    • Bitbucket Server and Data Center
    • Azure DevOps Services
    • Azure DevOps Server
    • Troubleshooting
    • Overview
    • Adding Public Providers and Modules
    • Publishing Private Providers
    • Publishing Private Modules
    • Using Providers and Modules
    • Configuration Designer
  • Migrating to Terraform Cloud
    • Overview
    • Using Sentinel with Terraform 0.12
    • Manage Policies
    • Enforce and Override Policies
    • Mocking Terraform Sentinel Data
    • Working With JSON Result Data
      • Overview
      • tfconfig
      • tfconfig/v2
      • tfplan
      • tfplan/v2
      • tfstate
      • tfstate/v2
      • tfrun
    • Example Policies
    • Overview
    • AWS
    • GCP
    • Azure
      • Overview
      • Service Catalog
      • Admin Guide
      • Developer Reference
      • Example Customizations
      • V1 Setup Instructions
    • Splunk Integration
    • Kubernetes Integration
    • Run Tasks Integration
    • Overview
    • IP Ranges
    • Data Security
    • Security Model
    • Overview
    • Part 1: Overview of Our Recommended Workflow
    • Part 2: Evaluating Your Current Provisioning Practices
    • Part 3: How to Evolve Your Provisioning Practices
    • Part 3.1: From Manual Changes to Semi-Automation
    • Part 3.2: From Semi-Automation to Infrastructure as Code
    • Part 3.3: From Infrastructure as Code to Collaborative Infrastructure as Code
    • Part 3.4: Advanced Workflow Improvements

  • Terraform Cloud Agents

  • Terraform Enterprise Admin

  • Other Docs

  • Intro to Terraform
  • Configuration Language
  • Terraform CLI
  • Terraform Cloud
  • Terraform Enterprise
  • Provider Use
  • Plugin Development
  • Registry Publishing
  • Integration Program
  • Terraform Tools
  • CDK for Terraform
  • Glossary
Type '/' to Search

»Admin Runs API

Terraform Enterprise feature: The admin API is exclusive to Terraform Enterprise, and can only be used by the admins and operators who install and maintain their organization's Terraform Enterprise instance.

These API endpoints are available in Terraform Enterprise as of version 201807-1.

The Runs Admin API contains endpoints to help site administrators manage runs.

»List all runs

GET /api/v2/admin/runs

This endpoint lists all runs in the Terraform Enterprise installation.

StatusResponseReason
200JSON API document (type: "runs")Successfully listed runs
404JSON API error objectClient is not an administrator.

»Query Parameters

These are standard URL query parameters. Remember to percent-encode [ as %5B and ] as %5D if your tooling doesn't automatically encode URLs.

ParameterDescription
qOptional. A search query string. Runs are searchable by ID, workspace name, organization name or email, and VCS repository identifier.
filter[status]Optional. A comma-separated list of Run statuses to restrict results to, which can include any of the following: "pending", "plan_queued", "planning", "planned", "confirmed", "apply_queued", "applying", "applied", "discarded", "errored", "canceled", "cost_estimating", "cost_estimated", "policy_checking", "policy_override", "policy_soft_failed", "policy_checked", and "planned_and_finished".
page[number]Optional. If omitted, the endpoint will return the first page.
page[size]Optional. If omitted, the endpoint will return 20 runs per page.

A VCS repository identifier is a reference to a VCS repository in the format :org/:repo, where :org and :repo refer to the organization (or project) and repository in your VCS provider.

»Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  "https://app.terraform.io/api/v2/admin/runs"
curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  "https://app.terraform.io/api/v2/admin/runs"

»Sample Response

{
  "data": [
    {
      "id": "run-VCsNJXa59eUza53R",
      "type": "runs",
      "attributes": {
        "status": "pending",
        "status-timestamps": {
          "planned-at": "2018-03-02T23:42:06+00:00",
          "discarded-at": "2018-03-02T23:42:06+00:00"
        },
        "has-changes": true,
        "created-at": "2018-03-02T23:42:06.651Z"
      },
      "relationships": {
        "workspace": {
          "data": {
            "id": "ws-mJtb6bXGybq5zbf3",
            "type": "workspaces"
          }
        }
      },
      "links": {
        "self": "/api/v2/runs/run-VCsNJXa59eUza53R"
      }
    }
  ],
  "links": {
    "self": "https://app.terraform.io/api/v2/admin/runs?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "first": "https://app.terraform.io/api/v2/admin/runs?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "prev": null,
    "next": null,
    "last": "https://app.terraform.io/api/v2/admin/runs?page%5Bnumber%5D=1&page%5Bsize%5D=20"
  },
  "meta": {
    "pagination": {
      "current-page": 1,
      "prev-page": null,
      "next-page": null,
      "total-pages": 1,
      "total-count": 1
    },
    "status-counts": {
      "pending": 1,
      "planning": 0,
      "planned": 0,
      "confirmed": 0,
      "applying": 0,
      "applied": 0,
      "discarded": 0,
      "errored": 0,
      "canceled": 0,
      "policy-checking": 0,
      "policy-override": 0,
      "policy-checked": 0,
      "total": 1
    }
  }
}
{
  "data": [
    {
      "id": "run-VCsNJXa59eUza53R",
      "type": "runs",
      "attributes": {
        "status": "pending",
        "status-timestamps": {
          "planned-at": "2018-03-02T23:42:06+00:00",
          "discarded-at": "2018-03-02T23:42:06+00:00"
        },
        "has-changes": true,
        "created-at": "2018-03-02T23:42:06.651Z"
      },
      "relationships": {
        "workspace": {
          "data": {
            "id": "ws-mJtb6bXGybq5zbf3",
            "type": "workspaces"
          }
        }
      },
      "links": {
        "self": "/api/v2/runs/run-VCsNJXa59eUza53R"
      }
    }
  ],
  "links": {
    "self": "https://app.terraform.io/api/v2/admin/runs?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "first": "https://app.terraform.io/api/v2/admin/runs?page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "prev": null,
    "next": null,
    "last": "https://app.terraform.io/api/v2/admin/runs?page%5Bnumber%5D=1&page%5Bsize%5D=20"
  },
  "meta": {
    "pagination": {
      "current-page": 1,
      "prev-page": null,
      "next-page": null,
      "total-pages": 1,
      "total-count": 1
    },
    "status-counts": {
      "pending": 1,
      "planning": 0,
      "planned": 0,
      "confirmed": 0,
      "applying": 0,
      "applied": 0,
      "discarded": 0,
      "errored": 0,
      "canceled": 0,
      "policy-checking": 0,
      "policy-override": 0,
      "policy-checked": 0,
      "total": 1
    }
  }
}

»Force a run into the "cancelled" state

POST /admin/runs/:id/actions/force-cancel

ParameterDescription
:idThe ID of the run to cancel.

This endpoint forces a run (and its plan/apply, if applicable) into the "canceled" state. This action should only be performed for runs that are stuck and no longer progressing normally, as there is a risk of lost state data if a progressing apply is force-canceled. Healthy runs can be requested for cancellation by end-users.

StatusResponseReason
200JSON API document (type: "runs")Successfully canceled the run.
404JSON API error objectRun not found, or client is not an administrator.

»Request body

This POST endpoint allows an optional JSON object with the following properties as a request payload.

Key pathTypeDefaultDescription
commentstringnullAn optional explanation for why the run was force-canceled.

»Sample Payload

{
  "comment": "This run was stuck and would never finish."
}
{
  "comment": "This run was stuck and would never finish."
}

»Sample Request

curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  --data @payload.json \
  "https://app.terraform.io/api/v2/admin/runs/run-VCsNJXa59eUza53R/actions/force-cancel"
curl \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/vnd.api+json" \
  --request POST \
  --data @payload.json \
  "https://app.terraform.io/api/v2/admin/runs/run-VCsNJXa59eUza53R/actions/force-cancel"

»Sample Response

{
  "data": {
    "id": "run-VCsNJXa59eUza53R",
    "type": "runs",
    "attributes": {
      "status": "errored",
      "status-timestamps": {
        "planned-at": "2018-03-02T23:42:06Z"
      },
      "has-changes": true,
      "created-at": "2018-03-02T23:42:06.651Z"
    },
    "relationships": {
      "workspace": {
        "data": {
          "id": "ws-mJtb6bXGybq5zbf3",
          "type": "workspaces"
        }
      }
    },
    "links": {
      "self": "/api/v2/runs/run-VCsNJXa59eUza53R"
    }
  }
}
{
  "data": {
    "id": "run-VCsNJXa59eUza53R",
    "type": "runs",
    "attributes": {
      "status": "errored",
      "status-timestamps": {
        "planned-at": "2018-03-02T23:42:06Z"
      },
      "has-changes": true,
      "created-at": "2018-03-02T23:42:06.651Z"
    },
    "relationships": {
      "workspace": {
        "data": {
          "id": "ws-mJtb6bXGybq5zbf3",
          "type": "workspaces"
        }
      }
    },
    "links": {
      "self": "/api/v2/runs/run-VCsNJXa59eUza53R"
    }
  }
}

»Available Related Resources

This GET endpoint can optionally return related resources, if requested with the include query parameter. The following resource types are available:

Resource NameDescription
workspaceThe workspace this run belongs in.
workspace.organizationThe organization of the associated workspace.
workspace.organization.ownersThe owners of the organization of the associated workspace.
github logoEdit this page
  • Overview
  • Docs
  • Extend
  • Privacy
  • Security
  • Press Kit
  • Consent Manager