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

# Put Document Command

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/commands/documents/put.md), [Java](https://docs.ravendb.net/6.2/client-api/commands/documents/put.java.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."

> **Note**
>
> - Use `PutDocumentCommand` to insert a document to the database or update an existing document.
>
> - In this page:
>
>   - [Example](#example)
>   - [Syntax](#syntax)

## Example

```python
# Create a new document
doc = Category(name="My category", description="My category description")

# Create metadata on the document
doc_info = DocumentInfo(collection="Categories")

# Convert your entity to a dict
dict_doc = session.entity_to_json.convert_entity_to_json_static(doc, session.conventions, doc_info)

# The put command (parameters are document ID, change vector check is None, the document to store)
command = PutDocumentCommand("employees/1-A", None, dict_doc)
# Request executor sends the command to the server
session.advanced.request_executor.execute_command(command)
```

## Syntax

```python
class PutDocumentCommand(RavenCommand[PutResult]):
  def __init__(self, key: str, change_vector: Optional[str], document: dict): ...
```

| Parameter | Type | Description |
| - | - | - |
| **key** | `str` | Unique ID under which document will be stored |
| **change\_vector** | `str` (optional) | Entity changeVector, used for concurrency checks (`None` to skip check) |
| **document** | `dict` | The document to store |

## See also

- [Get document](https://docs.ravendb.net/6.2/client-api/commands/documents/get.python.md)
- [Delete document](https://docs.ravendb.net/6.2/client-api/commands/documents/delete.python.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.md)
