Initial setup of API keys for a self-hosted instance.
Fonoster uses a Workspace-centric approach, meaning all operations are performed against a specific Workspace. By default, when you self-host Fonoster, it automatically creates a default Workspace along with a default username and password.
Once the installation is complete, create a new file called index.js and add the following code:
Copy
const SDK = require("@fonoster/sdk");// Replace these with your valuesconst client = new SDK.Client({ accessKeyId: "WO00000000000000000000000000000000", endpoint: "localhost:8449", allowInsecure: true});// Use your actual username and password hereclient.login("admin@fonoster.local", "changeme").then(async () => { const apikeys = new SDK.ApiKeys(client); apikeys.createApiKey({ role: "WORKSPACE_ADMIN", }).then((result) => { console.log(result); });});
4
Run the script
Finally, run the script.
Copy
node index.js
If everything goes well, you should see the new API key printed to the console, and you can use it to log in to your Workspace.