Back to Eliza

Secrets API

packages/docs/rest/secrets.md

2.0.13.8 KB
Original Source

The secrets API manages API keys and credentials for AI providers, blockchain RPCs, and third-party services. Secrets are stored in the Eliza config file and synced to process.env at runtime. Values are returned in redacted form — the UI can display which keys are set without exposing their contents.

Endpoints

MethodPathDescription
GET/api/secretsList all configured secrets (redacted)
PUT/api/secretsUpdate one or more secrets

GET /api/secrets

Returns all known secret keys with redacted values and metadata about which plugins they belong to. Enabled status is synced from the runtime plugin state.

Response

json
{
  "secrets": [
    {
      "key": "OPENAI_API_KEY",
      "description": "OpenAI API key",
      "category": "ai-provider",
      "sensitive": true,
      "required": true,
      "isSet": true,
      "maskedValue": "sk-****...xxxx",
      "usedBy": [
        { "pluginId": "openai", "pluginName": "OpenAI", "enabled": true }
      ]
    },
    {
      "key": "ANTHROPIC_API_KEY",
      "description": "Anthropic API key",
      "category": "ai-provider",
      "sensitive": true,
      "required": true,
      "isSet": false,
      "maskedValue": null,
      "usedBy": [
        { "pluginId": "anthropic", "pluginName": "Anthropic", "enabled": false }
      ]
    }
  ]
}
FieldTypeDescription
secretsarrayList of secret entries aggregated from all plugin parameters
secrets[].keystringEnvironment variable name
secrets[].descriptionstringHuman-readable description of the secret
secrets[].categorystringPlugin category (e.g. ai-provider, connector)
secrets[].sensitivebooleanWhether this is a sensitive parameter
secrets[].requiredbooleanWhether this parameter is required by its plugin
secrets[].isSetbooleanWhether the key has a non-empty value in the environment
secrets[].maskedValuestring|nullRedacted value (e.g. sk-****...xxxx) or null if unset
secrets[].usedByarrayList of plugins that declare this parameter
secrets[].usedBy[].pluginIdstringPlugin identifier
secrets[].usedBy[].pluginNamestringPlugin display name
secrets[].usedBy[].enabledbooleanWhether the plugin is currently loaded in the runtime

PUT /api/secrets

Update one or more secrets. Values are written to the config file and injected into process.env immediately. Keys with empty or whitespace-only values are silently skipped. Keys that are not declared as sensitive parameters by any plugin, or that match a blocked system variable name, are also skipped.

Request Body

json
{
  "secrets": {
    "OPENAI_API_KEY": "sk-new-key-here",
    "ANTHROPIC_API_KEY": "sk-ant-new-key"
  }
}
FieldTypeRequiredDescription
secretsobjectYesMap of environment variable names to new values

Response

json
{
  "ok": true,
  "updated": ["OPENAI_API_KEY", "ANTHROPIC_API_KEY"]
}
FieldTypeDescription
okbooleanWhether the operation succeeded
updatedstring[]List of key names that were actually written

Setting or clearing a provider key may require a restart for the runtime to pick up the change. The UI typically prompts the user accordingly.

Common Error Codes

StatusCodeDescription
400INVALID_REQUESTRequest body is malformed or missing required fields
401UNAUTHORIZEDMissing or invalid authentication token
404NOT_FOUNDRequested resource does not exist
400INVALID_BODYRequest body is not a valid JSON object with a secrets map
500INTERNAL_ERRORUnexpected server error