> ## 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.

# Add CRDT Data

Use this API to create new CRDT editor data on the backend. 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/add`

# 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 CRDT content to store. 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": "Hello, collaborative world!",
    "type": "text"
  }
}
```

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

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

**Array:**

```JSON theme={null}
{
  "data": {
    "organizationId": "YOUR_ORGANIZATION_ID",
    "documentId": "YOUR_DOCUMENT_ID",
    "editorId": "my-list-editor",
    "data": [{ "id": "1", "text": "Item 1" }, { "id": "2", "text": "Item 2" }],
    "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>Hello World</paragraph>",
    "type": "xml",
    "contentKey": "default"
  }
}
```

# Response

## Success Response

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

## Error Responses

**CRDT data already exists for the given editor ID:**

```JSON theme={null}
{
  "error": {
    "message": "CRDT data already exists for this editor ID.",
    "status": "ALREADY_EXISTS"
  }
}
```

**Invalid arguments:**

```JSON theme={null}
{
  "error": {
    "message": "Editor ID is required.",
    "status": "INVALID_ARGUMENT"
  }
}
```

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


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