Create vault

Updated at:

Create a vault that stores credentials. An empty object creates an anonymous vault.

Endpoint

Paths are relative to the Base URL. Send Authorization: Bearer $DASHSCOPE_API_KEY on every request. For authentication details, see Authentication.

POST/vaults

Request body

namestringOptional

Display name. 1–256 bytes after trimming. When omitted, the response returns null, an explicit null returns 400

metadataobject / nullOptional

Metadata, string key-value pairs, up to 16 items; key 1–64 characters, value up to 512 characters. When omitted or null, the response is {}

Creating an empty object {} generates an anonymous vault. The response name is null; no name is generated automatically.

Request example

curl -sS -X POST "$BASE_URL/vaults" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-secrets",
    "metadata": {"team": "support"}
  }'
import os
import requests

resp = requests.post(
    f"{os.environ['BASE_URL']}/vaults",
    headers={"Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}"},
    json={"name": "production-secrets", "metadata": {"team": "support"}},
)
print(resp.status_code, resp.json())

Response fields

201, returns a vault:

idstring

Vault ID

objectstring

Vault object type, fixed as vault

created_atinteger

Creation time in Unix seconds

namestring / null

Display name

metadataobject

Metadata, string key-value pairs; {} when not set

Response example

{
  "id": "vlt_xxx",
  "object": "vault",
  "created_at": 1793941200,
  "name": "production-secrets",
  "metadata": {"team": "support"}
}

Error codes

For the error response structure, see Errors.

HTTP statusError type / codeSolution
400invalid_request_error / unknown_parameterRemove the unknown field
400invalid_request_error / invalid_typeFix the field type as described
400invalid_request_error / invalid_request_errorFix name or metadata as described
401authentication_error / invalid_api_keySend a valid Authorization: Bearer $DASHSCOPE_API_KEY header
409conflict_error / conflict_errorRetry later. If it keeps failing, submit a ticket with x-request-id
500server_error / server_errorRetry later. If it keeps failing, submit a ticket with x-request-id