Jump toUpdate content

How to generate an API key

Reviewed on 08 June 2021Published on 12 March 2020

API keys are unique identifiers associated with your Scaleway projects and consist of an Access Key and a Secret Key. They allow you to use the Scaleway API.

Each Scaleway project can have several API keys, to give multiple accesses to the same project. API keys are like passwords, they allow total access to your account - do not share them! If you ever think your API key might be compromised, delete it and create a new one.

Creating an API key can be done directly from the Scaleway console:

  1. From the Scaleway console, navigate to the Credentials tab of your Project Dashboard:

  2. Scroll down to the API Key section:

  3. Click Generate new API key. The following pop-up appears:

  4. Add an API Key purpose (for your own reference), or leave this blank. Then click Generate API Key.

    The two parts of your API Key (Access Key and Secret Key) are displayed. Take careful note of the Secret Key, as it will not be recoverable or viewable after this point.

  5. Click OK to conclude.

How to use your API key

This is an example of one way you can use your API key: to make a call to the Scaleway Authentication API. You will store your Access Key and Secret Key as environment variables. Then, you will use curl to call the Scaleway API and authenticate yourself with your API key. You will receive back a token containing information about your account, including your user_id, project_id and organization_id, among other details.

Tip:

These instructions are for Linux/Mac operating systems. For Windows, when storing environment variables, use the set command instead of export.

  1. Open a terminal and execute the following commands. Replace your_access_key and your_secret_key with the access and secret keys you generated at the previous step.

    export SCW_ACCESS_KEY=your_access_key
    export SCW_SECRET_KEY=your_secret_key
    Tip:

    You will need to repeat these export commands every time you open a new shell session. To avoid the need for repetition, open your ~/.bashrc or ~/.zshrc files in a text editor and append the export commands to the file. Save and exit the file, and perform source ~/.bashrc (or source ~/.zshrc) to finish.

  2. Execute the following command:

curl https://account.scaleway.com/tokens/$SCW_ACCESS_KEY -H "X-Auth-Token: $SCW_SECRET_KEY"

You will receive a response similar to the following:

{
"token": {
"access_key": <SCW_ACCESS_KEY>,
"user_id": <SCW_USER_ID>,
"expires": null,
"creation_date": "2020-11-09T14:23:45.927530+00:00",
"creation_ip": "195.154.229.35",
"category": "user_created",
"deletion_date": null,
"inherits_user_perms": false,
"roles": {
"role": null,
"organization": null
},
"description": "",
"project_id": <SCW_PROJECT_ID>,
"organization_id": <SCW_ORGANIZATION_ID>,
"use_role_key": true
}
}

You can use your API key to authenticate yourself against the Scaleway Developer API, and use this to create and manage all your Scaleway resources.

See Also