> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference/generator-api-ref-alphanumeric-string-key.md).

# Alphanumeric String Key (AlphaNumericPkGenerator)

The [Alphanumeric String Key](/app/generation/generators/generator-reference/alphanumeric-string-key.md) generator can be applied to primary key columns. It generates unique alphanumeric strings of the same length as the input.

For example, for the origin value ABC123, the output value is a six-character alphanumeric string such as D24N05.

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

The Alphanumeric String Key generator can be self-consistent, but not consistent with another column. You cannot configure differential privacy.

The `metadata` object is populated from the [`BaseMetadata`](https://app.tonic.ai/apidocs/index.html#/models/BaseMetadata) object.

`preservePrefix` identifies a specific string that, when it occurs at the beginning of the source values, must be preserved in the destination values.

`numSuffixCharacters` identifies the number of characters at the end of each source value to preserve in the destination value.

`maskDigitsOnly` indicates whether to only mask the numeric characters.

```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": "AlphaNumericPkGenerator",
    "preservePrefix": "string",
    "numSuffixCharacters": integer,
    "maskDigitsOnly": boolean,
    "isConsistent": boolean,
    "encryptionProcessor": "x-on", //To use configured Structural data encryption
    "customValueProcessor": "string" //If custom value processor applied
  }
}
```

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

The following example replacement configures a column to use the built-in generator preset for the Alphanumeric String Key generator.

When a source value starts with `test_`, the destination value also starts with `test_`.

The destination values do not preserve any of the ending characters from the source values.

The generator masks both alphabetical and numeric characters.

The generator is not consistent.

```json
{
  "name": "workclass",
  "schema": "public",
  "table": "employees",
  "links": [
    {
      "schema": "public",
      "table": "employees",
      "column": "workclass",
      "metadata": {
        "presetId": "AlphaNumericPkGenerator",
        "generatorId": "AlphaNumericPkGenerator",
        "preservePrefix": "test_",
        "numSuffixCharacters": 0,
        "maskDigitsOnly": false,
        "isConsistent": false
      }
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
