SDK / API ReferenceVault
Store Credential
Store or update a credential in the vault
Scope: vault:write
Creates or updates a credential. If a credential with the same name exists, it's overwritten.
Request
import { Mailgent } from "@mailgent/sdk";
const mailgent = new Mailgent({ apiKey: process.env.MAILGENT_API_KEY! });
const credential = await mailgent.vault.store("stripe", {
type: "API_KEY",
data: { key: "sk_live_abc123..." },
metadata: { service: "stripe", prefix: "sk_live_...c123" },
});import os
from mailgent import Mailgent
mailgent = Mailgent(api_key=os.environ["MAILGENT_API_KEY"])
credential = mailgent.vault.store(
"stripe",
type="API_KEY",
data={"key": "sk_live_abc123..."},
metadata={"service": "stripe", "prefix": "sk_live_...c123"},
)mailgent vault store stripe \
--type API_KEY \
--data '{"key":"sk_live_abc123..."}' \
--metadata '{"service":"stripe","prefix":"sk_live_...c123"}'vault.store(name="stripe", type="API_KEY", data={...}, metadata={...})Available through @mailgent/mcp — see MCP setup.
curl -X PUT https://api.mailgent.dev/v0/vault/stripe \
-H "Authorization: Bearer loid-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"type": "API_KEY",
"data": { "key": "sk_live_abc123..." },
"metadata": { "service": "stripe", "prefix": "sk_live_...c123" }
}'Body
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | One of: LOGIN, API_KEY, OAUTH, TOTP, SSH_KEY, DATABASE, SMTP, AWS, CERTIFICATE, CUSTOM |
data | object | Yes | Secret fields (encrypted at rest) |
metadata | object | No | Non-secret fields (stored as plaintext for display) |
expiresAt | string | No | Expiry date (ISO 8601) |
Response
{
"credentialId": "cred_abc123",
"type": "API_KEY",
"name": "stripe",
"metadata": { "service": "stripe", "prefix": "sk_live_...c123" },
"expiresAt": null,
"createdAt": "2026-03-29T03:00:00Z"
}Examples
Store a login
curl -X PUT https://api.mailgent.dev/v0/vault/github \
-H "Authorization: Bearer loid-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"type": "LOGIN",
"data": { "password": "s3cret!" },
"metadata": { "uri": "https://github.com", "username": "agent-bot" }
}'Store a TOTP secret
curl -X PUT https://api.mailgent.dev/v0/vault/github-2fa \
-H "Authorization: Bearer loid-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"type": "TOTP",
"data": { "secret": "JBSWY3DPEHPK3PXP" },
"metadata": { "issuer": "GitHub", "account": "agent-bot" }
}'