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

# Authentication

> Programmatic access to Writesonic Agents: projects, tasks, playbooks, grids, knowledge base, and pages, over a simple API-key-authenticated REST API.

The Agents API is the REST interface to [Writesonic Agents](https://apidocs.writesonic.com/agents/overview.md). It exposes the same capabilities as the [Agents MCP server](https://apidocs.writesonic.com/agents-mcp/mcp-server.md): read your projects, create and manage tasks, inspect playbooks and grids, search your knowledge base, and pull pages reports, all as plain HTTP endpoints you can call from any language.

> [!NOTE]
>
> **Agents is in beta.** Access is currently limited to selected enterprise and agency accounts. To request it, talk to your account manager or [book a demo](https://writesonic.com/?demo=open) with our sales team.

## Base URL

```
https://api.agents.writesonic.com
```

All endpoints are mounted under `/api/v1/business`. Every request is a JSON `POST` (a few reads are `GET`), and every response is JSON.

## Authentication

Every request requires your Writesonic API key in the `X-API-Key` header.

```bash theme={"system"}
curl --request GET \
  --url https://api.agents.writesonic.com/api/v1/business/whoami \
  --header 'X-API-Key: <your-api-key>'
```

### How to find your API key

**1. Log in to Writesonic**

Go to [app.writesonic.com](https://app.writesonic.com) and sign in.

**2. Open the API Dashboard**

Hover over your profile picture in the top-right corner and select **API Dashboard**.

**3. Activate the API**

Switch the activation toggle **on** to enable API access.

**4. Reveal your API key**

Click **Reveal API Key** and copy it.

> [!WARNING]
>
> Never commit your API key to a public repository or ship it in client-side code. Use environment variables or a secrets manager.

## Scoping a request

Your API key belongs to a **workspace** by default. Most endpoints act on a single **project** within it, which you name with a request header.

| Header | Value | Required |
| - | - | - |
| `X-API-Key` | Your Writesonic API key | Always |
| `X-Project-Id` | The project a request targets | For project-scoped endpoints |
| `X-Workspace-Id` | Overrides the workspace your key defaults to | Optional |
| `Content-Type` | `application/json` | For `POST` requests with a body |

> [!NOTE]
>
> `GET /whoami` is the one call that needs no `X-Project-Id`. Call it first, it returns your identity, your teams, and the projects in the active workspace. Use a project's `id` from that response as the `X-Project-Id` header on every other call.

## Your first request

**1. Get your projects**

```bash theme={"system"}
curl --request GET \
  --url https://api.agents.writesonic.com/api/v1/business/whoami \
  --header 'X-API-Key: <your-api-key>'
```

Copy the `id` of the project you want to work with from the `projects` array.

**2. Query that project's tasks**

```bash theme={"system"}
curl --request POST \
  --url https://api.agents.writesonic.com/api/v1/business/tasks/query \
  --header 'X-API-Key: <your-api-key>' \
  --header 'X-Project-Id: <project-id>' \
  --header 'Content-Type: application/json' \
  --data '{"view": "list"}'
```

## Error responses

| Status | Meaning |
| - | - |
| `401` | Missing or invalid API key |
| `403` | Key is valid but lacks access to the project or workspace |
| `422` | Validation error in the request body or headers |
| `429` | Rate limit exceeded |

## MCP or REST?

The Agents API and the [Agents MCP server](https://apidocs.writesonic.com/agents-mcp/mcp-server.md) are two front doors to the same tools.

* Reach for **REST** when you're writing code, a backend job, a script, an integration.
* Reach for **MCP** when you want an AI assistant (Claude, ChatGPT) to call these tools for you in natural language.

Each REST endpoint below does the same job as one MCP tool. The [tools reference](https://apidocs.writesonic.com/agents-mcp/tools-reference.md) lists the REST path for every tool.

Send a tool's arguments as the top-level fields of the JSON body. MCP clients wrap them in an `args` object; the REST API does not.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.