Tyk v2.2 Documentation Components

  1. Home
  2. Tyk v2.2 Documentation Components
  3. Tutorial: Create an API Token Without GUI (OP: Pro)

Tutorial: Create an API Token Without GUI (OP: Pro)

To create an API Token, we will need the API ID that we wish to grant the token access to, then creating the token is a very simple API call to the endpoint. In a Pro installation, we use the dashboard endpoint instead of the gateway endpoint, as in a Pro installation we should always integrate with the dashboard API as it has a more granular security model.

You will also need your own API Key, to get these values:

  1. Click on “System Management” -> “Users” -> Your user name -> Edit.
  2. The API key is under marked as Tyk Dashboard API Access Credentials, copy this somewhere you can reference it. API key location
  3. Select the “System Management” -> APIs, beside your new API Name is listed the API ID, store this as well. API ID location

Once you have these values, you can use them to access the dashboard API, the below curl command will generate a token for one of your APIs:

curl -X POST -H "authorization: 1238b7e0e2ff4c2957321724409ee2eb" 
 -H "Content-Type: application/json" 
 -d '{
    "allowance": 1000,
    "rate": 1000,
    "per": 1,
    "expires": -1,
    "quota_max": -1,
    "quota_renews": 1449051461,
    "quota_remaining": -1,
    "quota_renewal_rate": 60,
    "access_rights": {
        "ad5004d961a147d4649fd3216694ebe2": {
            "api_id": "ad5004d961a147d4649fd3216694ebe2",
            "api_name": "test-api",
            "versions": ["Default"]
    "meta_data": {}
 }' http://localhost:3000/api/keys | python -mjson.tool

You will see a response with your new token:

    "action": "create",
    "key": "c2cb92a78f944e9a46de793fe28e847e",
    "status": "ok"

The value returned in the key parameter of the response is the access token you can now use to access the API that was specified in the access_rights section of the call