This documentation is actively being improved. You may encounter gaps or incomplete sections as we refine and expand the content. We appreciate your understanding and welcome any feedback to help us make this resource even better!

API keys are used to authenticate requests to the API. API keys operate at the Workspace level and are used to authenticate requests to the API. You can create multiple API keys for a single Workspace, and each API key can be given different permissions.

All API keys have an Access Key ID and an Access Key Secret. The Access Key ID is used to identify the API key, and the Access Key Secret is used to authenticate the request. You should keep the Access Key Secret secure and never share it with anyone.

You can differentiate API keys’ Access Key ID from Workspace’s Access Key ID by the prefix “AP”.

Workspace’s Access Key ID have the “WO” prefix, and User’s Access Key ID has the “US” prefix

To create an API key with the SDK, first create a new Node.js project and install the SDK:

mkdir create-apikey
cd create-apikey
npm init -y
npm install @fonoster/sdk

Then, create a new file called index.js and add the following code:

const SDK = require("@fonoster/sdk");

// Replace with your Workspace's Access Key ID
const client = new SDK.Client({ accessKeyId: "WO00000000000000000000000000000000" });

// Use the username and password of your Fonoster account
client.login("youruser@youremail.com", "yourpassword").then(async () => {
  const apikeys = new SDK.ApiKeys(client);

  apikeys.createApiKey({
    role: "WORKSPACE_ADMIN",
  }).then((result) => {
    console.log(result);
  });
});

Run the script with the following command:

node index.js

Remember to save the Access Key ID and Access Key Secret in a secure location. You will not be able to retrieve the Access Key Secret again.