---
title: "How to Check if a Document Exists"
url: "https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-document-exists"
version: "6.2"
language: "python"
---

# How to Check if a Document Exists

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-document-exists.md), [Java](https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-document-exists.java.md), [PHP](https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-document-exists.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-document-exists.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**
>
> - To check whether the database contains a certain document,  
>   use the `session.advanced` operations `exists` method.
>
> - Calling `exists` does not [load](https://docs.ravendb.net/6.2/client-api/session/loading-entities.python.md)
>   the document entity to the session, and the session will not track it.
>
> - In this page:
>   - [Check if document exists](#check-if-document-exists)
>   - [Syntax](#syntax)

## Check if document exists

```python
exists = session.advanced.exists("employees/1-A")

if exists:
  ...  # Document 'employees/1-A' exists
```

## Syntax

```python
def exists(self, key: str) -> bool: ...
```

| Parameter | Type | Description |
| - | - | - |
| **key** | `str` | The ID of the document to look for |

| Return Value | Description |
| - | - |
| `bool` | `True` - this document exists in the database.<br />`False` - The document does Not exist in the database |

## See also

- [What is a Session and How Does it Work](https://docs.ravendb.net/6.2/client-api/session/what-is-a-session-and-how-does-it-work.python.md)
- [Loading Entities](https://docs.ravendb.net/6.2/client-api/session/loading-entities.python.md)
- [How to Check if Entity has Changed](https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-entity-has-changed.python.md)
- [How to Check if There are Any Changes on a Session](https://docs.ravendb.net/6.2/client-api/session/how-to/check-if-there-are-any-changes-on-a-session.python.md)
- [Evict Entity From a Session](https://docs.ravendb.net/6.2/client-api/session/how-to/evict-entity-from-a-session.python.md)
- [Refresh Entity](https://docs.ravendb.net/6.2/client-api/session/how-to/refresh-entity.python.md)
