# Set up Coauthor

Coauthor runs in the Collaboration Server On-Premises image. It needs no extra container and no switch. Your license key turns it on. This page takes you from the license key to a first edit by an agent. After each step, a **You should see** line tells you how to check it.

Coauthor gives your AI agents tools to read and edit documents through the Model Context Protocol (MCP). To learn what it does, see the [Coauthor](../../guides/editing-toolkit/coauthor/overview.md) guides.

<a id="choose-your-path"></a>

## Choose your path

The same image runs with collaboration and without it. Your license decides which one you get. It includes Coauthor and collaboration, or Coauthor only. We tell you which one when we send it. If your editors use your server now, it has collaboration.

|                           | With collaboration                               | Without it                       |
| ------------------------- | ------------------------------------------------ | -------------------------------- |
| **Your license includes** | Coauthor and collaboration                       | Coauthor only                    |
| **Documents**             | Live documents, uploaded documents and snapshots | Uploaded documents and snapshots |
| **Who opens sessions**    | Your backend, Claude Code, or a chat app         | Your backend only                |

Without collaboration, there are no live documents. Claude Code and chat apps open their own sessions, and they work on live documents only. So they do not work on this path. Your backend opens every session, and gives the session token to your agent. [Document types](../../guides/editing-toolkit/coauthor/document-types.md) explains the three types.

Some steps differ by path. Those steps have a part for each one.

<a id="before-you-start"></a>

## Before you start

Have these ready:

