# Configuration

The Platform SDK uses bearer token authentication. Every client instance is scoped to a single workspace.

## Configuration Parameters

| Parameter     | Type     | Required | Description                                          |
| ------------- | -------- | -------- | ---------------------------------------------------- |
| `apiKey`      | `string` | ✅        | API key from the Amigo dashboard                     |
| `workspaceId` | `string` | ✅        | Workspace ID all requests are scoped to              |
| `baseUrl`     | `string` | ❌        | Override the default `https://api.platform.amigo.ai` |

## Creating a Client

```typescript
import { AmigoClient } from '@amigo-ai/platform-sdk'

const client = new AmigoClient({
  apiKey: 'your-api-key',
  workspaceId: 'your-workspace-id',
})
```

### With a Custom Base URL

Use `baseUrl` to point to a regional or staging endpoint:

```typescript
const client = new AmigoClient({
  apiKey: 'your-api-key',
  workspaceId: 'your-workspace-id',
  baseUrl: 'https://api.platform.amigo.ai', // default
})
```

## Environment Variables

The recommended approach for production is to read credentials from environment variables rather than hardcoding them.

```typescript
import 'dotenv/config'
import { AmigoClient } from '@amigo-ai/platform-sdk'

const client = new AmigoClient({
  apiKey: process.env.AMIGO_API_KEY!,
  workspaceId: process.env.AMIGO_WORKSPACE_ID!,
})
```

Corresponding `.env` file:

```env
AMIGO_API_KEY=your-api-key
AMIGO_WORKSPACE_ID=your-workspace-id
```

### Separate Environments

Use separate `.env` files per environment:

{% tabs %}
{% tab title="Development (.env.dev)" %}

```env
AMIGO_API_KEY=dev_api_key
AMIGO_WORKSPACE_ID=dev_workspace_id
```

{% endtab %}

{% tab title="Production (.env.prod)" %}

```env
AMIGO_API_KEY=prod_api_key
AMIGO_WORKSPACE_ID=prod_workspace_id
```

{% endtab %}
{% endtabs %}

## Getting Your Credentials

### API Key

Generate an API key from the Amigo dashboard:

1. Log in at `https://<your-org-id>.amigo.ai`
2. Navigate to **Settings → API Keys**
3. Click **Create API Key** and optionally set an expiration date.
4. Copy the key. It is only shown once.

{% hint style="warning" %}
**Never commit API keys to source control.** Use environment variables or a secrets manager.
{% endhint %}

### Workspace ID

Your workspace ID appears in the dashboard URL:

```
https://<org-id>.amigo.ai/workspaces/<workspace-id>/...
```

It is also returned in every workspace-scoped API response under the `workspace_id` field.

## Security Best Practices

* **Rotate API keys regularly.** Set an expiration date and rotate before expiry.
* **Use read-only keys where possible.** API keys inherit their creator's permissions.
* **One key per environment.** Use separate keys for development, staging, and production.
* **Never log credentials.** Avoid printing `apiKey` or config objects.

## Next Steps

* [**Quickstart**](/developer-guide/platform-api/platform-sdk/quickstart.md)**.** Make your first API call.
* [**Error Handling**](/developer-guide/platform-api/platform-sdk/error-handling.md)**.** Handle authentication and other errors.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.amigo.ai/developer-guide/platform-api/platform-sdk/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
