How to hit the HCP Terraform (Terraform Cloud) API

HCP Terraform's API at https://app.terraform.io/api/v2 follows JSON:API: send Content-Type: application/vnd.api+json on writes.

Authentication

Create a token at User Settings → Tokens. Send it as Authorization: Bearer <token>. In the examples it's written {{TFC_TOKEN}}.

Full reference: https://developer.hashicorp.com/terraform/cloud-docs/api-docs

Current account

curl https://app.terraform.io/api/v2/account/details \
  -H "Authorization: Bearer {{TFC_TOKEN}}"
Run in PostTaco

List organizations

curl https://app.terraform.io/api/v2/organizations \
  -H "Authorization: Bearer {{TFC_TOKEN}}"
Run in PostTaco

List workspaces

curl https://app.terraform.io/api/v2/organizations/{{ORG_NAME}}/workspaces \
  -H "Authorization: Bearer {{TFC_TOKEN}}"
Run in PostTaco