---
title: "Put Document Command"
url: "https://docs.ravendb.net/6.2/client-api/commands/documents/put"
version: "6.2"
language: "java"
---

# Put Document Command

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/commands/documents/put.md), [Python](https://docs.ravendb.net/6.2/client-api/commands/documents/put.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/commands/documents/put.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/commands/documents/put.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

**Put** is used to insert or update a document in a database.

## Syntax

```java
public PutDocumentCommand(String id, String changeVector, ObjectNode document)
```

| Parameter | Type | Description |
| - | - | - |
| **id** | `String` | Unique ID under which document will be stored |
| **changeVector** | `String` | Entity changeVector, used for concurrency checks (`null` to skip check) |
| **document** | `ObjectNode` | The document to store. You may use `session.advanced().getEntityToJson().convertEntityToJson` to convert your entity to a `ObjectNode` |

## Example

```java
Category doc = new Category();
doc.setName("My category");
doc.setDescription("My category description");

DocumentInfo docInfo = new DocumentInfo();
docInfo.setCollection("Categories");

ObjectNode jsonDoc = session.advanced().getEntityToJson().convertEntityToJson(doc, docInfo);
PutDocumentCommand command = new PutDocumentCommand("categories/999", null, jsonDoc);
session.advanced().getRequestExecutor().execute(command);
```

## See also

- [Get document](https://docs.ravendb.net/6.2/client-api/commands/documents/get.java.md)
- [Delete document](https://docs.ravendb.net/6.2/client-api/commands/documents/delete.java.md)
- [Send multiple commands using a batch](https://docs.ravendb.net/6.2/client-api/commands/batches/how-to-send-multiple-commands-using-a-batch.java.md)
