API Key Methods

API for API keys

The API keys are for accessing the Memset API programatically not using a username and password. Their scope can be limited on creation so that it is possible to create API keys with just a single purpose.

Scopes

API keys can be scoped with “name”, “method” or with both.

API keys created with “name” scopes can only be called with a parameter called “name” with one of the values supplied in the scope when it was created.

API keys created with “method” scopes can only be used to call those named methods and no others.

For example if an API key was created with the scopes:

{
    "name": [ "server1", "server2" ]
}

Then it could only be used to access methods which take a “name” parameter and with that set to either “server1” or “server2”

If an API key was created with the scopes:

{
    "method": [ "server.reboot" ]
}

Then it could only be used to call the “server.reboot” method.

If an API key was created with the scopes:

{
    "method": [ "server.reboot" ],
    "name": [ "server1", "server2" ]
}

Then it could only be used to call the “server.reboot” method on “server1” or “server2”.

apikey.add_scope()

Adds a single scope to an API key

Parameters:
  • id (String) – The API key. API Keys are 32 hex digits.
  • scope_name (String) – The name of the API scope. Acceptable values: ‘method’, ‘name’.
  • value (String) – The value of the API scope. Ensure this value has at most 50 characters.
Returns:

Dictionary: as described in apikey.info().

apikey.create()

Creates a new API key for this account.

Parameters:
  • scopes (Dictionary, Optional) – The scopes dictionary as described in apikey.info().
  • comment (String, Optional) – User comment. Ensure this value has at most 255 characters.
Returns:

a dictionary containing the new api key as described in apikey.info().

apikey.delete()

Deletes an API key.

Parameters:id (String) – The API key. API Keys are 32 hex digits.
Returns:an empty dictionary.
apikey.delete_scope()

Deletes a single scope to an API key. Doesn’t raise an error if it didn’t exist.

Parameters:
  • id (String) – The API key. API Keys are 32 hex digits.
  • scope_name (String) – The name of the API scope. Acceptable values: ‘method’, ‘name’.
  • value (String) – The value of the API scope. Ensure this value has at most 50 characters.
Returns:

Dictionary: as described in apikey.info().

apikey.info()

Describes the API key.

Parameters:id (String) – The API key. API Keys are 32 hex digits.
Returns:a dictionary with the following keys:
key
String: 32 digit hex which is the api_key.
scopes
Dictionary: A dictionary of Lists of String. The keys are the scope names (“method” or “name”) and the values are lists of valid entries for those scopes
comment
String: User comment associated to the key (if any).
created
Date: Date when the key was created.
apikey.list()

List all the API keys for this account.

Returns:a list of dictionaries where each dictionary is as described in apikey.info().

Table Of Contents

Previous topic

Methods

Next topic

Bandwidth Methods

This Page