# Mongo ObjectId Key (ObjectIdPkGenerator)

The [Mongo ObjectId Key](/app/generation/generators/generator-reference/mongo-objectid-key.md) generator generates values to de-identify fields that contain MongoDB `ObjectId` values. The column value must be 12 bytes long.

## Link object structure <a href="#generator-api-objectid-key-link-object" id="generator-api-objectid-key-link-object"></a>

The ObjectId Key generator does not support linking. It can be self-consistent, but not consistent with another column. You cannot configure differential privacy.

The `metadata` object is populated from the [`ObjectIdPkMetadata`](https://app.tonic.ai/apidocs/index.html#/models/ObjectIdPkMetadata) object. `preserveTimetampAndCounter` indicates whether to only change the random value portion of the identifier, but keep the timestamp and incremented counter portions.

There is no generator-specific configuration.

```json
{
  "schema": "string",
  "table": "string",
  "column": "string",
  "path": "string",  //JSON fields only
  "dataType": "string",  //MongoDB, Amazon DynamoDB, and JSON fields only
  "metadata": {
    "presetId": "string",
    "generatorId": "ObjectIdPkGenerator",
    "isConsistent": false,
    "preserveTimestampAndCounter": false,
    "encryptionProcessor": "x-on", //To use configured Structural data encryption
    "customValueProcessor": "string"  //If custom value processor applied
  }
}
```

## Example replacement <a href="#generator-api-objectid-key-replacement" id="generator-api-objectid-key-replacement"></a>

In the following example replacement for the Mongo ObjectId Key generator, consistency is disabled.

Only the random value portion of the identifier is changed.

```json
{
  "name": "userid",
  "schema": "public",
  "table": "users",
  "links": [
    {
      "schema": "public",
      "table": "users",
      "column": "user_id",
      "dataType": "ObjectId",
      "metadata": {
        "presetId": "ObjectIdPkGenerator",
        "generatorId": "ObjectIdPkGenerator",
        "isConsistent": false,
        "preserveTimestampAndCounter": true
      }
    }
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference/generator-api-ref-objectid-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
