---
title: "Get Identities Operation"
url: "https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/get-identities"
version: "6.2"
language: "csharp"
---

# Get Identities Operation

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/get-identities.java.md), [Python](https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/get-identities.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/get-identities.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/get-identities.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**
>
> - Upon document creation, providing a collection name with a pipe symbol (`|`)
>   will cause the server to generate an ID for the new document called an **identity**.  
>   E.g. `companies|`
>
> - The identity document ID is unique across the entire cluster within the database scope.  
>   It is composed of the provided collection name and an integer value that is continuously incremented.
>
> - Identity values can also be managed from the Studio [identities](https://docs.ravendb.net/6.2/studio/database/documents/identities-view.md) view.
>
> - Use `GetIdentitiesOperation` to get the dictionary that maps collection names to their corresponding latest identity values.
>
> > **Info**
> >
> > Learn more about identities in:
> >
> > - [Document identifier generation - Identity ID](https://docs.ravendb.net/6.2/server/kb/document-identifier-generation.md#identity-id)
> > - [Working with document identifiers](https://docs.ravendb.net/6.2/client-api/document-identifiers/working-with-document-identifiers.md#identities)
>
> - In this page:
>
>   - [Get identities operation](#get-identities-operation)
>   - [Syntax](#syntax)

## Get identities operation

### Sync

```csharp
// Create a document with an identity ID:
// ======================================

using (var session = store.OpenSession())
{
  // Request the server to generate an identity ID for the new document. Pass:
  //   * The entity to store
  //   * The collection name with a pipe (|) postfix 
  session.Store(new Company { Name = "RavenDB" }, "companies|");
  
  // If this is the first identity created for this collection,
  // and if the identity value was not customized
  // then a document with an identity ID "companies/1" will be created
  session.SaveChanges();
}

// Get identities information:
// ===========================

// Define the get identities operation
var getIdentitiesOp = new GetIdentitiesOperation();

// Execute the operation by passing it to Maintenance.Send
Dictionary<string, long> identities = store.Maintenance.Send(getIdentitiesOp);

// Results
var latestIdentityValue = identities["companies|"]; // => value will be 1
```

### Async

```csharp
// Create a document with an identity ID:
// ======================================

using (var asyncSession = store.OpenAsyncSession())
{
  // Request the server to generate an identity ID for the new document. Pass:
  //   * The entity to store
  //   * The collection name with a pipe (|) postfix 
  asyncSession.StoreAsync(new Company { Name = "RavenDB" }, "companies|");
  
  // If this is the first identity created for this collection,
  // and if the identity value was not customized
  // then a document with an identity ID "companies/1" will be created
  asyncSession.SaveChangesAsync();
}

// Get identities information:
// ===========================

// Define the get identities operation
var getIdentitiesOp = new GetIdentitiesOperation();

// Execute the operation by passing it to Maintenance.SendAsync
Dictionary<string, long> identities = await store.Maintenance.SendAsync(getIdentitiesOp);

// Results
var latestIdentityValue = identities["companies|"]; // => value will be 1
```

## Syntax

```csharp
public GetIdentitiesOperation();
```

## See also

- [Working with Document Identifiers](https://docs.ravendb.net/6.2/client-api/document-identifiers/working-with-document-identifiers.md)
- [Global ID Generation Conventions](https://docs.ravendb.net/6.2/client-api/configuration/identifier-generation/global.md)
- [Type-specific ID Generation Conventions](https://docs.ravendb.net/6.2/client-api/configuration/identifier-generation/type-specific.md)
- [Document Identifier Generation](https://docs.ravendb.net/6.2/server/kb/document-identifier-generation.md#identity-id)
- [Document Identifier Generation](https://docs.ravendb.net/6.2/server/kb/document-identifier-generation.md)
- [What are Operations](https://docs.ravendb.net/6.2/client-api/operations/what-are-operations.md)
- [Seed identity](https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/seed-identity.md)
- [Increment next identity](https://docs.ravendb.net/6.2/client-api/operations/maintenance/identities/increment-next-identity.md)
