Infracost API

The majority of users should use the Infracost CLI, which does not send the Terraform statefile to the open-source Cloud Pricing API; instead it sends the relevant data for finding a unique cloud price point.

The API described in this page can be useful for CI/CD integrations, such as Atlantis, where it might be easier to use curl or an HTTP library instead of installing the Infracost CLI. Terraform plan JSON files can be sent to this API, which runs the CLI and returns the results. Whilst this API deletes files from the server after they are processed, it is a good security practice to remove secrets from the file before sending it to the API. For example, AWS provides a grep command that can be used to do this.

To use this API, send an HTTP POST request to with the terraform-json-file parameter using the multipart/form-data request body format, as shown in the following example curl request. The x-api-key header must be set to your Infracost API key.

terraform-json-fileTerraform plan JSON fileYesUse '@' to upload the file with curl, e.g. -F "terraform-json-file=@plan.json"
usage-fileInfracost usage file that specifies values for usage-based resourcesNoUse '@' to upload the file with curl, e.g. -F "usage-file=@infracost-usage.yml"
show-skippedShow unsupported resources, some of which might be free. Only for table and HTML outputNoDefaults to false
outputOutput format: json, table, htmlNoDefaults to table and returns a text/plain response. If output is set to json, an application/json response is returned; and if output is set to html, a text/html response is returned.
no-colorTurn off colored output, useful for table output or Windows users (color output has a bug we need to fix on Windows)NoDefaults to false
cd path/to/code
terraform init
terraform plan -out .
terraform show -json > plan.json
curl -X POST -H "x-api-key: my-api-key" -F "ci-platform=atlantis" \
-F "terraform-json-file=@plan.json" \