Terraform
- Terraform Enterprise
- 1.0.x (latest)
- v202507-1
- v202506-1
- v202505-1
- v202504-1
- v202503-1
- v202502-2
- v202501-1
- v202411-2
- v202411-1
- v202410-1
- v202409-3
- v202409-2
- v202409-1
- v202408-1
- No versions of this document exist before v202408-1. Click below to redirect to the version homepage.
- v202407-1
- v202406-1
- v202405-1
- v202404-2
- v202404-1
- v202402-2
- v202402-1
- v202401-2
- v202401-1
- v202312-1
- v202311-1
- v202310-1
- v202309-1
- v202308-1
- v202307-1
- v202306-1
- v202305-2
- v202305-1
- v202304-1
- v202303-1
- v202302-1
- v202301-2
- v202301-1
- v202212-2
- v202212-1
- v202211-1
- v202210-1
- v202209-2
- v202209-1
- v202208-3
- v202208-2
- v202208-1
- v202207-2
- v202207-1
- v202206-1
Plan exports API reference
Plan exports allow users to download data exported from the plan of a Run in a Terraform workspace. Currently, the only supported format for exporting plan data is to generate mock data for Sentinel.
Create a plan export
POST /plan-exports
This endpoint exports data from a plan in the specified format. The export process is asynchronous, and the resulting data becomes downloadable when its status is "finished". The data is then available for one hour before expiring. After the hour is up, a new export can be created.
| Status | Response | Reason |
|---|---|---|
| 201 | JSON API document (type: "plan-exports") | Successfully created a plan export |
| 404 | JSON API error object | Plan not found, or user unauthorized to perform action |
| 422 | JSON API error object | Malformed request body (missing attributes, wrong types, etc.), or a plan export of the provided data-type is already pending or downloadable for this plan |
Request Body
This POST endpoint requires a JSON object with the following properties as a request payload.
Properties without a default value are required.
| Key path | Type | Default | Description |
|---|---|---|---|
data.type | string | Must be "plan-exports". | |
data.attributes.data-type | string | The format for the export. Currently, the only supported format is "sentinel-mock-bundle-v0". | |
data.relationships.plan.data | object | A JSON API relationship object that represents the plan being exported. This object must have a type of plans, and the id of a finished Terraform plan that does not already have a downloadable export of the specified data-type (e.g: {"type": "plans", "id": "plan-8F5JFydVYAmtTjET"}) |
Sample Payload
{
"data": {
"type": "plan-exports",
"attributes": {
"data-type": "sentinel-mock-bundle-v0"
},
"relationships": {
"plan": {
"data": {
"id": "plan-8F5JFydVYAmtTjET",
"type": "plans"
}
}
}
}
}
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/plan-exports
Sample Response
{
"data": {
"id": "pe-3yVQZvHzf5j3WRJ1",
"type": "plan-exports",
"attributes": {
"data-type": "sentinel-mock-bundle-v0",
"status": "queued",
"status-timestamps": {
"queued-at": "2019-03-04T22:29:53+00:00",
},
},
"relationships": {
"plan": {
"data": {
"id": "plan-8F5JFydVYAmtTjET",
"type": "plans"
}
}
},
"links": {
"self": "/api/v2/plan-exports/pe-3yVQZvHzf5j3WRJ1",
}
}
}
Show a plan export
GET /plan-exports/:id
| Parameter | Description |
|---|---|
id | The ID of the plan export to show. |
There is no endpoint to list plan exports. You can find IDs for plan exports in the
relationships.exports property of a plan object.
| Status | Response | Reason |
|---|---|---|
| 200 | JSON API document (type: "plan-exports") | The request was successful |
| 404 | JSON API error object | Plan export not found, or user unauthorized to perform action |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
https://app.terraform.io/api/v2/plan-exports/pe-3yVQZvHzf5j3WRJ1
Sample Response
{
"data": {
"id": "pe-3yVQZvHzf5j3WRJ1",
"type": "plan-exports",
"attributes": {
"data-type": "sentinel-mock-bundle-v0",
"status": "finished",
"status-timestamps": {
"queued-at": "2019-03-04T22:29:53+00:00",
"finished-at": "2019-03-04T22:29:58+00:00",
"expired-at": "2019-03-04T23:29:58+00:00"
},
},
"relationships": {
"plan": {
"data": {
"id": "plan-8F5JFydVYAmtTjET",
"type": "plans"
}
}
},
"links": {
"self": "/api/v2/plan-exports/pe-3yVQZvHzf5j3WRJ1",
"download": "/api/v2/plan-exports/pe-3yVQZvHzf5j3WRJ1/download"
}
}
}
Download exported plan data
GET /plan-exports/:id/download
This endpoint generates a temporary URL to the location of the exported plan data in a .tar.gz archive, and then redirects to that link. If using a client that can follow redirects, you can use this endpoint to save the .tar.gz archive locally without needing to save the temporary URL.
| Status | Response | Reason |
|---|---|---|
| 302 | HTTP Redirect | Plan export found and temporary download URL generated |
| 404 | JSON API error object | Plan export not found, or user unauthorized to perform action |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--location \
https://app.terraform.io/api/v2/plan-exports/pe-3yVQZvHzf5j3WRJ1/download \
> export.tar.gz
Delete exported plan data
DELETE /plan-exports/:id
Plan exports expire after being available for one hour, but they can be deleted manually as well.
| Status | Response | Reason |
|---|---|---|
| 204 | No content | Plan export deleted successfully |
| 404 | JSON API error object | Plan export not found, or user unauthorized to perform action |
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
-X DELETE \
https://app.terraform.io/api/v2/plan-exports/pe-3yVQZvHzf5j3WRJ1