> For the complete documentation index, see [llms.txt](https://docs.metamynd.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metamynd.ai/agent-ownership-verifai/credential-vault.md). Agents can also search and read this documentation through its [MCP server](https://docs.metamynd.ai/~gitbook/mcp).

# Credential Vault

### Credential Custody

The architectural principle described throughout this documentation, **MetaMynd is never a place your secrets sit waiting to be stolen**, is delivered by three mechanisms:

1. **Non-custodial identity keys.** MetaMynd never keeps a durable copy of an agent's own signing key, and several custody options keep it off MetaMynd entirely.
2. **Process separation** between the agent and the process that acts.
3. **A governed Credential Vault** from which a trusted gateway process, never the agent, pulls operational credentials just in time.

#### Identity keys: four ways to hold them

| Option                                     | Who generates the key               | What MetaMynd sees                                                                     | Where the key lives afterwards                                     |
| ------------------------------------------ | ----------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| **Managed, plaintext delivery**            | MetaMynd                            | The private key, once, in the provisioning response                                    | In your config (`agentKey`)                                        |
| **Managed, passphrase-encrypted delivery** | MetaMynd                            | The private key, once; it is returned encrypted under a passphrase you set at issuance | In your config as `agentKeyEncrypted`, decrypted in memory at load |
| **BYOK** (bring your own key)              | You                                 | Only the public key, plus a signed proof of control                                    | Wherever you keep it                                               |
| **Signer daemon**                          | The local `agentsafe-signer` daemon | Only the public key, plus a signed proof of control                                    | Inside the daemon process; the agent process never holds it        |

**Managed keys are shown once and never stored.** When MetaMynd mints a managed Ed25519 keypair for an agent's or principal's `did:hedera` identity, the private key is returned to the owner exactly **once**, at mint or rotate time. The UI labels it "shown once", and it is never written to any database row. The network-identity table that stores the rest of the minted record (DID, public key, HCS topic/tx ids) has no private-key column at all.

**Passphrase-encrypted delivery** (set a passphrase of at least 12 characters in Launchpad's Identity stage, or `passphrase` on `POST /onboarding/agent`) returns `agentKeyEncrypted` with `agentKey: null`. `createGuardFromConfig(config, { passphrase })` in `@metamynd/agentsafe-guard` 0.12.0 or later decrypts it in memory. MetaMynd never stores or logs the passphrase, so a lost passphrase is unrecoverable, the same as a lost BYOK key.

**BYOK and the signer daemon** keep the private key off MetaMynd entirely. With the daemon (`keyProvider: 'daemon'`), the key never enters the agent's own process either. `create-metamynd-agent --byok --daemon-socket <path> --daemon-admin-socket <path>` provisions a new agent this way. See [Key Custody & the Signer Daemon](https://docs.metamynd.ai/verifai-trust-layer/key-custody-and-the-signer-daemon).

The practical consequence of every option: **a lost key has no recovery path.** There is no vault to restore it from, because it was never retained anywhere to restore. The only remedy is rotation: minting a fresh key on the same network, which supersedes the old one (see [DID Issuance](https://docs.metamynd.ai/verifai-trust-layer/did-issuance)). This is a deliberate non-custodial posture, not a missing feature. MetaMynd holding a copy of every agent's private key would be exactly the kind of honeypot the platform is designed to avoid.

#### Operational (upstream) credentials: process separation + the Credential Vault

For the credentials a system needs at runtime to call other services (a payment rail's API key, a merchant integration's token), the boundary is process separation. The default `create-metamynd-agent` scaffold (see [create-metamynd-agent](https://docs.metamynd.ai/sdks/create-metamynd-agent-cli)) generates two separate processes, and only the `gateway/` process ever holds a real credential. The agent process depends on `@metamynd/agentsafe-guard`, signs requests, and never receives one. The `--no-gateway` flag opts out, collapsing back to a single process where the credential-isolation guarantee no longer holds.

The **Credential Vault** lets a gateway source those credentials from a governed store instead of a static `.env` file. Credentials are stored **encrypted at rest** (AES-256-GCM), scoped to an owner and a connector.

{% hint style="info" %}
**Which gateway uses the vault today.** The only built-in client of the vault is [`@metamynd/agentsafe-http-gateway`](https://docs.metamynd.ai/sdks/agentsafe-http-gateway), and it is opt-in. The `gateway/` process that `create-metamynd-agent` scaffolds does **not** read from the vault; it still takes its upstream credential from its own environment.
{% endhint %}

**How release works**

Release happens through exactly one path, `POST /credential-vault/resolve`, and is **just in time and conditional**:

1. **The gateway authenticates the call** with a shared secret sent as the `x-credential-vault-token` header and compared in constant time against the vault's `CREDENTIAL_VAULT_GATEWAY_TOKEN`. The agent process never holds this secret.
2. **The vault requires an Action Passport** for the `authorizationId` being resolved that exists, is **`active`** and is unexpired. No valid passport, no release; this is checked before the credential is even looked up. `active` means **between authorize and capture**: once capture consumes the passport, resolve is refused. A gateway must resolve its credential before it settles the hold.
3. **The tenant comes from the passport, never from the caller.** The vault derives the owner from the Action Passport the gateway presents. One gateway deployment can serve many tenants' agents against the same connector, and a misconfigured or compromised gateway still cannot misroute or spoof which tenant's credential it receives.
4. **The plaintext is decrypted and returned to the gateway for that one call.** It is never returned to, or visible from, the agent process.
5. **Every access, allowed or refused, is audited** to the evidence trail. A refusal records a specific reason (`INVALID_GATEWAY_TOKEN`, `NO_VALID_ACTION_PASSPORT`, `CREDENTIAL_NOT_FOUND`, `DECRYPT_FAILED`), while the caller only ever sees a generic HTTP 403 "Credential not available". The plaintext never enters an audit record.

**Managing credentials**

The vault is administered from the dashboard's **Credential Vault** page, or through the API at `/api/v1/credential-vault`:

| Route                        | Who                               | Purpose                                                                                              |
| ---------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `POST /`                     | Owner                             | Store a credential (`connectorId`, `credentialType`, `value`, optional `label` and `highRisk` flag). |
| `GET /`                      | Owner                             | List credentials. Metadata only; never the value or its ciphertext.                                  |
| `POST /:credentialId/rotate` | Owner or platform admin           | Replace the value **in place**: same credential id and connector, new ciphertext.                    |
| `POST /:credentialId/revoke` | Owner or platform admin           | Revoke it.                                                                                           |
| `POST /resolve`              | Gateway (token + active passport) | The just-in-time release described above. Not session-authenticated.                                 |

There is **one active credential per owner and connector**. A second create for the same connector returns HTTP 409. Rotate or revoke of a credential that doesn't exist, or isn't yours, returns 404 rather than 403, so the response never confirms that someone else's credential exists. The audit trail records `credential.create`, `credential.rotate`, `credential.revoke` and `credential.access` events.

**Wiring it into agentsafe-http-gateway**

The feature is off unless `CREDENTIAL_VAULT_URL` is set.

| Variable                         | Meaning                                                                                             |
| -------------------------------- | --------------------------------------------------------------------------------------------------- |
| `CREDENTIAL_VAULT_URL`           | The vault base URL, for example `https://metamynd.ai/api/v1/credential-vault`. Unset = feature off. |
| `CREDENTIAL_VAULT_GATEWAY_TOKEN` | The gateway-only shared secret. Required when the URL is set.                                       |
| `CREDENTIAL_VAULT_CONNECTOR_ID`  | Which stored credential to resolve. Required when the URL is set.                                   |
| `CREDENTIAL_VAULT_HEADER_NAME`   | The upstream header the value is injected into. Default `Authorization`.                            |

The gateway resolves the credential against the request's claimed `authorizationId`, so it only works on routes that go through the gateway's claim flow. There is deliberately no owner-id setting: the tenant always comes from the passport. Setting the URL without the token and connector id is a startup error. If the vault refuses a resolve, the call is **not** forwarded: the caller gets `502 CREDENTIAL_UNAVAILABLE` and a hold the request claimed is released. The gateway never falls back to any other stored value. See [agentsafe-http-gateway](https://docs.metamynd.ai/sdks/agentsafe-http-gateway).

#### What's genuinely encrypted at rest

The platform uses real encryption at rest (`AES-256-GCM`) for:

* DID private keys captured transiently during minting, before the one-time response above is sent;
* principal PII (for example, KYB registration details);
* a handful of admin/operator-facing configuration values (such as a self-hosted deployment's own Hedera operator credentials);
* operational (upstream) credentials stored in the Credential Vault for just-in-time release to a trusted gateway.

None of this is something an agent can reach on its own. Vault release is gateway-authenticated and passport-gated, never agent-initiated.

> **"An agent never holds the real credential for the actions it takes. A separate, gateway-owned process holds it and, with agentsafe-http-gateway, can source it from a governed Credential Vault that releases a credential only to that gateway, just in time, and only against an active Action Passport for the specific action. For an agent's own identity key, MetaMynd never keeps a durable copy: a managed key is shown to its owner once, BYOK and daemon-held keys never reach MetaMynd at all, and a lost key is rotated away, not recovered."**


---

# 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.metamynd.ai/agent-ownership-verifai/credential-vault.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.
