> For the complete documentation index, see [llms.txt](https://docs.verygoodsecurity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verygoodsecurity.com/vault/developer-tools/larky/code-examples/redact-reveal.md).

# Redact/reveal

> To try it out today, email us at <support@vgs.io>

## Working with Vault

This page demonstrates how Larky is flexible and shows its benefit of doing many different things within one piece of code which can be placed under one route filter. The code is ready for use together with `curl` examples.

### Larky code sample

There is an example of code below which does different types of body manipulations:

* Redact of `card_number` in two different formats and Persistent storage
* Redact of `cvv` in Volatile storage
* Reveal of `secret` value
* Setting the new values into the new fields
* Removing the old fields from the body

```python
load('@stdlib/json', 'json')
load("@stdlib//builtins", builtins="builtins")
load("@vgs//vault", "vault")

def process(input, ctx):
    body = json.loads(str(input.body))

    # reading data from body
    card = body['card_number']
    cvv = body['cvv']
    alias4 = body['secret']

    # redact operation
    alias1 = vault.redact(card, storage='persistent', format='FPE_SIX_T_FOUR')
    alias2 = vault.redact(card, storage='persistent', format='UUID')
    alias3 = vault.redact(cvv, storage='volatile', format='UUID')

    # reveal operation
    secret = vault.reveal(alias4)

    # setting body
    body['card_6T4'] = alias1
    body['card_generic'] = alias2
    body['cvv_alias'] = alias3
    body['secret'] = secret

    # remove odd values
    body.pop('card_number')
    body.pop('cvv')

    # If you need to remove the alias
    # vault.delete(alias4)

    input.body = builtins.bytes(json.dumps(body))
    return input
```

### Testing

Request to send:

```bash
curl {VAULT_URL}/post \
  -H 'Content-Type: application/json' \
  -d '{
    "card_number": "4532251801577121",
    "cvv": "123",
    "secret": "tok_sandbox_vvLyaGWnxm5msxd8Zh3QS1"
  }'
```

Response example:

```json
{
  "card_6T4": "4532250530167121",
  "card_generic": "tok_sandbox_hUTo6bTm4kRrTKyoNfBCPm",
  "cvv_alias": "tok_sandbox_qjoDDEgRsvSUeGdkDNW6XA",
  "secret": "FNfcatCkg5yqh5mPBEwuxbbVFNfcatCkg5yqh5mPBEwuxbbV"
}
```

### Useful links

* [Supported formats](/vault/tokens.md#alias-formats)
* [YAML file export/import](/vault/developer-tools/vault-management/yaml.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/larky/code-examples/redact-reveal.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
