API /context return Forbidden

When I follow this doc https://circleci.com/docs/api/v2/#operation/listEnvironmentVariablesFromContext I get “You don’t have permission to list environment variables in this context” error message.

The Circle-Token, passed when executing curl cmd, belongs to a user with admin access so it is impossible that the user doesn’t have permissions.

Endpoint https://circleci.com/api/v1.1/me works fine with the same token.

You can see this error if the token is from a user that has a valid CircleCI account, but that user either does not have access to the organization or does not have access to modify contexts.

You can check this in the UI by going to the contexts page for that organization

https://app.circleci.com/settings/organization/{gitub or bitbucket}/{organization name}/contexts

Replace {github or bitbucket} with either github or bitbucket and {organization name} with the name of your organization. Example circleci.

If you do not have the required permissions you will see an error on that page. The user needs to be an admin of the organization on Github or Bitbucket.

I checked, I do have access to the context page (and I am able to add/delete context and env vars) but still get an error when using the user token to perform curl request.

“You don’t have permission to list environment variables in this context”

This https://circleci.com/api/v2/context/{context-id}
does not work, but I can create and delete context on the

If you are able to create a context through the UI with the user, but not the API, I would open up a support ticket as it sounds like something may not be working correctly.

You are sure that you are using a Personal API token as opposed to a Project API token. You can verify that by making a GET requests to this endpoint.