Documentation Index
Fetch the complete documentation index at: https://tyk.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
While a Session dictates the overall limits and lifecycle for a client, theaccess_rights map is the engine that drives exactly what that client is allowed to do.
The access_rights map links the Session to specific APIs and defines the boundaries of access within those APIs. This includes restricting access to specific endpoints (paths and HTTP methods), and even overriding the global session limits for a particular API.
While you can configure
access_rights directly on a Session object, it is highly recommended to manage these settings via Policies for easier management at scale.The Access Rights Map
Under the hood,access_rights is a map where the key is the API ID, and the value is an Access Definition object.
If an API ID is not present in this map, the Session has absolutely no access to that API. If it is present, Tyk evaluates the rules defined in the Access Definition.
Basic API Access
At its simplest, an Access Definition grants access to an API identified by its unique ID:api_id: The internal ID of the API.api_name: A human-readable name for the API.
Granular Endpoint Access
By default, granting access to an API allows the client to access all paths and HTTP methods (endpoints) within that API. You can restrict this using theallowed_urls allow list.
allowed_urls: A list of objects that define specific endpoints the client can access. If this list is empty, all endpoints are allowed. If it contains even one entry, Tyk operates in a “default deny” mode, and the request must match an entry in this allow list to proceed.
allowed_urls allow list contains:
url: A regular expression pattern matching the allowed path (e.g.,/users/.*).methods: A list of allowed HTTP methods for that path (e.g.,["GET", "POST"]).
/users endpoint:
API-Level Limits and Quotas
Sometimes, you want a client to have different rate limits or quotas for different APIs. For example, a client might be allowed 100 requests per second globally, but only 10 requests per second to a computationally expensive “Reports” API. You can override the Session’s global limits (the rate limit and quota controls declared at the root of the session object) for a specific API using thelimit object within the Access Definition.
limit: An object containing rate limit and quota settings that apply only to this API. If these fields are set, they take precedence over the global Session limits when the client accesses this specific API:rateandper: The API-specific rate limit.throttle_intervalandthrottle_retry_limit: The API-specific throttling configuration.quota_maxandquota_renewal_rate: The API-specific quota configuration.
Endpoint-Level Rate Limits
For even finer control, you can define rate limits for specific paths and methods within an API using theendpoints list.
endpoints: A list of objects that define rate limits for specific paths.path: The exact path (e.g.,/reports).methods: A list of methods and their associated limits.name: The HTTP method (e.g.,GET).limit: The rate limit configuration (rateandper) for this specific path and method.
Protocol-Specific Controls
The Access Definition also contains fields for securing specific types of APIs: GraphQLrestricted_typesandallowed_types: Controls which GraphQL types the client can query.field_access_rights: Granular control over specific fields within GraphQL types.disable_introspection: Prevents the client from running introspection queries.
json_rpc_methodsandjson_rpc_methods_access_rights: Controls access to specific JSON-RPC methods.mcp_primitivesandmcp_access_rights: Controls access to specific Model Context Protocol (MCP) primitives.
Tyk Classic API Controls
If you are using Tyk Classic APIs, you can also restrict access to specific API versions:versions: A list of strings representing the allowed versions (e.g., [“Default”, “v2”]). The client’s request must target one of these versions.
This field is ignored for Tyk OAS APIs, which are inherently unversioned from the Session’s perspective, as each has its own unique API ID.