Create Organisations, Users, Api Definitions, Key

Ah! Ok, so when you create a key with the Advanced API, what happens is:

CREATE key request -> [Advanced API] Gateway Wrapper -> [Tyk Gateway API] CREATE Key

Basically the dashboard validates the request and then instructs the gateway to generate the token, the dashboard (advanced API) doesn’t generate the token directly.

So, if you create an API in the dashboard, it will save it, and signal to Tyk Gateway to load the API (hot reload).

Tyk gateway has a timed load for these signals so they batch if lots of updates happen at the same time (to prevent constant, or back-to-back reloads). If your CREATE command is happening too quickly, the API will not exist on the gateway yet, and therefore the key cannot be created since it is attached to an API that the gateway won’t recognise, and so the request fails up the chain.

The trick is to wait for the API to be loaded in Tyk (say 5 secs or so) before creating keys. You can see the reload live if you tail the logs on save an API definition to get the timing.