Skip to main content

Authentication

API Key acquisition and usage

Memory API uses API Key authentication. Pass the key via the Authorization header.

Get credentials

  1. Open the console: Open the Bailian console and log in with your Alibaba Cloud account.
  2. Get API Key: Obtain DASHSCOPE_API_KEY from the console, starting with sk-. See Get API Key.
    API keys have account-level permissions. Store them securely and never commit to code repositories.

Usage

Configure as an environment variable:
export DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxx"
Each request carries the Authorization header:
curl --location 'https://dashscope.aliyuncs.com/api/v2/apps/memory/add' \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "user_id": "user_001",
    "custom_content": "The user prefers concise technical examples."
  }'

Permissions

  • Alibaba Cloud primary account: can call all endpoints directly
  • RAM sub-accounts: require appropriate permissions
  • API Key scope is configured in the console

Security best practices

  • Never in repos: use environment variables
  • Per-app keys: use separate keys for each app
  • Rotate regularly: change keys periodically
View AddMemory to start calling.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration