Terraform
Explorer API
Explorer allows you to query your HCP Terraform data across workspaces in an organization. You can select from a variety of available views and supply optional sort and filter parameters to present your data in the format that best suits your needs.
Queries are scoped to the organization level. You must have owner permissions in the organization, or read access to workspaces and projects.
Execute a query
GET /organizations/:organization_name/explorer
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. The organization must already exist and you must have permissions to read the organization's workspaces and projects. |
Note: Explorer is restricted to the owners team, teams with the "Read all workspaces" permission, teams with the "Read all projects" permission, and the organization API token.
Explorer queries will time out after 60 seconds. If the desired query is timing out, try a simpler query that uses less filters.
Requests to the explorer are subject to rate limiting. Explorer will return a 429 status code when rate limiting is active for the authenticated context.
Data presented by the explorer is eventually consistent. Query results typically contain data that represents the current state of the system, but in some cases a small delay may be necessary before querying for data that has recently been updated.
Query parameters
This GET endpoint requires a query string that supports the following properties.
Parameter | Description |
---|---|
type | Required. Must be one of the following available views: workspaces , tf_versions , providers , or modules . See the View Types section for more information about each. |
sort | Optionally sort the returned data by the specified field name. The field name must use snake case and exist within the supplied view type. The field name supplied can be prefixed with a hyphen (- ) to perform a descending sort. |
filter | Optionally specify one or more filters to limit the data returned. See Filtering for more information. |
fields | Optionally limit the data returned only to the specified fields. The field names supplied must use snake case and be submitted in comma-separated format. If omitted, all available fields will be returned for the requested view type. |
page[number] | Optional. If omitted, the endpoint will return the first page. |
page[size] | Optional. If omitted, the endpoint will use a default page size. |
View Types
Explorer queries each require a view, specified by the type
query string parameter.
There are several contextual views available for querying:
Type | Description |
---|---|
workspaces | Information about the workspaces in the target organization and any current runs associated with them. Each row returned represents a single workspace. See View Type: workspaces for available fields. |
tf_versions | Information about the Terraform versions in use across this organization. Each row returned represents a Terraform version in use. See View Type: tf_versions for available fields. |
providers | Information about the Terraform providers in use across the target organization. Each row returned represents a Terraform provider in use. See View Type: providers for available fields. |
modules | Information about the Terraform modules in use across the target organization. Each row returned represents a Terraform module in use. See View Type: modules for available fields. |
The fields returned by a given query are specific to the view type used. The fields available for each view type are detailed below:
View Type: workspaces
Field | Type | Description |
---|---|---|
all_checks_succeeded | boolean | True if checks have succeeded for the workspace, false otherwise. |
checks_errored | number | The number of checks that errored without completing. |
checks_failed | number | The number of checks that completed and failed. |
checks_passed | number | The number of checks that completed and passed. |
checks_unknown | number | The number of checks that could not be assessed. |
current_run_applied_at | datetime | Represents the time that this workspace's current run was applied. |
current_run_external_id | string | The external ID of this workspace's current run. |
current_run_status | string | The status of this workspace's current run. |
drifted | boolean | True if drift has been detected for the workspace, false otherwise. |
external_id | string | The external ID of this workspace. |
module_count | number | The number of distinct modules used by this workspace. |
modules | string | A comma separated list of modules used by this workspace. |
organization_name | string | The name of the organization this workspace belongs to. |
project_external_id | string | The external ID of the project this workspace belongs to. |
project_name | string | The name of the project this workspace belongs to. |
provider_count | number | The number of distinct providers used in this workspace. |
providers | string | A comma separated list of providers used in this workspace. |
resources_drifted | number | The count of resources that drift was detected for. |
resources_undrifted | number | The count of resources that drift was not detected for. |
state_version_terraform_version | string | The Terraform version used to create the current run's state file. |
vcs_repo_identifier | string | The name of the repository configured for this workspace, if available. |
workspace_created_at | datetime | The time this workspace was created. |
workspace_name | string | The name of this workspace. |
workspace_terraform_version | string | The Terraform version currently configured for this workspace. |
workspace_updated_at | datetime | The time this workspace was last updated. |
View Type: tf_versions
Field | Type | Description |
---|---|---|
version | string | The semantic version string for this Terraform version. |
workspace_count | number | The number of workspaces using this terraform version. |
workspaces | string | A comma-separated list of workspaces using this terraform version. |
View Type: providers
Field | Type | Description |
---|---|---|
name | string | The name of this provider. |
source | string | The source of this provider. |
version | string | The semantic version string for this provider. |
workspace_count | number | The number of workspaces using this provider. |
workspaces | string | A comma-separated list of workspaces using this provider. |
View Type: modules
Field | Type | Description |
---|---|---|
name | string | The name of this module. |
source | string | The source of this module. |
version | string | The semantic version string for this module. |
workspace_count | number | The number of workspaces using this module version. |
workspaces | string | A comma-separated list of workspaces using this module version. |
Filtering
The explorer can present filtered data from any view type using a variety of operators.
Filter strings begin with the reserved string filter
, and are passed as URL
query string parameters using key-value pairs. The parameter key contains the
filter's target field and operator, and the parameter value contains the filter
value to be used during the query.
Multiple filters can be used in a query by providing multiple filter query
string parameters separated with &
. When multiple filters are used, a logical AND is used
to evaluate the results.
Each filter string must use the following format:
filter[<FILTER_INDEX>][<FIELD_NAME>][<FIELD_OPERATOR>][FIELD_VALUE_INDEX]=<FILTER VALUE>
Filter string sub-parameters
- FILTER_INDEX: The index of the filter. Each filter requires a unique
index. The first filter should use a
0
and each additional filter should use an index that is the previous filter's index incremented by 1. - FIELD_NAME: The name of the field to apply the filter to. The field must be a valid field for the view type being queried. See View Types for a list of fields available for each type.
- FIELD_OPERATOR: The operator to use when filtering. Must be supported by the field type being filtered. See Filter Operators for the available operators and their supported field types.
- FIELD_VALUE_INDEX: Must be
0
. This sub-parameter is reserved for future use. - FILTER_VALUE: The filter value used by the filter during the query.
Once the desired filter strings have been added to a request URI, they should be percent-encoded along with the rest of the query string parameters.
Sample Filter Strings
View Type: workspace
Show workspaces that contain test
in their name:
filter[0][workspace_name][contains][0]=test
After encoding:
filter%5B0%5D%5Bworkspace_name%5D%5Bcontains%5D%5B0%5D=test
View Type: modules
Show modules that contain aws
in their name and version string equal to 1.1
filter[0][name][contains][0]=aws&filter[0][version][is][0]=1.1
After encoding:
filter%5B0%5D%5Bname%5D%5Bcontains%5D%5B0%5D=aws&filter%5B0%5D%5Bversion%5D%5Bis%5D%5B0%5D=1.1
Filter Operators
Operator | Supported Field Types | Description |
---|---|---|
is | boolean , number , string | Filters data to rows where the field value is equivalent to the filter value. |
is_not | number , string | Filters data to rows where the field value is different from the filter value. |
contains | string | Filters data to rows where the field value contains the filter value as a sub-string. |
does not contain | string | Filters data to rows where the field value does not contain the filter value as a sub-string. |
is_empty | boolean , number , string | Filters data to rows where the field does not contain a value. |
is_not_empty | boolean , number , string | Filters data to rows where the field contains any value. |
gt | number | Filters data to rows where the field value is greater than the filter value. |
lt | number | Filters data to rows where the field value is less than the filter value. |
gteq | number | Filters data to rows where the field value is greater than or equal to the filter value. |
lteq | number | Filters data to rows where the field value is less than or equal to the filter value. |
is_before | datetime | Filters data to rows |
where the field value is earlier than the filter value. ISO 8601 formatted timestamps are required for filter values. If no time zone offset is provided, the filter value will be interpreted as UTC. | ||
is_after | datetime | Filters data to rows |
where the field value is earlier than the filter value. ISO 8601 formatted timestamps are required for filter values. If no time zone offset is provided, the filter value will be interpreted as UTC. |
Pagination
This endpoint supports pagination with standard URL query parameters. Remember to percent-encode [
as %5B
and ]
as %5D
if your tooling doesn't automatically encode URLs.
Sample requests
View Type: workspaces
Show data for all workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=workspaces'
Show data for all workspaces with test
in their name
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=workspaces&&filter%5B0%5D%5Bworkspace_name%5D%5Bcontains%5D%5B0%5D=test'
View Type: modules
Show modules used across all workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=modules'
Show public modules only
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=modules&filter%5B0%5D%5Bregistry_type%5D%5Bis%5D%5B0%5D=public'
View Type: provider
Show providers used across all workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=providers'
Show most used providers across all workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=providers&sort=-workspace_count'
View Type: tf_versions
Show Terraform versions used across all workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=tf_versions'
Show all Terraform versions used in more than 10 workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer?type=tf_versions&filter%5B0%5D%5Bworkspace_count%5D%5Bgt%5D%5B0%5D=10'
Sample response
Show data for all workspaces
{
"data": [
{
"attributes": {
"all-checks-succeeded": true,
"checks-errored": 0,
"checks-failed": 0,
"checks-passed": 0,
"checks-unknown": 0,
"current-run-applied-at": null,
"current-run-external-id": "run-rdoEKh2Gy3K6SbCZ",
"current-run-status": "planned_and_finished",
"drifted": false,
"external-id": "ws-j2sAeWRxou1b5HYf",
"module-count": 0,
"modules": null,
"organization-name": "acme-corp",
"project-external-id": "prj-V61QLE8tvs4NvVZG",
"project-name": "Default Project",
"provider-count": 0,
"providers": null,
"resources-drifted": 0,
"resources-undrifted": 0,
"state-version-terraform-version": "1.5.7",
"vcs-repo-identifier": null,
"workspace-created-at": "2023-10-17T21:56:45.570+00:00",
"workspace-name": "payments-service",
"workspace-terraform-version": "1.5.7",
"workspace-updated-at": "2023-12-08T19:58:15.513+00:00"
},
"id": "ws-j2sAWeRxuo1b5HYf",
"type": "visibility-workspace"
},
{
"attributes": {
"all-checks-succeeded": true,
"checks-errored": 0,
"checks-failed": 0,
"checks-passed": 0,
"checks-unknown": 0,
"current-run-applied-at": "2023-08-18T16:24:59.000+00:00",
"current-run-external-id": "run-9MmJaoQTvDCh5wUa",
"current-run-status": "applied",
"drifted": true,
"external-id": "ws-igUVNQSYVXRkhYuo",
"module-count": 0,
"modules": null,
"organization-name": "acme-corp",
"project-external-id": "prj-uU2xNqGeG86U9WgT",
"project-name": "web",
"provider-count": 0,
"providers": null,
"resources-drifted": 3,
"resources-undrifted": 3,
"state-version-terraform-version": "1.4.5",
"vcs-repo-identifier": "acmecorp/api",
"workspace-created-at": "2023-04-25T17:09:14.960+00:00",
"workspace-name": "api-service",
"workspace-terraform-version": "1.4.5",
"workspace-updated-at": "2023-12-08T20:43:16.779+00:00"
},
"id": "ws-igUNVQSYXVRkhYuo",
"type": "visibility-workspace"
}
],
"links": {
"self": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces",
"first": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces",
"last": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces",
"prev": null,
"next": null
},
"meta": {
"pagination": {
"current-page": 1,
"page-size": 20,
"next-page": null,
"prev-page": null,
"total-pages": 1,
"total-count": 2
}
}
}
Export data as CSV
GET /organizations/:organization_name/explorer/export/csv
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. The organization must already exist in the system, and the user must have permissions to read the workspaces and projects within it. |
This endpoint can be used to download a full, unpaged export of the query results in CSV format (with the filter, sort, and field selections applied).
Explorer queries will time out after 60 seconds. If the desired query is timing out, try a simpler query that uses less filters.
Requests to the explorer are subject to rate limiting. Explorer will return a 429 status code when rate limiting is active for the authenticated context.
Data presented by the explorer is eventually consistent. Query results typically contain data that represents the current state of the system, but in some cases a small delay may be necessary before querying for data that has recently been updated.
Query parameters
This GET endpoint supports the same query string parameters as the Explorer Query endpoint.
Sample requests
View Type: workspaces
Show data for all workspaces
curl \
--header "Authorization: Bearer $TOKEN" \
https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/export/csv?type=workspaces
Sample response
Show data for all workspaces
all_checks_succeeded,checks_errored,checks_failed,checks_passed,checks_unknown,current_run_applied_at,current_run_external_id,current_run_status,drifted,external_id,module_count,modules,organization_name,project_external_id,project_name,provider_count,providers,resources_drifted,resources_undrifted,state_version_terraform_version,vcs_repo_identifier,workspace_created_at,workspace_name,workspace_terraform_version,workspace_updated_at
"true","0","0","0","0","","run-rdoEKh2Gy3K6SbCZ","planned_and_finished","false","ws-j2sAeWRxou1b5HYf","0","","acme-corp","prj-V61QLE8tvs4NvVZG","Default Project","0","","0","0","1.5.7","","2023-10-17T21:56:45+00:00","payments-service","1.5.7","2023-12-13T15:48:16+00:00"
"true","0","0","0","0","2023-08-18T16:24:59+00:00","run-9MmJaoQTvDCh5wUa","applied","true","ws-igUVNQSYVXRkhYuo","0","","acme-corp","prj-uU2xNqGeG86U9WgT","web","0","","3","3","1.4.5","acmecorp/api","2023-04-25T17:09:14+00:00","api-service","1.4.5","2023-12-13T15:29:03+00:00"
List saved views
Note: The ability to save views in the explorer is in public beta. All APIs and workflows are subject to change.
Use this endpoint to display all of the explorer's saved views in an organization.
GET /api/v2/organizations/:organization_name/explorer/views
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request GET \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/views'
Sample response
{
"data": [{
"id": "sq-P9Yn6Ad6EiVMz77s",
"type": "explorer-saved-queries",
"attributes": {
"name": "my saved query",
"created-at": "2024-10-11T16:18:51.442Z",
"query": {
"filter": [{
"field": "workspace_name",
"operator": "contains",
"value": ["child"],
},
{
"field": "workspace_name",
"operator": "contains",
"value": ["-"],
}],
"type": "workspaces"
},
"query-type": "workspaces"
}
}]
}
Create saved view
Note: The ability to save views in the explorer is in public beta. All APIs and workflows are subject to change.
Use this endpoint to create a saved view in the explorer.
POST /api/v2/organizations/:organization_name/explorer/views
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
To create a saved view, provide the following data in your payload.
Key path | Type | Default | Description |
---|---|---|---|
data.name | string | The name of the saved view. | |
data.query_type | string | The primary type that the view is querying. Refer to View Types for details. | |
data.query | object | A list of filters, fields, and sorting rules for the view. Refer to Query parameters for full details. | |
data.query.filter | array[objects] | A list of filters composed of fields, operators, and values. | |
data.query.filter.field | string | The field name to filter by. | |
data.query.filter.operator | string | The operator applied to field and value. | |
data.query.filter.value | array[strings] | A list of values to filter by. | |
data.query.fields | array[strings] | A list of fields to include in the view. | |
data.query.sort | array[strings] | A list of fields to sort by. Prefix with - for descending sort. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request POST \
--data @payload.json \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/views'
Sample response
{
"data": {
"id": "sq-P9Yn6Ad6EiVMz77s",
"type": "explorer-saved-queries",
"attributes": {
"name": "my saved query",
"created-at": "2024-10-11T16:18:51.442Z",
"query": {
"filter": [{
"field": "workspace_name",
"operator": "contains",
"value": ["child"],
},
{
"field": "workspace_name",
"operator": "contains",
"value": ["-"],
}],
"type": "workspaces"
},
"query-type": "workspaces"
}
}
}
Show saved view
Use this endpoint to display a specific saved view from the explorer.
GET /api/v2/organizations/:organization_name/explorer/views/:view_id
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
:view_id | The ID of the saved view to show. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request GET \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/views/$VIEW_ID`
Sample response
{
"data": {
"id": "sq-P9Yn6Ad6EiVMz77s",
"type": "explorer-saved-queries",
"attributes": {
"name": "my saved query",
"created-at": "2024-10-11T16:18:51.442Z",
"query": {
"filter": [{
"field": "workspace_name",
"operator": "contains",
"value": ["child"],
},
{
"field": "workspace_name",
"operator": "contains",
"value": ["-"],
}],
"type": "workspaces"
},
"query-type": "workspaces"
}
}
}
Update a saved view
Use this endpoint to update the data a saved view queries.
PATCH /api/v2/organizations/:organization_name/explorer/views/:view_id
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
:view_id | The external id of the saved view to update. |
You must have the following fields in the payload for your request.
Key path | Type | Default | Description |
---|---|---|---|
data.name | string | The name of the saved view. | |
data.query | object | A list of filters, fields, and sorting rules for the view. See Query parameters for full details. | |
data.query.filter | array[objects] | A list of filters composed of fields, operators, and values. See Filtering for more information. | |
data.query.filter.field | string | The field name to filter by. | |
data.query.filter.operator | string | The operator applied to field and value. | |
data.query.filter.value | array[strings] | A list of values to filter by. | |
data.query.fields | array[strings] | A list of fields to include in the view. Refer to execute a query for a list of available parameters. | |
data.query.sort | array[strings] | A list of fields to sort by. Prefix with - for descending sort. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request PATCH \
--data @payload.json \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/viewsi/$VIEW_ID'
Sample response
{
"data": {
"id": "sq-P9Yn6Ad6EiVMz77s",
"type": "explorer-saved-queries",
"attributes": {
"name": "my saved query",
"created-at": "2024-10-11T16:18:51.442Z",
"query": {
"filter": [{
"field": "workspace_name",
"operator": "contains",
"value": ["candy"],
},
{
"field": "workspace_name",
"operator": "contains",
"value": ["pumpkins"],
}],
"type": "workspaces"
},
"query-type": "workspaces"
}
}
}
Delete a saved view
Use this endpoint to delete a saved view.
DELETE /api/v2/organizations/:organization_name/explorer/views/:view_id
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
:view_id | The ID of the saved view you want to delete. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request DELETE \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/views/$VIEW_ID`
Sample response
{
"data": {
"id": "sq-P9Yn6Ad6EiVMz77s",
"type": "explorer-saved-queries",
"attributes": {
"name": "my saved query",
"created-at": "2024-10-11T16:18:51.442Z",
"query": {
"filter": [{
"field": "workspace_name",
"operator": "contains",
"value": ["candy"],
},
{
"field": "workspace_name",
"operator": "contains",
"value": ["pumpkins"],
}],
"type": "workspaces"
},
"query-type": "workspaces"
}
}
}
Query a saved view
Re-execute a saved view's query to retrieve current results.
GET /api/v2/organizations/:organization_name/explorer/views/:view_id/results
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
:view_id | The ID of the saved view to re-query. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request GET \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/views/$VIEW_ID/results`
Sample response
{
"data": [
{
"attributes": {
"all-checks-succeeded": true,
"checks-errored": 0,
"checks-failed": 0,
"checks-passed": 0,
"checks-unknown": 0,
"current-run-applied-at": null,
"current-run-external-id": "run-rdoEKh2Gy3K6SbCZ",
"current-run-status": "planned_and_finished",
"drifted": false,
"external-id": "ws-j2sAeWRxou1b5HYf",
"module-count": 0,
"modules": null,
"organization-name": "acme-corp",
"project-external-id": "prj-V61QLE8tvs4NvVZG",
"project-name": "Default Project",
"provider-count": 0,
"providers": null,
"resources-drifted": 0,
"resources-undrifted": 0,
"state-version-terraform-version": "1.5.7",
"vcs-repo-identifier": null,
"workspace-created-at": "2023-10-17T21:56:45.570+00:00",
"workspace-name": "candy distribution system",
"workspace-terraform-version": "1.5.7",
"workspace-updated-at": "2023-12-08T19:58:15.513+00:00"
},
"id": "ws-j2sAWeRxuo1b5HYf",
"type": "visibility-workspace"
},
{
"attributes": {
"all-checks-succeeded": true,
"checks-errored": 0,
"checks-failed": 0,
"checks-passed": 0,
"checks-unknown": 0,
"current-run-applied-at": "2023-08-18T16:24:59.000+00:00",
"current-run-external-id": "run-9MmJaoQTvDCh5wUa",
"current-run-status": "applied",
"drifted": true,
"external-id": "ws-igUVNQSYVXRkhYuo",
"module-count": 0,
"modules": null,
"organization-name": "acme-corp",
"project-external-id": "prj-uU2xNqGeG86U9WgT",
"project-name": "web",
"provider-count": 0,
"providers": null,
"resources-drifted": 3,
"resources-undrifted": 3,
"state-version-terraform-version": "1.4.5",
"vcs-repo-identifier": "acmecorp/api",
"workspace-created-at": "2023-04-25T17:09:14.960+00:00",
"workspace-name": "pumpkin smasher",
"workspace-terraform-version": "1.4.5",
"workspace-updated-at": "2023-12-08T20:43:16.779+00:00"
},
"id": "ws-igUNVQSYXVRkhYuo",
"type": "visibility-workspace"
}
],
"links": {
"self": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces",
"first": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces",
"last": "https://app.terraform.io/api/v2/organizations/acme-corp/explorer?page%5Bnumber%5D=1&page%5Bsize%5D=20&type=workspaces",
"prev": null,
"next": null
},
"meta": {
"pagination": {
"current-page": 1,
"page-size": 20,
"next-page": null,
"prev-page": null,
"total-pages": 1,
"total-count": 2
}
}
}
Query a saved view as CSV
Re-execute a saved view's query to retrieve current results, HCP Terraform returns results as a CSV.
GET /api/v2/organizations/:organization_name/explorer/views/:view_id/csv
Parameter | Description |
---|---|
:organization_name | The name of the organization to query. To view a query, you must have permission to read the workspaces and projects within that query. |
:view_id | The external id of the saved view to query. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--request GET \
'https://app.terraform.io/api/v2/organizations/$ORG_NAME/explorer/views/$VIEW_ID/csv`
Sample response
all_checks_succeeded,checks_errored,checks_failed,checks_passed,checks_unknown,current_run_applied_at,current_run_external_id,current_run_status,drifted,external_id,module_count,modules,organization_name,project_external_id,project_name,provider_count,providers,resources_drifted,resources_undrifted,state_version_terraform_version,vcs_repo_identifier,workspace_created_at,workspace_name,workspace_terraform_version,workspace_updated_at
"true","0","0","0","0","","run-rdoEKh2Gy3K6SbCZ","planned_and_finished","false","ws-j2sAeWRxou1b5HYf","0","","acme-corp","prj-V61QLE8tvs4NvVZG","Default Project","0","","0","0","1.5.7","","2023-10-17T21:56:45+00:00","candy distribution service","1.5.7","2023-12-13T15:48:16+00:00"
"true","0","0","0","0","2023-08-18T16:24:59+00:00","run-9MmJaoQTvDCh5wUa","applied","true","ws-igUVNQSYVXRkhYuo","0","","acme-corp","prj-uU2xNqGeG86U9WgT","web","0","","3","3","1.4.5","acmecorp/api","2023-04-25T17:09:14+00:00","api-service","1.4.5","2023-12-13T15:29:03+00:00"