https://infracost.io logo
#help
Title
# help
a

adorable-zoo-31914

11/23/2023, 9:35 AM
Hi! I'd like to try out the API by referring to https://www.infracost.io/docs/integrations/infracost_api. I'm going through this command and I'm getting an invalid api message as a response.
Copy code
curl -X POST -H "x-api-key: my-api-key" -F "ci-platform=atlantis" \
     -F "path=@plan.json" \
     <https://pricing.api.infracost.io/breakdown>
{"error":"Invalid API key","error_code":"invalid_api_key"}%
I see that the CLI is working fine, so there seems to be no problem with the API KEY, but is that API no longer available? Thanks for the answer.
w

white-airport-8778

11/23/2023, 10:16 AM
@adorable-zoo-31914 that API is available, I wonder if you have one of the legacy API keys - does your API key start with
ico-
? if not, it’s a legacy API key and you should get a new one from dashboard.infracost.io
a

adorable-zoo-31914

11/23/2023, 3:12 PM
@white-airport-8778 Thanks for the answer. My api key starts with an ICO. I'm in the same environment as the example, and my biggest question is that the CLI works, but the API doesn't. Is there anything else I need to consider when using the API?
w

white-airport-8778

11/23/2023, 4:29 PM
@adorable-zoo-31914 nope, that’s all that’s needed, I’ll DM you to screenshare when you can as that’s probably the fastest way to debug 🙂 We have other people using that API. Also, just checking you’re replacing “my-api-key” with your own API key in that curl command, right? so you’re running
Copy code
curl -X POST -H "x-api-key: ico-...." \
     -F "path=@plan.json" \
     <https://pricing.api.infracost.io/breakdown>
a

adorable-zoo-31914

11/23/2023, 5:21 PM
@white-airport-8778 I ran it using your message and it worked, thank you very much. I analyzed the cause and it seems that there was a problem with the single quotes in the command shared via notion. I'm using infracost for the first time today and I think I can use it well thanks to you. Thanks:)
w

white-airport-8778

11/23/2023, 5:22 PM
Awesome - good luck 🚀
a

adorable-zoo-31914

11/24/2023, 3:21 AM
@white-airport-8778 Is it possible to use the .tf file as an API, or is it only the planned results that can be used as an API?
w

white-airport-8778

11/24/2023, 7:10 AM
The API currently only supports TF Plan JSON file
3 Views