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

# ContentServer Websocket API

This section describes the payload of the WebSocket API exposed by the ContentServer.

> base URL: `ws://<server>:<port>/content/ws/v5`\
> version: `v5`

## ContentServer Websocket API

The websocket of the ContentServer provides the ability to listen for changes in a directory.
The messages sent through the websocket follow the ones received by the `IContentListener`.
Every time a change is made, a message is sent through that connection.

The message from the ContentServer depends on the action performed: ADD, DELETE or UPDATE.

The following listing details the content sent through the payload:

### Update an entry of the ContentServer

Action: `Updated`

When the you update an entry of the ContentServer, the ContentServer returns the newly updated entry's content and metadata.

Example:

```
{
    path: "foo/bar",
    action: "UPDATED",
    entry: {
        content: "baz",
        isDirectory: false,
        owners: ["admin"],
        readers: ["admin"],
        timestamp: 1583832594206,
        lastEditor: "admin",
        canRead: true,
        canWrite: true
    }
}
```

Key attributes:

* `path`: path to the entry.
* `content`: content of the entry.
* `isDirectory`: whether the entry is a directory or not.
* `owners`: list of users with edit access to the entry.
* `readers`: list of users with read access to the entry.
* `timestamp`: the UNIX timestamp of the last edit.
* `lastEditor`: the user who performed the update.
* `canRead`: whether the current user has read access to the entry.
* `canWrite`: whether the current user has write access to the entry.

### Add an entry to the ContentServer

Action: `Add`

When you add a new entry to the ContentServer, the ContentServer returns the metadata of the created entry.

Example:

```
{
    path: "/ui/bookmarks/content/d4e",
    action: "ADD",
    entry: {
        isDirectory: true,
        owners: ["admin"],
        readers: ["admin"],
        timestamp: 1583832594206,
        lastEditor: "admin",
        canRead: true,
        canWrite: true
    }
}
```

Key attributes:

* `path`: path to the entry.
* `isDirectory`: whether the entry is a directory.
* `owners`: list of users with edit access to the entry.
* `readers`: list of users with read access to the entry.
* `timestamp`: the UNIX timestamp of the last edit.
* `lastEditor`: the user who performed the update.
* `canRead`: whether the current user has read access to the entry.
* `canWrite`: whether the current user has write access to the entry.

### Remove an entry of the ContentServer

When the user deletes an entry of the ContentServer, it only returns the path of the removed entry.

Action: `Remove`

```
{
    path: "/ui/bookmarks/content/d4e",
    action: "REMOVE"
}
```

### Miscellaneous

There are two further actions, one when the websocket is connected and the other when it disconnects. Each action only contains a single instruction.

Action: `Connected`

Example:

```
{
    id: "foo",
    statusCode: 202,
    instruction: "Connected"
}
```
