API Key quota isn't returned correctly by the Dashboard API

Hello!

I’m trying to set up an API key with a specific quote using the Dashboard API on the Tyk Cloud. Here’s a sample of the particular request I’m using:

{
	"allowance": 1,
	"rate": 10,
	"per": 1,
	"expires": -1,
	"quota_max": 50,
	"quota_remaining": 50,
	"quota_renewal_rate": 3600,
	"access_rights": {
		"ApiID": {
			"api_id": "ApiID",
			"api_name": "ApiName",
			"versions": ["Default"]
		}
	},
	"meta_data": {
		"company_id": "1"
	}
}

Judging by the API reference & the samples, I assume that’s setting up a global quota on a particular key. The response is totally fine, and I can retrieve the key via GET request afterwards:

{
	"api_model": {},
	"key_id": "KeyID",
	"data": {
		"access_rights_array": [
			{
				"api_name": "ApiName",
				"api_id": "ApiID",
				"versions": [
					"Default"
				],
				"allowed_urls": null,
				"restricted_types": null,
				"allowed_types": null,
				"disable_introspection": false,
				"limit": {
					"rate": 0,
					"per": 0,
					"throttle_interval": 0,
					"throttle_retry_limit": 0,
					"max_query_depth": 0,
					"quota_max": 0,
					"quota_renews": 0,
					"quota_remaining": 0,
					"quota_renewal_rate": 0,
					"set_by_policy": false
				},
				"field_access_rights": null,
				"allowance_scope": ""
			}
		],
		"oauth_keys_array": [],
		"last_check": 0,
		"allowance": 1,
		"rate": 10,
		"per": 1,
		"throttle_interval": 0,
		"throttle_retry_limit": 0,
		"max_query_depth": 0,
		"date_created": "2024-01-15T16:04:40.39451315Z",
		"expires": -1,
		"quota_max": 50,
		"quota_renews": 1705401370,
		"quota_remaining": 50,
		"quota_renewal_rate": 3600,
		"access_rights": {
			"ApiID": {
				"api_name": "ApiName",
				"api_id": "ApiID",
				"versions": [
					"Default"
				],
				"allowed_urls": null,
				"restricted_types": null,
				"allowed_types": null,
				"disable_introspection": false,
				"limit": {
					"rate": 0,
					"per": 0,
					"throttle_interval": 0,
					"throttle_retry_limit": 0,
					"max_query_depth": 0,
					"quota_max": 0,
					"quota_renews": 0,
					"quota_remaining": 0,
					"quota_renewal_rate": 0,
					"set_by_policy": false
				},
				"field_access_rights": null,
				"allowance_scope": ""
			}
		},
		"org_id": "OrgID",
		"oauth_client_id": "",
		"oauth_keys": null,
		"certificate": "",
		"basic_auth_data": {
			"user": "",
			"password": "",
			"hash_type": ""
		},
		"jwt_data": {
			"secret": ""
		},
		"hmac_enabled": false,
		"hmac_string": "",
		"is_inactive": false,
		"apply_policy_id": "",
		"apply_policies": null,
		"data_expires": 0,
		"monitor": {
			"trigger_limits": null
		},
		"enable_detailed_recording": false,
		"meta_data": {
			"company_id": "1"
		},
		"tags": [],
		"alias": "",
		"last_updated": "1705397770",
		"id_extractor_deadline": 0,
		"session_lifetime": 0
	},
	"key_hash": "KeyHash"
}

The problem I have is that the quota-related part in Key API remains static. I’ve tried doing several requests with the key, and quote_remaining stays the same.

"quota_renews": 1705401370,
"quota_remaining": 50,

Once I reach the quota limit, Tyk starts to give me “Quota exceeded” error, which means quota is, in fact, respected. Once an hour passes, Tyk starts to accept requests again, which means quota_renews is (was) respected as well, yet in the GET API both parameters stay the same: quota_remaining doesn’t decrement per request, quota_renews stays at the value of the first renewal.

Is there something I’m doing wrong? Are these not supposed to reflect the actual quota status? Or is there some cache involved in Dashboard APIs, which prevents me from seeing the correct values? Or they are supposed to be determined some other way?

Thanks in advance!

Welcome to the community :tada:

We’ve addressed your query via our commercial support channel. We discovered your deployment method was cloud. The solution to the issue is to use the Edge Gateway API /keys/{keyName:[^/]*} with the Gateway API Secret to retrieve the key that tracks the quota calculation for the API call. This will allow you to see the correct quota values.