RunpodR
Runpod10mo ago
21 replies
ajgeiss0702

Requests using RUNPOD_API_KEY fail with 403 unauthorized.

Hello,

I'm experimenting with using runpod for running a bunch of one-off jobs. According to the [pods environment variables] page, the RUNPOD_API_KEY is an api key for making api calls scoped to the specific job.

Basically, I want to terminate (or at least shut down) the pod once it is done with its task. However when I make a call to the rest api, I get 403 Forbidden and an empty response body.

Here is how I am calling the api (nodejs from within the container):
fetch('https://rest.runpod.io/v1/pods/' + process.env.RUNPOD_POD_ID + "/stop", {
  method: 'POST',
  headers: {
    Authorization: 'Bearer ' + process.env.RUNPOD_API_KEY,
    "user-agent": "RE-TEST/1.0.0"
  }
})

Any help with this would be highly appreciated
Was this page helpful?