> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fonoster.com/llms.txt
> Use this file to discover all available pages before exploring further.

# First API Keys

> Initial setup of API keys for a self-hosted instance.

import WipDocsWarning from '/snippets/wip-docs-warning.mdx';

<WipDocsWarning />

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.

```text theme={"system"}
Default accessKeyId: WO00000000000000000000000000000000
Default username: admin@fonoster.local
Default password: changeme
```

You must create API keys to log in to a Workspace and perform operations.

## Create an API Key

<Steps>
  <Step title="Prepare the environment">
    First, create a new folder (e.g., fonoster-apikeys-demo) and navigate to it.

    ```bash theme={"system"}
    mkdir fonoster-apikeys-demo
    cd fonoster-apikeys-demo
    npm init -y
    ```
  </Step>

  <Step title="Install the SDK">
    Install the `@fonoster/sdk` package.

    ```bash theme={"system"}
    npm install @fonoster/sdk
    ```
  </Step>

  <Step title="Create the script">
    Once the installation is complete, create a new file called `index.js` and add the following code:

    ```javascript theme={"system"}
    const SDK = require("@fonoster/sdk");

    // Replace these with your values
    const client = new SDK.Client({ 
      accessKeyId: "WO00000000000000000000000000000000",
      endpoint: "localhost:8449",
      allowInsecure: true
    });

    // Use your actual username and password here
    client.login("admin@fonoster.local", "changeme").then(async () => {
      const apikeys = new SDK.ApiKeys(client);

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

  <Step title="Run the script">
    Finally, run the script.

    ```bash theme={"system"}
    node index.js
    ```
  </Step>
</Steps>

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.

<CardGroup cols={2}>
  <Card title="SDK" icon="code" href="https://www.npmjs.com/package/@fonoster/sdk">
    SDK documentation at NPM.
  </Card>

  <Card title="Command-Line" icon="square-terminal" href="https://www.npmjs.com/package/@fonoster/ctl">
    Command-line documentation at NPM.
  </Card>
</CardGroup>
