Manage API keys

API keys are fixed authentication keys, used to access Supermetrics API.

Please note that this page is only available for general information purposes. Managing API keys requires an oAuth access token with appropriate permissions. Please contact us to manage your API keys for you.

List API keys

GET https://api.supermetrics.com/enterprise/v2/api_keys
Response
PropertyTypeDescription
meta > request_idstring API request ID
dataapi_key[] Partial API key objects. See example for included properties.
HTTP 200 OK
{
    "meta": {
        "request_id": "WnjTGeKqOXTnkZQMbZCfVMdmswv2wAzx"
    },
    "data": [
        {
            "@type": "api_key",
            "api_key_id": "apk_2",
            "created_time": "2021-09-25T12:38:47+00:00",
            "description": "",
            "key_type": "none",
            "key_start": "api_H8TKlr...",
            "is_enabled": true,
            "behalf_of_user_info": null
        },
        {
            "@type": "api_key",
            "api_key_id": "apk_1",
            "created_time": "2021-08-04T04:16:19+00:00",
            "description": "My old API key",
            "key_type": "user",
            "key_start": "api_9Oz1n6...",
            "is_enabled": false,
            "behalf_of_user_info": {
                "@type": "user",
                "user_id": "usr_1",
                "email": "info@supermetrics.com"
            }
        }
    ]
}
Permissions

api_keys_read


Get API key

GET https://api.supermetrics.com/enterprise/v2/api_key/:api_key_id
  • api_key_id string
    Supermetrics API key ID
  • show_key_value bool
    Optional. Show API key value as plain text into the response. Reading value is recorded to the audit logs.
Response
PropertyTypeDescription
meta > request_idstring API request ID
dataapi_key API key object
HTTP 200 OK
{
    "meta": {
        "request_id": "WnjTGeKqOXTnkZQMbZCfVMdmswv2wAzx"
    },
    "data": {
        "@type": "api_key",
        "api_key_id": "apk_2",
        "created_time": "2021-09-25T12:38:47+00:00",
        "description": "",
        "key_type": "none",
        "key_start": "api_H8TKlr...",
        "key_value": null,
        "scope_names": [
            "team_lists_write"
        ],
        "allow_ips": [
            "127.0.0.1"
        ],
        "is_enabled": true,
        "behalf_of_user_info": {
            "@type": "user",
            "user_id": "usr_1",
            "email": "info@supermetrics.com"
        }
    }
}
Permissions

api_keys_read


Add API key

Creating a new API key through this endpoint is recorded to the audit logs.

POST https://api.supermetrics.com/enterprise/v2/api_key
  • key_type string
    Required. Type of key to create. Either query for shared API keys to show in Query Manager or user for private keys intended for one user.
  • description string
    Optional. Internal API key description
  • scope_names string | string[]
    Optional. List of permission scopes for the API key. Defaults to none. See scopes for more.
  • allow_ips string | string[]
    Optional. List of fixed or CIDR formatted IP addresses allowed to use API key. Only IPv4 is supported.
  • is_enabled bool
    Optional. Whether API key is enabled and can be used in requests. Defaults to true.
  • behalf_of_user_id string
    Optional. Supermetrics user ID the API key identifies as. See restrictions for more.
Request
POST https://api.supermetrics.com/enterprise/v2/api_key
Authorization: Bearer <access token>
Content-Type: application/json

{
    "description": "My new API key",
    "behalf_of_user_id": "usr_1"
}
Response

HTTP 201 Created
Response from Get API key

Errors

API_KEY_ALLOW_IP_INVALID, API_KEY_LIMIT_EXCEEDED, API_KEY_SCOPE_NAME_INVALID, API_KEY_USER_INVALID

Permissions

api_keys_write


Update API key

PATCH https://api.supermetrics.com/enterprise/v2/api_key/:api_key_id
  • description string
    Optional. Internal API key description
  • scope_names string | string[]
    Optional. List of permission scopes for the API key. Defaults to none. See scopes for more.
  • allow_ips string | string[]
    Optional. List of fixed or CIDR formatted IP addresses allowed to use API key. Only IPv4 is supported.
  • is_enabled bool
    Optional. Whether API key is enabled and can be used in requests. Defaults to true.
  • behalf_of_user_id string
    Optional. Supermetrics user ID the API key identifies as. Use null to remove previously saved value. See restrictions for more.
Request
PATCH https://api.supermetrics.com/enterprise/v2/api_key/apk_3
Authorization: Bearer <access token>
Content-Type: application/json

{
    "description": "Old disabled API key",
    "is_enabled": false
}
Response

HTTP 200 OK
Response from Get API key

Errors

API_KEY_ALLOW_IP_INVALID, API_KEY_NOT_FOUND, API_KEY_SCOPE_NAME_INVALID, API_KEY_UPDATE_FAILED, API_KEY_USER_INVALID

Permissions

api_keys_write


Supported scopes

API keys can be given the following permission scopes to limit access to Supermetrics API.

ScopeDescription
ds_accounts_readAllow reading accounts from available data sources
ds_login_links_readAllow reading existing data source login links
ds_login_links_writeAllow creating and updating data source login links
ds_logins_readAllow reading existing data source authentications
ds_queries_readAllow reading all available saved queries
ds_queries_runAllow running new data source queries
table_groups_readAllow reading existing table groups
table_groups_writeAllow creating, updating and removing table groups
team_lists_readAllow reading team lists
team_lists_writeAllow creating, updating and removing team lists
team_settings_readAllow reading team settings
team_settings_writeAllow updating team settings

Restrictions

  • Please note that you are, by default, limited to total of 5 API keys. This number consists of both enabled and disabled API keys. Please contact us or your Supermetrics representative to get additional API keys.

  • When an API key contains IP restrictions, it can no longer be used with previous version (v1) of the Supermetrics API. Please migrate any existing queries.

  • When API key type is user and behalf_of_user has been specified, removing that user from your team will also disable the API key. Shared API keys will revert to their default behaviour – identifying as the first user in the team with OWNER or ADMIN role.

Object reference

api_key
PropertyTypeDescription
api_key_idstring Supermetrics API key ID
created_timestring ISO 8601 datetime for when API key was created
descriptionstring Internal API key description
key_typestring
Type of API key
noneNo specific type, used in older keys
queryKey is shared with team and shown in Query Manager
userKey is private and intended for one user
key_startstring First 10 characters from the API key value
key_valuestring API key value as plain text, when requested. Defaults to null.
scope_namesstring[] List of permission scopes for the API key. See scopes for more.
allow_ipsstring[] List of fixed or CIDR formatted IP addresses allowed to use API key
is_enabledbool Whether API key is enabled and can be used in requests
behalf_of_user_infouser Supermetrics user the API key identifies as. Defaults to null.

user
PropertyTypeDescription
user_idstring Supermetrics user ID
emailstring Supermetrics user email

Errors

StatusErrorDescription
400API_KEY_ALLOW_IP_INVALIDProvided IP is not a valid IP address, or an IP range in CIDR format.
403API_KEY_LIMIT_EXCEEDEDCreating new API keys would exceed your total key limit.
404API_KEY_NOT_FOUNDRequested API key was not found.
400API_KEY_SCOPE_NAME_INVALIDProvided scope name is not supported. See scopes for more.
500API_KEY_UPDATE_FAILEDFailed to update API key due to an internal error. Please try again.
400API_KEY_USER_INVALIDProvided user ID either does not exist or does not have access to this team.
Last updated 2023-10-09 UTC.