Using apiKey as an id

Hi,

Just wondering about the apiKey on a model. I am wanting to create new Records using the JS client, but notice I can only do so using model Ids, and not keys. Is there anyway I can just use the key instead of the model id (i.e. Im guessing you are multi-tenant - so unique by api key + apiKey?)… cos atm I have to pull a list of all models (and cache), and lookup the relevant model id using the api key, in order to post a create / update record request. It’d be nice to reduce the requests a bit by using known apiKeys, instead of doing the lookup.

Thanks :slight_smile:

welcome to Community @devaccounts!

Your suggestion makes sense! I’ll note this down and see if we can do anything about that :slight_smile:

Thank you very much for reporting it

1 Like

hi @devaccounts

this is possible now :slight_smile: You can do it in a two steps way. First you fetch the model using its api_key ( https://www.datocms.com/docs/content-management-api/resources/item-type/self ), then you create the item and since you have the model object, you have also its id :slight_smile:

1 Like