Tyk

Tyk Keys API

All keys that are used to access services via Tyk correspond to a session object that informs Tyk about the context of this particular token, like access rules and rate/quota allowance.

OpenAPI Specification

tyk-keys-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  title: Tyk Dashboard Admin Additional Permissions Keys API
  version: 5.3.0
  description: 'For Tyk On-Premises installations only, the Dashboard Admin API has two endpoints and is used to set up and provision a Tyk Dashboard instance without the command line.


    In order to use the Dashboard Admin API, you''ll need to get the `admin_secret` value from your Tyk Dashboard configurations.


    The secret you set should then be sent along as a header with each Dashboard Admin API Request in order for it to be successful:


    ```

    admin-auth: <your-secret>

    ```'
servers:
- url: http://localhost/
- url: https://localhost/
security:
- ApiKeyAuth: []
tags:
- description: All keys that are used to access services via Tyk correspond to a session object that informs Tyk about the context of this particular token, like access rules and rate/quota allowance.
  externalDocs:
    description: API Key Management.
    url: https://tyk.io/docs/tyk-apis/tyk-dashboard-api/api-keys/
  name: Keys
paths:
  /api/apis/{apiID}/keys:
    get:
      description: Lists keys that grant access to the API with the ID {apiID}.
      operationId: listApiKeys
      parameters:
      - description: Use p query parameter to say which page you want returned. Send number less than 0 to return all items.
        example: 1
        in: query
        name: p
        required: false
        schema:
          type: integer
      - description: ID of the API.
        example: 663a4ed9b6be920001b191ae
        in: path
        name: apiID
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              example:
                data:
                  keys:
                  - 5e9d9544a1dcd60001d0ed20a28c495beff140a4a6d8c272a1956b99
                  - 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
                  - 5e9d9544a1dcd60001d0ed2060ff87c0deab4a508dd2ac18ccb8b664
                pages: 1
              schema:
                $ref: '#/components/schemas/Keys'
          description: Paginated key IDs.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/apis/{apiID}/keys'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              example:
                Message: Could not retrieve keys.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Returned when keys are hashed and hashed key listing is disabled.
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal keys data from Tyk API.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: List keys by API.
      tags:
      - Keys
  /api/apis/{apiID}/keys/{keyID}:
    delete:
      description: Deleting a key will remove it permanently from the system, however analytics relating to that key will still be available.
      operationId: deleteApiKeyDetail
      parameters:
      - description: If you are not sure if a key is hashed you can send this as true.
        example: true
        in: query
        name: auto_guess
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      - description: Use the hash of the key as input instead of the full key. Any none empty string will be interpreted as to say you want to use hash input.
        example: '1'
        in: query
        name: hashed
        required: false
        schema:
          type: string
      - description: Set to true if the passed key is a username.
        example: true
        in: query
        name: username
        required: false
        schema:
          enum:
          - true
          - false
          type: boolean
      - description: ID of API the keys grant access to. Can either be the internal or external API ID.
        example: 546e885199c947147e7f39b7d6e8e984
        in: path
        name: apiID
        required: true
        schema:
          type: string
      - description: The key ID
        example: 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
        in: path
        name: keyID
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              example:
                Message: Key deleted successfully.
                Meta: null
                Status: OK
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key deleted.
        '400':
          content:
            application/json:
              example:
                Message: Attempted access to non-owned key.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Trying to access a key your org does not own.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/apis/{apiID}/keys/{keyID}'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              example:
                Message: Could not retrieve key detail.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key with ID not found.
        '500':
          content:
            application/json:
              example:
                Message: Could not delete key.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: Delete key with API ID and key ID.
      tags:
      - Keys
    get:
      description: Fetches the key that grant access to the API with the ID {apiID} and key ID {keyID}.
      operationId: getApiKeyDetail
      parameters:
      - description: If you are not sure if a key is hashed you can send this as true.
        example: true
        in: query
        name: auto_guess
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      - description: Use the hash of the key as input instead of the full key.Any none empty string will be interpreted as to say you want to use hash input.
        example: '1'
        in: query
        name: hashed
        required: false
        schema:
          type: string
      - description: Set to true if the passed key ID is a username.
        example: true
        in: query
        name: username
        required: false
        schema:
          enum:
          - true
          - false
          type: boolean
      - description: ID of API the keys grant access to. Can either be the internal or external API ID.
        example: 546e885199c947147e7f39b7d6e8e984
        in: path
        name: apiID
        required: true
        schema:
          type: string
      - description: The Key ID.
        example: 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
        in: path
        name: keyID
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyData'
          description: Key data fetched.
        '400':
          content:
            application/json:
              example:
                Message: Attempted access to non-owned key.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Trying to access a key your org does not own.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/apis/{apiID}/keys/{keyID}'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              example:
                Message: Could not retrieve key detail.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key with ID not found.
      summary: Get key details with API ID and key ID.
      tags:
      - Keys
    put:
      description: You can also manually add keys to Tyk using your own key-generation algorithm. It is recommended if using this approach to ensure that the OrgID being used in the API Definition and the key data is blank so that Tyk does not try to prepend or manage the key in any way.
      operationId: updateApiKeyDetail
      parameters:
      - description: If you are not sure if a key is hashed you can send this as true.
        example: true
        in: query
        name: auto_guess
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      - description: Use the hash of the key as input instead of the full key. Any none empty string will be interpreted as to say you want to use hash input.
        example: '1'
        in: query
        name: hashed
        required: false
        schema:
          type: string
      - description: Set to true if the passed key ID is a username.
        example: true
        in: query
        name: username
        required: false
        schema:
          enum:
          - true
          - false
          type: boolean
      - description: Adding the suppress_reset parameter and setting it to 1, will cause Tyk not to reset the quota limit that is in the current live quota manager. By default Tyk will reset the quota in the live quota manager (initialising it) when adding a key. Adding the `suppress_reset` flag to the URL parameters will avoid this behaviour.
        example: '1'
        in: query
        name: suppress_reset
        required: false
        schema:
          type: string
      - description: ID of API the keys grant access to. Can either be the internal or external API ID.
        example: 546e885199c947147e7f39b7d6e8e984
        in: path
        name: apiID
        required: true
        schema:
          type: string
      - description: The Key ID.
        example: 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
        in: path
        name: keyID
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            example:
              alias: portal-key
              allowance: 1000
              apply_policies:
              - 62a0ec9092faf50001395817
              enable_detailed_recording: true
              expires: 1718439136
              hmac_enabled: false
              is_inactive: false
              meta_data:
                tyk_developer_id: 62b3fb9a1d5e4f00017226f5
              org_id: 5e9d9544a1dcd60001d0ed20
              per: 60
              quota_max: -1
              quota_remaining: 0
              quota_renewal_rate: -1
              quota_renews: 1715847135
              rate: 1000
              tags:
              - edge-eu
              - edge
              throttle_interval: 0
              throttle_retry_limit: 0
            schema:
              $ref: '#/components/schemas/SessionState'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyData'
          description: Key updated
        '400':
          content:
            application/json:
              example:
                Message: User/Key object validation failed, most likely malformed input.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Malformed input.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: Request body malformed.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unmarshalling request body failed, malformed.
        '404':
          content:
            application/json:
              example:
                Message: Could not retrieve key detail.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key with ID not found.
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal Key data.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: With API ID and key ID.
      tags:
      - Keys
  /api/apis/{apiId}/keys/search:
    get:
      description: Lists keys that grant access to the API with the ID {apiID}. When q query parameter is passed it will only return keys that contains the string sent by q.
      operationId: SearchKeys
      parameters:
      - description: Filter and return all keys that contain this text in there key ID.
        example: itachi
        in: query
        name: q
        required: false
        schema:
          type: string
      - description: Use p query parameter to say which page you want returned. Send number less than 0 to return all items.
        example: 1
        in: query
        name: p
        required: false
        schema:
          type: integer
      - description: ID of the API.
        example: 663a4ed9b6be920001b191ae
        in: path
        name: apiId
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              example:
                data:
                  keys:
                  - 5e9d9544a1dcd60001d0ed20itachi
                  - 5e9d9544a1dcd60001d0ed20ns-itachi
                pages: 1
              schema:
                $ref: '#/components/schemas/Keys'
          description: Paginated key IDs
        '400':
          content:
            application/json:
              example:
                Message: Could not search keys.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Could not search keys.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/apis/{apiId}/keys/search'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal user data.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: Search keys by API.
      tags:
      - Keys
  /api/apis/keys:
    get:
      description: Return a paginated list of keys.
      operationId: listKeys
      parameters:
      - description: Use p query parameter to say which page you want returned. Send number less than 0 to return all items.
        example: 1
        in: query
        name: p
        required: false
        schema:
          type: integer
      responses:
        '200':
          content:
            application/json:
              example:
                data:
                  keys:
                  - 5e9d9544a1dcd60001d0ed20a28c495beff140a4a6d8c272a1956b99
                  - 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
                  - 5e9d9544a1dcd60001d0ed2060ff87c0deab4a508dd2ac18ccb8b664
                pages: 1
              schema:
                $ref: '#/components/schemas/Keys'
          description: Paginated key IDs.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/apis/keys'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal keys data from Tyk API.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: List All the keys.
      tags:
      - Keys
  /api/keys:
    post:
      description: "Tyk will generate the access token based on the OrgID specified in the API Definition and a random UUID. This ensures that keys can be owned by different API owners should segmentation be needed at an organisational level.\n  <br/><br/>\n API keys without access_rights data will be written to all APIs on the system (this also means that they will be created across all SessionHandlers and StorageHandlers, it is recommended to always embed access_rights data in a key to ensure that only targeted APIs and their back-ends are written to."
      operationId: addKey
      parameters:
      - description: Set this to true to create a basic user. Note you have to send basic_auth_data(user and password) in the request body if this value is set to true.
        example: true
        in: query
        name: basic_auth
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      requestBody:
        content:
          application/json:
            example:
              alias: portal-key
              allowance: 1000
              apply_policies:
              - 62a0ec9092faf50001395817
              enable_detailed_recording: true
              expires: 1718439136
              hmac_enabled: false
              is_inactive: false
              meta_data:
                tyk_developer_id: 62b3fb9a1d5e4f00017226f5
              org_id: 5e9d9544a1dcd60001d0ed20
              per: 60
              quota_max: -1
              quota_remaining: 0
              quota_renewal_rate: -1
              quota_renews: 1715847135
              rate: 1000
              tags:
              - edge-eu
              - edge
              throttle_interval: 0
              throttle_retry_limit: 0
            schema:
              $ref: '#/components/schemas/SessionState'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyData'
          description: New Key added.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: Request body malformed.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unmarshalling request body failed, malformed.
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal key data.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: Create a key.
      tags:
      - Keys
  /api/keys/{keyId}:
    delete:
      description: Deleting a key will remove it permanently from the system, however analytics relating to that key will still be available.
      operationId: deleteKey
      parameters:
      - description: If you are not sure if a key is hashed you can send this as true.
        example: true
        in: query
        name: auto_guess
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      - description: Use the hash of the key as input instead of the full key.Any none empty string will be interpreted as to say you want to use hash input.
        example: '1'
        in: query
        name: hashed
        required: false
        schema:
          type: string
      - description: Set to true if the passed key is a username
        example: true
        in: query
        name: username
        required: false
        schema:
          enum:
          - true
          - false
          type: boolean
      - description: The ID of the key.
        example: 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
        in: path
        name: keyId
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              example:
                Message: Key deleted successfully.
                Meta: null
                Status: OK
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key deleted.
        '400':
          content:
            application/json:
              example:
                Message: Attempted access to non-owned key.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Trying to access a key your org does not own.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/keys/{keyId}'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              example:
                Message: Could not retrieve key detail.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key with ID not found
        '500':
          content:
            application/json:
              example:
                Message: Could not delete key.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: Delete key.
      tags:
      - Keys
    get:
      description: Get the details of a key.
      operationId: getKeyDetail
      parameters:
      - description: The ID of the key.
        example: 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
        in: path
        name: keyId
        required: true
        schema:
          type: string
      - description: If you are not sure if a key is hashed you can send this as true.
        example: true
        in: query
        name: auto_guess
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      - description: Use the hash of the key as input instead of the full key.Any none empty string will be interpreted as to say you want to use hash input.
        example: '1'
        in: query
        name: hashed
        required: false
        schema:
          type: string
      - description: Set to true if the passed key ID is a username.
        example: true
        in: query
        name: username
        required: false
        schema:
          enum:
          - true
          - false
          type: boolean
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyData'
          description: Key Data fetched.
        '400':
          content:
            application/json:
              example:
                Message: Attempted access to non-owned key.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Trying to access a key your org does not own.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: 'access denied: You do not have permission to access  /api/keys/{keyId}'
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              example:
                Message: Could not retrieve key detail.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Key with ID not found.
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal key data from Tyk API.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: Get key Details.
      tags:
      - Keys
    post:
      description: Creates a key with a custom key ID.
      operationId: createCustomKey
      parameters:
      - description: The ID to give the key.
        example: my-custom-key
        in: path
        name: keyId
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            example:
              alias: portal-key
              allowance: 1000
              apply_policies:
              - 62a0ec9092faf50001395817
              enable_detailed_recording: true
              expires: 1718439136
              hmac_enabled: false
              is_inactive: false
              meta_data:
                tyk_developer_id: 62b3fb9a1d5e4f00017226f5
              org_id: 5e9d9544a1dcd60001d0ed20
              per: 60
              quota_max: -1
              quota_remaining: 0
              quota_renewal_rate: -1
              quota_renews: 1715847135
              rate: 1000
              tags:
              - edge-eu
              - edge
              throttle_interval: 0
              throttle_retry_limit: 0
            schema:
              $ref: '#/components/schemas/SessionState'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeyData'
          description: Key created.
        '401':
          content:
            application/json:
              example:
                Message: Not authorised
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              example:
                Message: Request body malformed.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Unmarshalling request body failed, malformed.
        '500':
          content:
            application/json:
              example:
                Message: Failed to unmarshal Key data.
                Meta: null
                Status: Error
              schema:
                $ref: '#/components/schemas/ApiResponse'
          description: Internal server error.
      summary: Create custom key.
      tags:
      - Keys
    put:
      description: You can also manually add keys to Tyk using your own key-generation algorithm. It is recommended if using this approach to ensure that the OrgID being used in the API definition and the key data is blank so that Tyk does not try to prepend or manage the key in any way.
      operationId: updateKeyDetail
      parameters:
      - description: The ID of the key.
        example: 5e9d9544a1dcd60001d0ed20e7f75f9e03534825b7aef9df749582e5
        in: path
        name: keyId
        required: true
        schema:
          type: string
      - description: Use the hash of the key as input instead of the full key. Any none empty string will be interpreted as to say you want to use hash input.
        example: '1'
        in: query
        name: hashed
        required: false
        schema:
          type: string
      - description: If you are not sure if a key is hashed you can send this as true.
        example: true
        in: query
        name: auto_guess
        required: false
        schema:
          default: false
          enum:
          - true
          - false
          type: boolean
      - description: Set to true if the passed key ID is a username.
        example: true
        in: que

# --- truncated at 32 KB (87 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/tyk/refs/heads/main/openapi/tyk-keys-api-openapi.yml