Skip to the content

API Key Management 'How To' Guide

This guide will demonstrate how to use our API key management API methods.


The full documentation for any of the API key management API endpoints can be found here:

Create a new API key

To create a new API key for use with our validation API's, plugins or code integrations, make a POST request to https://api.data-8.co.uk/ApiKey. In the body of the request, pass an object providing the necessary details, like so:

{
  "description": "string",
  "username": "string",
  "expiresOn": "2020-10-26T12:08:21.052Z",
  "maxRequestsPerIPPerDay": 0
}

If successful, the response body should contain an object with the generated key's details, including the API key itself stored in the key property.


Edit or Update an API Key

To edit an API key make a PUT request to https://api.data-8.co.uk/ApiKey/{key}. In the body of the request, pass an object containing the new details of the key, like so:

{
  "key": "string",
  "description": "string",
  "username": "string",
  "expiresOn": "2020-10-26T12:17:54.114Z",
  "maxRequestsPerIPPerDay": 0
}

Delete an API Key

To delete an API key, make a DELETE request to https://api.data-8.co.uk/ApiKey/{key}.


Other API Key Methods

There are some other API key methods that are not described here. These are listed below.

Add or Remove Domains, IP Addresses or Allowed Services

When a key is first created, it is assumed that the key is a server-side API key. To change the key type (to a client-side key) add a domain to the API key. Keys with at least one domain are treated as client-side API keys and will not work from the server-side.


Add a Domain to an API Key

You should add a domain to an API key if you plan on making requests from the client-side. If you are creating a key to test in a localhost environment, add an IP address to the key before adding localhost as a domain.

To add an allowed domain to an API key, make a PUT request to https://api.data-8.co.uk/ApiKey/{key}/allowedDomains/{domain}.


Remove a Domain from an API Key

To remove an allowed domain from an API key, make a DELETE request to https://api.data-8.co.uk/ApiKey/{key}/allowedDomains/{domain}.


Add an IP Address to an API Key

You should add an address to an API key if you are making requests from the server-side, or if you are using localhost as a domain.

To add an allowed IP address to an API key, make a PUT request to https://api.data-8.co.uk/ApiKey/{key}/allowedIPs/{network}/{prefix}.

If you want to add an IP address to an API key but aren't sure what to enter for the network or prefix parameters, you can use the alternate method of adding an IP address to an API key; Make a POST request to https://api.data-8.co.uk/ApiKey/{key}/allowedIPs and pass the IP address as a string in the body of the request.


Remove an IP Address from an API Key

If you have added the domain localhost to the API key, you will need to remove this before removing the last IP address from the key.

To remove an allowed IP address from an API key, make a DELETE request to https://api.data-8.co.uk/ApiKey/{key}/allowedIPs/{network}/{prefix}.


Add an Allowed Service to an API Key

Adding an allowed service will restrict the API key to only work on the specified service and method.

To add an allowed service to an API key, make a PUT request to https://api.data-8.co.uk/ApiKey/{key}/allowedServices/{service}.


Remove an Allowed Service from an API Key

To remove an allowed service from an API key, make a DELETE request to https://api.data-8.co.uk/ApiKey/{key}/allowedServices/{service}.


Other API Key Methods

There are some other API key methods that are not described here. These are listed below.