* **A license that includes Coauthor.** During Early Access, [contact us](https://ckeditor.com/contact/) to get one.
* **Your editor bundle, with CKEditor 5 v49.0.0 or later.** Step 5 adds `DocumentCompare` to it.
* **2 CPU and 4 GB of memory for each container that runs sessions.** Step 3 sets the memory limit. [Metrics](metrics.md) shows how to watch it.

<a id="1-install-or-update-the-server"></a>

## 1. Install or update the server

<a id="update-a-running-server"></a>

### Update a running server

With an online license, you need to do nothing. When we add Coauthor to your license, your server gets it on its own.

With an offline license, you need a new license key. [Get your License key](installation/quickstart.md#step-2-get-your-license-key) shows where to find it. Then:

1. Set the new key in `LICENSE_KEY` everywhere you set it now.
2. Restart the containers. A rolling restart works, one container at a time. Open editing sessions keep working. Finish the restart before you go on.

<a id="new-install"></a>

### New install

Set up the server as these pages describe. Coauthor needs nothing more than a normal install:

1. Check the [Requirements](requirements.md).
2. Follow [Installation](installation/overview.md). It sets up the SQL database, Redis and the server. [Docker](installation/examples/docker.md) and [Kubernetes](installation/examples/kubernetes.md) show full examples.
3. Set `LICENSE_KEY` to your license key.

With Coauthor only, live documents and collaboration are not available. Coauthor, the Management Panel and the bundle upload work as usual.

**You should see:** each container is running, and `<your server URL>/health` answers `200`.

<a id="2-set-the-external-endpoint-only-if-needed"></a>

## 2. Set the external endpoint (only if needed)

[`APPLICATION_EXTERNAL_ENDPOINT`](installation/configuration/application-external-endpoint.md) is the public URL of your server, such as `https://cs.example.com`. Coauthor needs it in two cases:

* **A chat app signs in with OAuth from another machine.** Coauthor checks that each token was made for this URL. If you leave it empty, Coauthor uses `http://localhost:8000`, and an app on another machine cannot sign in. You also need to [register your own login server](../../guides/editing-toolkit/coauthor/authentication.md#register-your-login-server). This case needs collaboration, because chat apps work on live documents.
* **You run a separate Collaboration Worker, and your agent edits live documents.** The worker runs editors in the background, and they join each document through this URL. Set the same value on each worker container.

In all other cases, you can leave it empty. That includes the built-in worker, and uploaded documents only. A token signed with your access key needs no OAuth.

If you set it, use a full URL that starts with `http://` or `https://`. Otherwise, the server does not start. Restart the containers after you set it.

**You should see:** `<APPLICATION_EXTERNAL_ENDPOINT>/health` answers `200`.

<a id="3-set-container-memory"></a>

## 3. Set container memory

Give each container that runs sessions 2 CPU and 4 GB, with a memory limit on the container itself. [Limits](limits-and-scaling.md#limits) shows which containers, and how to set it.

**You should see:** after a restart, the container logs do **not** show `The container memory monitor is disabled.` If they show it, see [Containers without a memory limit](limits-and-scaling.md#containers-without-a-memory-limit).

<a id="4-create-an-environment-and-keys"></a>

## 4. Create an environment and keys

Create an environment, an access key and an API secret in the [Management Panel](management.md). With collaboration, you can use the environment that your editors use now.

To script it, use the [Management REST API](management.md#cloud-services-management-rest-api). [Creating an environment in Node.js](../../examples/on-premises/creating-environment-nodejs.md) creates the environment and the access key. Wait at least 10 seconds before you add the API secret.

The commands on this page read these shell variables:

```sh
export CS_URL='<your server URL>'   # for example https://cs.example.com, with no / at the end
export ENVIRONMENT_ID='<environmentId>'
export TOOLKIT_URL="$CS_URL/toolkit/v1/environments/$ENVIRONMENT_ID"
```

<a id="5-upload-the-editor-bundle"></a>

## 5. Upload the editor bundle

Add `DocumentCompare` to your editor bundle, and upload it under a new version. [Add DocumentCompare to your editor bundle](../../guides/editing-toolkit/coauthor/set-up.md#add-documentcompare-to-your-editor-bundle) shows how, with the on-premises address. With collaboration, switch your editors to the new version too.

If you start from the [upload script in the Quick start](../../guides/editing-toolkit/coauthor/quick-start.md#upload-the-editor-bundle), make two changes:

1. Send the upload to `<your server URL>/api/v5/<environmentId>/editors` instead of the cloud address.
2. Without collaboration, leave out `RealTimeCollaborativeEditing`, `RealTimeCollaborativeComments` and `RealTimeCollaborativeTrackChanges`.

Set the version that you uploaded:

```sh
export BUNDLE_VERSION='<bundleVersion>'
```

<a id="6-connect-your-agent"></a>

## 6. Connect your agent

* **The MCP address** is `$TOOLKIT_URL/mcp`. See [Find the MCP address](../../guides/editing-toolkit/coauthor/set-up.md#find-the-mcp-address).
* **Tokens:** your backend signs them with the access key. See [Authentication](../../guides/editing-toolkit/coauthor/authentication.md).
* **Without collaboration,** your agent cannot open sessions itself. The `openSession` tool works on live documents only. So your backend opens each session over REST, as in step 7, and gives the session token to your agent. With that token, the agent connects to the MCP address and edits the document.
* **The steps** that every agent takes are in [Connect an agent](../../guides/editing-toolkit/coauthor/connect-an-agent.md).

<a id="7-test-it"></a>

## 7. Test it

<a id="with-collaboration"></a>

### With collaboration

Follow [Example 1: Claude Code](../../guides/editing-toolkit/coauthor/quick-start.md#example-1-claude-code) in the Quick start, with two changes:

* Set `COAUTHOR_URL` to your `TOOLKIT_URL`.
* Use the ID of a document that is open in your editor, instead of `pricing`.

**You should see:** Claude Code edits the document, and the change arrives in your editor.

<a id="without-collaboration"></a>

### Without collaboration

Your backend opens a session on an uploaded document. Your agent edits it, and finishes the session. Then your backend reads the edited document. Here, `curl` plays both parts. It calls the same tools as an agent does over MCP, in their REST form.

First, [sign a backend token](../../guides/editing-toolkit/coauthor/authentication.md#sign-a-backend-token) with `sessions:open`, `sessions:read`, `sessions:apply` and `sessions:close` on all documents (`*`). Set it in `BACKEND_TOKEN`.

1. Open a session with the bundle version from step 5:

   ```sh
   curl -sS -X POST "$TOOLKIT_URL/sessions" \
   	-H "Authorization: Bearer $BACKEND_TOKEN" -H 'Content-Type: application/json' \
   	-d '{ "target": { "type": "uploaded", "bundleVersion": "'"$BUNDLE_VERSION"'", "document": { "content": { "data": "<p>The plan costs $30 per month.</p>" } } }, "actor": { "id": "setup-agent", "name": "Setup agent" }, "appliedBy": "agent", "finishBy": "agent" }'
   ```

   **You should see:** JSON with `id`, `token` and `expiresAt`. Copy the values:

   ```sh
   export SESSION_ID='<id>'
   export SESSION_TOKEN='<token>'
   ```

2. As the agent, edit the document with the session token:

   ```sh
   curl -sS -X POST "$TOOLKIT_URL/sessions/$SESSION_ID/tools/editDocument" \
   	-H "Authorization: Bearer $SESSION_TOKEN" -H 'Content-Type: application/json' \
   	-d '{ "edits": [ { "oldString": "$30 per month", "newString": "$35 per month" } ] }'
   ```

   **You should see:** JSON with `"accepted": true`.

3. As the agent, finish the session. This applies the edit and closes the session:

   ```sh
   curl -sS -X POST "$TOOLKIT_URL/sessions/$SESSION_ID/tools/finish" \
   	-H "Authorization: Bearer $SESSION_TOKEN" -H 'Content-Type: application/json' \
   	-d '{}'
   ```

   **You should see:** JSON with `operations` above `0`.

4. As the backend, check the session:

   ```sh
   curl -sS "$TOOLKIT_URL/sessions/$SESSION_ID" -H "Authorization: Bearer $BACKEND_TOKEN"
   ```

   **You should see:** `"status": "closed"`, and `lastApply` with `operations` above `0`. If the status is still `open`, wait a second and run it again.

5. As the backend, read the edited document:

   ```sh
   curl -sS "$TOOLKIT_URL/sessions/$SESSION_ID/document" -H "Authorization: Bearer $BACKEND_TOKEN"
   ```

   **You should see:** `document.content.data` holds `The plan costs $35 per month.`

Your own agent makes the same calls over MCP, with the session token.

<a id="troubleshooting"></a>

## Troubleshooting

<a id="http-403-license-has-no-rights-to-service-on-a-coauthor-call"></a>

### HTTP 403 `license-has-no-rights-to-service` on a Coauthor call

Check that you set the new `LICENSE_KEY` everywhere, and restart the containers.

<a id="http-403-license-has-no-rights-to-service-on-a-live-document"></a>

### HTTP 403 `license-has-no-rights-to-service` on a live document

Your license does not include collaboration. Live documents and the editors of your application need it. Use uploaded documents or snapshots. Or [contact us](https://ckeditor.com/contact/) for a license with collaboration.

<a id="http-400-bundle-missing-plugin"></a>

### HTTP 400 `bundle-missing-plugin`

The bundle of the session has no `DocumentCompare`. For a live document, the editors still use an old bundle. Add `DocumentCompare`, and upload the bundle under a new version, as in step 5. For live documents, switch your editors to it.

<a id="http-400-editor-too-old"></a>

### HTTP 400 `editor-too-old`

The bundle uses an older CKEditor 5. Build the bundle with CKEditor 5 v49.0.0 or later, and upload it under a new version.

<a id="http-503-the-editor-is-busy"></a>

### HTTP 503: the editor is busy

The message is `The editor is busy and could not run this call in time`. Every container that runs sessions is full, or near its memory limit. Wait a moment, and try again. If it keeps happening, add containers. See [Limits and scaling](limits-and-scaling.md).

<a id="http-409-on-the-bundle-upload"></a>

### HTTP 409 on the bundle upload

You uploaded this `bundleVersion` before. Upload under a new version, and set it in `BUNDLE_VERSION`.

<a id="the-server-does-not-start-after-you-set-application_external_endpoint"></a>

### The server does not start after you set `APPLICATION_EXTERNAL_ENDPOINT`

The value is not a full URL. Use a URL that starts with `http://` or `https://`, such as `https://cs.example.com`.

<a id="a-chat-app-cannot-sign-in"></a>

### A chat app cannot sign in

`APPLICATION_EXTERNAL_ENDPOINT` is empty, or not the URL that the app reaches. Set it to the public URL of your server, as in step 2.

[Errors](https://help.cke-cs.com/toolkit/v1/docs#section/Errors/Codes) in the API reference lists every Coauthor error.

<a id="next-steps"></a>

## Next steps

* [Limits and scaling](limits-and-scaling.md) shows how many sessions a container keeps, and how to scale.
* [Metrics](metrics.md) shows what to watch, and when to add containers.
* [Connect an agent](../../guides/editing-toolkit/coauthor/connect-an-agent.md) shows how your agent works on a document.
* [Document types](../../guides/editing-toolkit/coauthor/document-types.md) helps you choose what your agent edits.
* [Security and compliance](../../guides/editing-toolkit/coauthor/security-and-compliance.md) shows what data Coauthor keeps, and for how long.

---

Full index of the Cloud Services documentation: [llms.txt](../../../llms.txt)
