Creating API keys - how do I get the actual delivery key via the API?

I’m trying to use the API to great an API key for a new space. I want the actual API key so that I can update a config space with it.

In the createApiKey docs, it says that the function returns a Promise for an ApiKey.ApiKey. When I look at that result I can see the name that I gave it, and I get some kind of id off the sys object, but I want the key value itself that will be used to query Contentful.

I tried to query for it by id using space.getApiKey and I get the same result. Is there a way to get the actual delivery key?

I’m replying to my own message to show the answer. There is an ‘accessToken’ property on the returned object that has what I’m looking for.

I might be misreading the API docs, but I feel like this should be in the documentation for ApiKey.

2 Likes

@dustin.aleksiuk awesome! Thanks for your question and details. That’s true- you’re right with the answer.
Thank you for your feedback. We work on documentation improvements constantly. Recently we re-designed SDK reference, i.e. https://contentful.github.io/contentful-management.js/contentful-management/3.12.0/index.html . And more to come, as always ! :slight_smile: