MailgentMailgent
Vault

No more
.env files.

Encrypted credential storage for AI agents. Store API keys, OAuth tokens, and login credentials with scoped access, automatic rotation, and audit trails. Drag-and-drop .env import from the console.

AES-256-GCM

Encryption

Per-identity

Scoped access

Auto

OAuth refresh

Store credentials

store-credentials.ts
const API = "https://api.mailgent.dev/v0"
const headers = {
  "Authorization": "Bearer mgent-a3f91b00...",
  "Content-Type": "application/json",
}

// PUT /v0/vault/:name — Store an API key (AES-256-GCM encrypted)
await fetch(`${API}/vault/stripe-production`, {
  method: "PUT",
  headers,
  body: JSON.stringify({
    type: "API_KEY",
    data: {
      apiKey: "sk_live_4eC39HqLyjWDqB...",
    },
    metadata: { service: "stripe", environment: "production" },
    expiresAt: "2026-12-31T00:00:00Z",
  }),
})

// PUT /v0/vault/:name — Store OAuth tokens
await fetch(`${API}/vault/hubspot-crm`, {
  method: "PUT",
  headers,
  body: JSON.stringify({
    type: "OAUTH",
    data: {
      access_token: "CLH7sqK...",
      refresh_token: "CJH7sqK...",
    },
    metadata: { service: "hubspot" },
  }),
})

Retrieve & rotate

use-credentials.ts
// GET /v0/vault/:name — Retrieve decrypted credential
const cred = await fetch(`${API}/vault/stripe-production`, { headers })
  .then(r => r.json())

// cred.data.apiKey → "sk_live_4eC39HqLyjWDqB..."
const charge = await stripe.charges.create(
  { amount: 2000, currency: "usd" },
  { apiKey: cred.data.apiKey }
)

// PUT /v0/vault/:name — Rotate by overwriting (upsert)
await fetch(`${API}/vault/stripe-production`, {
  method: "PUT",
  headers,
  body: JSON.stringify({
    type: "API_KEY",
    data: { apiKey: newApiKey },
    metadata: { service: "stripe", rotatedAt: new Date().toISOString() },
  }),
})

What's included.

Envelope encryption

AES-256-GCM with per-credential data encryption keys, each wrapped by org-level KMS keys. Even if the database is fully compromised, encrypted values are useless without the KMS key hierarchy. Defense in depth, not security theater.

Scoped access per identity

Every credential is bound to a specific agent identity. Sub-agents can receive attenuated access with narrower scopes. Every read, write, and delete is logged in the audit trail with timestamps, identity, and IP address.

OAuth auto-refresh

Store OAuth access and refresh tokens together. Mailgent automatically refreshes access tokens before they expire, so your agent never encounters a 401 or deals with token lifecycle. Just retrieve and use — the token is always valid.

Zero-downtime rotation

Rotate API keys and credentials without redeploying agents. Overwrite a credential and the next API read returns the new value instantly. No config files to update, no deployments to trigger, no downtime.

Drag-and-drop .env import

Migrating from .env files? Drag and drop your .env into the console. Mailgent auto-detects secret types (API keys, database URLs, OAuth tokens), categorizes them, and stores each one encrypted — in one click. Delete the .env file forever.

Delegation chain & revocation

Every credential access is traceable through the delegation chain: Human > Org > Identity > Credential. Revoke an identity and every credential it owns becomes instantly inaccessible. No orphaned secrets, no cleanup scripts.

Typed credentials

Store credentials with semantic types — API_KEY, OAUTH, LOGIN, CUSTOM. Each type has structured fields so your agent knows exactly what it's working with. No more parsing opaque strings or guessing which env var is which.

Native MCP integration

Access vault credentials directly from Claude Desktop, Cursor, or any MCP client. The vault.store, vault.get, vault.list, and vault.delete tools let MCP-connected AI clients manage credentials without writing API calls.

Use cases.

How teams use Vault to give agents secure access to the services they need.

Third-party API access

Agent stores and retrieves API keys for Stripe, Twilio, HubSpot, or any third-party service. Keys are encrypted at rest and scoped per identity — no shared .env files, no risk of one agent leaking another's credentials.

Autonomous service login

Agent stores usernames, passwords, and TOTP seeds for services it needs to log into. Combined with TOTP code generation, agents complete full login flows including 2FA — without a human pasting credentials into a chat.

Database connection strings

Store database URLs, connection strings, and certificates securely. Agents retrieve them at runtime and connect directly — no hardcoded credentials in code, no secrets in environment variables, no config files in version control.

Payment processing

Agent retrieves Stripe or payment processor API keys from Vault to create charges, generate invoices, or send payment links. Keys are rotated without redeploying. Every access is audit-logged for PCI compliance support.

OAuth workflow automation

Agent stores OAuth tokens for Google Workspace, Microsoft 365, HubSpot CRM, and other OAuth-protected services. Tokens auto-refresh so the agent maintains persistent access to calendars, documents, and CRM data.

Multi-agent credential sharing

Parent agents delegate attenuated credential access to sub-agents. A lead-gen agent can share read-only CRM access with an email agent without exposing the full OAuth token. Revoke the parent and all downstream access stops.

Security architecture

Secrets management built for the agent era.

Traditional secrets managers were built for servers and CI pipelines. Vault is built for autonomous agents that need to retrieve credentials, rotate them, and share attenuated access with sub-agents — all with a delegation chain that traces every action back to a human. No .env files. No hardcoded secrets. No shared credentials between agents that shouldn't share them.

Stop hardcoding secrets.

Migrate from .env files in one click. Store, rotate, and audit every credential your agents use.