Unable to find context ID

hi all,

am currently trying to update an environment variable in a context in my organisation and according to the api reference: CircleCI API it says it is required that my context id has to be part of the path in the request.

but i have been unable to find it, the documentation does not throw any light on finding these id’s.

its there a way i can get it?
if possible, please i need help.

I can not provide an exact answer just some hints

  • Contexts have little documentation about their API usage. The small section on using them via the CLI does help a little as the CLI is using the API and so there is a mapping between the two.

  • I get the feeling that the writers of the API are the main users of the API and so are not dependent on their structure or supporting docs.

Taking all of the above into account it seems that to get context ID you have to

  • Use the ‘List contexts API’ call to scan all the defined contexts under your account and look for the one you wish to modify. The name you are looking for will be the text name of the Context as listed via the GUI under Organization Settings.

  • Use the ID from the first step to call “Add or update an environment variable”

2 Likes

Hi @Joshua_Igoni ,

As @rit1010 has mentioned, you can use the following API endpoint to get a list of your context ids:

CircleCI API

If you are logged in to CircleCI, you can also visit the page directly in your browser. For example:

https://circleci.com/api/v2/context?owner-slug=gh/orgnamegoeshere

You can also find the id for a specific context by navigating to that context’s page in the UI, and the id will be present in the url after contexts/.

1 Like

wow this is very helpful, thanks so much guys @aaronclark @rit1010

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.