Skip to main content

Create Credential

Creates a Credential in a specified Vault. The auth field currently supports only the environment_variable type. Sensitive values are write-only and never returned in responses.

Prerequisites

Endpoint and authentication configured. For details, see Overview and authentication.

Endpoint

POST /vaults/{vault_id}/credentials

Request body

FieldRequiredTypeDescription
authYesobjectAuthentication information, always of the environment_variable type. See auth type below
display_nameNostringHuman-readable name of the Credential, max 255 characters
metadataNoobjectCustom key-value pairs for business metadata

auth type

The auth field currently supports only the environment_variable type, which injects as an environment variable into sessions.
FieldRequiredTypeDescription
typeYesstringAlways environment_variable
secret_nameYesstringEnvironment variable name; immutable after creation
secret_valueYesstringEnvironment variable value; write-only, never returned in responses
networkingYesobjectNetwork policy that restricts real-key substitution to requests sent to the specified hosts
networking.allowed_hostsYesarrayList of hosts allowed for real-key substitution. Supports *.example.com wildcard subdomains, up to 10 entries. Set * to apply to all hosts
injection_locationYesobjectInjection location that marks where the secret is written into the request. Currently only the Authorization header is supported; writing into the request body is not yet supported
injection_location.headerNobooleanWhether to write into the Authorization header (Bearer format)

Request example

curl -X POST "$AGENTSTUDIO_URL/vaults/vlt_xxx/credentials" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "Third-party API key",
    "auth": {
      "type": "environment_variable",
      "secret_name": "API_KEY",
      "secret_value": "sk-xxxx",
      "networking": {
        "allowed_hosts": [
          "api.example.com",
          "*.example.com"
        ]
      },
      "injection_location": {
        "header": true
      }
    }
  }'

Response example

{
  "id": "cred_xxx",
  "type": "credential",
  "vault_id": "vlt_xxx",
  "display_name": "Third-party API key",
  "auth": {
    "type": "environment_variable",
    "secret_name": "API_KEY",
    "networking": {
      "allowed_hosts": [
        "api.example.com",
        "*.example.com"
      ]
    },
    "injection_location": {
      "header": true
    }
  },
  "metadata": {},
  "archived_at": null,
  "created_at": "2026-07-10T08:00:00Z",
  "updated_at": "2026-07-10T08:00:00Z",
  "request_id": "req_xxx"
}

Response fields

FieldTypeDescription
idstringCredential ID, format cred_xxx
typestringAlways credential
vault_idstringVault ID that the Credential belongs to
display_namestringHuman-readable name of the Credential
authobjectAuthentication information with sensitive values masked (e.g. secret_value is not returned)
auth.typestringAuth type; currently only environment_variable
auth.secret_namestringEnvironment variable name
auth.networkingobjectNetwork policy
auth.networking.allowed_hostsarrayList of hosts allowed for real-key substitution
auth.injection_locationobjectInjection location. Currently only the Authorization header is supported; writing into the request body is not yet supported
auth.injection_location.headerbooleanWhether to write into the Authorization header
metadataobjectCustom key-value pairs
archived_atstring | nullArchive timestamp; null if not archived
created_atstringCreation time, ISO 8601
updated_atstringLast update time, ISO 8601
request_idstringUnique request identifier

Error codes

HTTP statusError codeDescription
400InvalidParameterRequired parameter missing or invalid
401InvalidApiKeyInvalid API key provided
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration