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 bodyauthobject (必选)Authentication information, always of the environment_variable type.display_name string (可选)Human-readable name of the Credential, max 255 charactersmetadata object (可选)Custom key-value pairs for business metadataauth typeTheauth field currently supports only the environment_variable type, which injects as an environment variable into sessions.type string (必选)Always environment_variablesecret_name string (必选)Environment variable name. Must match ^[a-zA-Z][a-zA-Z0-9_]*$: start with a letter; only letters, digits, and underscores. Immutable after creationsecret_value string (必选)Environment variable value; write-only, never returned in responsesnetworking object (必选)Network policy that restricts real-key substitution to requests sent to the specified hostsnetworking.allowed_hosts array (必选)List of hosts allowed for real-key substitution. Supports *.example.com wildcard subdomains, up to 10 entries. Set * to apply to all hostsinjection_location object (必选)Injection location that marks where the secret is written into the request. The location is the request header; placeholders in the request body and query parameters are not replacedinjection_location.header boolean (可选)Whether to enable request-header replacement. Set to trueWithin one vault, secret_name values must be unique. Creating a duplicate returns 409 CREDENTIAL_SECRET_NAME_DUPLICATE ("A credential with the same secret name already exists in this vault"). | Request example |
Response fieldsidstringCredential ID, format cred_xxxtype stringAlways credentialvault_id stringVault ID that the Credential belongs todisplay_name stringHuman-readable name of the Credentialauth objectAuthentication information with sensitive values masked (e.g. secret_value is not returned)auth.type stringAuth type; currently only environment_variableauth.secret_name stringEnvironment variable nameauth.networking objectNetwork policyauth.networking.allowed_hosts arrayList of hosts allowed for real-key substitutionauth.injection_location objectInjection location. The location is the request header; placeholders in the request body and query parameters are not replacedauth.injection_location.header booleanWhether to enable request-header replacementmetadata objectCustom key-value pairsarchived_at string | nullArchive timestamp; null if not archivedcreated_at stringCreation time, ISO 8601updated_at stringLast update time, ISO 8601request_id stringUnique request identifier | Response example |
Error codes
| HTTP status | Error code | Description |
|---|---|---|
| 400 | InvalidParameter | Required parameter missing or invalid. |
| 401 | InvalidApiKey | Invalid API key provided. |
| 409 | CREDENTIAL_SECRET_NAME_DUPLICATE | secret_name already exists in the vault. |