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

# Update CRDT Data

Use this API to replace existing CRDT editor data on the backend. The update creates proper CRDT operations on the existing document state so connected clients can pick up the change. Use it with the [Multiplayer Editing (Yjs)](https://velt.dev/docs/realtime-collaboration/crdt/setup/core.md) feature.

# Endpoint

`POST https://api.velt.dev/v2/crdt/update`

# Headers

**x-velt-api-key** `string` *required*

Your API key.

**x-velt-auth-token** `string` *required*

Your [Auth Token](https://velt.dev/docs/security/auth-tokens.md).

# Body Parameters

**data** `object` *required*

**properties**

**organizationId** `string` *required*

Organization ID where the document belongs

**documentId** `string` *required*

Document ID containing the CRDT editor data

**editorId** `string` *required*

Unique identifier for the specific CRDT editor instance

**data** `string | object | array` *required*

The new CRDT content to replace existing data with. Must match the specified `type`: string for `text`/`xml`, object for `map`, array for `array`.

**type** `string` *required*

The CRDT data type. One of: `text`, `map`, `array`, `xml`.

**contentKey** `string`

Yjs content key name. Defaults to `content`. Use `default` for TipTap.

## Example Requests

**Text (e.g., CodeMirror):**

```JSON theme={null}
{
  "data": {
    "organizationId": "YOUR_ORGANIZATION_ID",
    "documentId": "YOUR_DOCUMENT_ID",
    "editorId": "my-collab-note",
    "data": "Updated collaborative content!",
    "type": "text"
  }
}
```

**Map (e.g., ReactFlow):**

```JSON theme={null}
{
  "data": {
    "organizationId": "YOUR_ORGANIZATION_ID",
    "documentId": "YOUR_DOCUMENT_ID",
    "editorId": "my-flow-editor",
    "data": { "nodes": { "node-1": { "label": "Updated" } }, "edges": {} },
    "type": "map"
  }
}
```

**Array:**

```JSON theme={null}
{
  "data": {
    "organizationId": "YOUR_ORGANIZATION_ID",
    "documentId": "YOUR_DOCUMENT_ID",
    "editorId": "my-list-editor",
    "data": [{ "id": "1", "text": "Updated Item 1" }, { "id": "3", "text": "New Item 3" }],
    "type": "array"
  }
}
```

**XML (e.g., TipTap):**

```JSON theme={null}
{
  "data": {
    "organizationId": "YOUR_ORGANIZATION_ID",
    "documentId": "YOUR_DOCUMENT_ID",
    "editorId": "my-rich-text-editor",
    "data": "<paragraph>Updated content</paragraph><heading level=\"2\">New heading</heading>",
    "type": "xml",
    "contentKey": "default"
  }
}
```

# Response

## Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "CRDT data updated successfully."
  }
}
```

## Error Responses

**No CRDT data found for the given editor ID:**

```JSON theme={null}
{
  "error": {
    "message": "No CRDT data found for this editor ID.",
    "status": "NOT_FOUND"
  }
}
```

**Invalid arguments:**

```JSON theme={null}
{
  "error": {
    "message": "Data must be a string for type text.",
    "status": "INVALID_ARGUMENT"
  }
}
```

```json theme={null}
{
  "result": {
    "status": "success",
    "message": "CRDT data updated successfully."
  }
}
```


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