showPermissionSets: Controls whether the content of the permissionSets field is populated or not. Defaults to true (e.g., true)
symbol: (e.g., BNBUSDT)
fromId: ID to get aggregate trades from INCLUSIVE. (e.g., 1)
startTime: Timestamp in ms to get aggregate trades from INCLUSIVE. (e.g., 1735693200000)
endTime: Timestamp in ms to get aggregate trades until INCLUSIVE. (e.g., 1735693200000)
limit: Default: 500; Maximum: 1000. (e.g., 500)
timeZone: Default: 0 (UTC)
recvWindow: The value cannot be greater than 60000. Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified. (e.g., 5000)
timestamp: (e.g., 1)
quantity: (e.g., 1)
quoteOrderQty: (e.g., 1)
price: (e.g., 400)
newClientOrderId: A unique id among open orders. Automatically generated if not sent. Orders with the same newClientOrderID can be accepted only when the previous one is filled, otherwise the order will be rejected.
strategyId: (e.g., 1)
strategyType: The value cannot be less than 1000000. (e.g., 1)
stopPrice: Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. (e.g., 1)
trailingDelta: See Trailing Stop order FAQ. (e.g., 1)
icebergQty: Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order. (e.g., 1)
Users can provide Binance API credentials in different ways. The agent will try to retrieve automatically with the two first ways the credentials, but users can also explicitly tell the agent that they have set the credentials or stored them in a .env file, and the agent should re-read that file when they do. The agent can also make http requests with the two first methods without user confirmation.
Environment variables
Search for the following specific variables only (never dump the full environment):
Authorized environment variables
Mainnet: BINANCE_API_KEY and BINANCE_SECRET_KEY
Testnet: BINANCE_TESTNET_API_KEY and BINANCE_TESTNET_SECRET_KEY
Demo: BINANCE_DEMO_API_KEY and BINANCE_DEMO_SECRET_KEY
Read and use in a single exec call so the raw key never enters the agent's context:
Environment variables must be set before OpenClaw starts. They are inherited at process startup and cannot be injected into a running instance. If you need to add or update credentials without restarting, use a secrets file (see option 2).
Secrets file (.env)
Check ~/.openclaw/secrets.env , ~/.env, or a .env file in the workspace. Read individual keys with grep, never source the full file:
# Try all credential locations in order
API_KEY=$(grep '^BINANCE_API_KEY=' ~/.openclaw/secrets.env 2>/dev/null | cut -d= -f2-)
SECRET_KEY=$(grep '^BINANCE_SECRET_KEY=' ~/.openclaw/secrets.env 2>/dev/null | cut -d= -f2-)
# Fallback: search .env in known directories (KEY=VALUE then raw line format)fordirin ~/.openclaw ~; do
[ -n "$API_KEY" ] && break
env_file="$dir/.env"
[ -f "$env_file" ] || continue# Read first two lines
line1=$(sed -n '1p'"$env_file")
line2=$(sed -n '2p'"$env_file")
# Check if lines contain '=' indicating KEY=VALUE formatif [[ "$line1" == *=* && "$line2" == *=* ]]; then
API_KEY=$(grep '^BINANCE_API_KEY='"$env_file" 2>/dev/null | cut -d= -f2-)
SECRET_KEY=$(grep '^BINANCE_SECRET_KEY='"$env_file" 2>/dev/null | cut -d= -f2-)
else# Treat lines as raw values
API_KEY="$line1"
SECRET_KEY="$line2"fidone
This file can be updated at any time without restarting OpenClaw, keys are read fresh on each invocation. Users can tell you the variables are now set or stored in a .env file, and you should re-read that file when they do.
Inline file
Sending a file where the content is in the following format:
abc123...xyz
secret123...key
Never run printenv, env, export, or set without a specific variable name
Never run grep on env files without anchoring to a specific key ('^VARNAME=')
Never source a secrets file into the shell environment (source .env or . .env)
Only read credentials explicitly needed for the current task
Never echo or log raw credentials in output or replies
Never commit TOOLS.md to version control if it contains real credentials — add it to .gitignore
Never Disclose API Key and Secret
Never disclose the location of the API key and secret file.
Never send the API key and secret to any website other than Mainnet and Testnet.
Never Display Full Secrets
When showing credentials to users:
API Key: Show first 5 + last 4 characters: su1Qc...8akf
Secret Key: Always mask, show only last 5: ***...aws1
Example response when asked for credentials:
Account: main
API Key: su1Qc...8akf
Secret: ***...aws1
Environment: Mainnet
Listing Accounts
When listing accounts, show names and environment only — never keys:
Binance Accounts:
main (Mainnet/Testnet)
testnet-dev (Testnet)
futures-keys (Mainnet)
Transactions in Mainnet
When performing transactions in mainnet, always confirm with the user before proceeding by asking them to write "CONFIRM" to proceed.
Credentials requested: Mask secrets (show last 5 chars only)
Listing accounts: Show names and environment, never keys
Account selection: Ask if ambiguous, default to main
When doing a transaction in mainnet, confirm with user before by asking to write "CONFIRM" to proceed
New credentials: Prompt for name, environment, signing mode
When a request requires signing, if the request isn't an order and the API keys aren't described as mainnet, testnet or demo keys, try to make request to the different base urls and see if it works, without asking the user. If it works, store the keys with the corresponding environment.
Adding New Accounts
When user provides new credentials by Inline file or message:
Ask for account name
Ask: Mainnet, Testnet or Demo
Store in TOOLS.md with masked display confirmation
Signing Requests
For trading endpoints that require a signature:
Detect key type first, inspect the secret key format before signing.
Build query string with all parameters, including the timestamp (Unix ms).
Percent-encode the parameters using UTF-8 according to RFC 3986.
Sign query string with secretKey using HMAC SHA256, RSA, or Ed25519 (depending on the account configuration).
Append signature to query string.
Include X-MBX-APIKEY header.
Otherwise, do not perform steps 4–6.
New Client Order ID
For endpoints that include the newClientOrderId parameter, the value must always start with agent-. If the parameter is not provided, agent- followed by 18 random alphanumeric characters will be generated automatically. If a value is provided, it will be prefixed with agent-
Example: agent-1a2b3c4d5e6f7g8h9i
User Agent Header
Include User-Agent header with the following string: binance-spot/1.1.0 (Skill)
cancelNewClientOrderId: Used to uniquely identify this cancel. Automatically generated by default.
cancelOrigClientOrderId: Either cancelOrderId or cancelOrigClientOrderId must be sent. If both cancelOrderId and cancelOrigClientOrderId parameters are provided, the cancelOrderId is searched first, then the cancelOrigClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected.
cancelOrderId: Either cancelOrderId or cancelOrigClientOrderId must be sent. If both cancelOrderId and cancelOrigClientOrderId parameters are provided, the cancelOrderId is searched first, then the cancelOrigClientOrderId from that result is checked against that order. If both conditions are not met the request will be rejected. (e.g., 1)
listClientOrderId: A unique Id for the entire orderList
quantity: (e.g., 1)
limitClientOrderId: A unique Id for the limit order
price: (e.g., 1)
limitStrategyId: (e.g., 1)
limitStrategyType: The value cannot be less than 1000000. (e.g., 1)
limitIcebergQty: Used to make the LIMIT_MAKER leg an iceberg order. (e.g., 1)
stopClientOrderId: A unique Id for the stop loss/stop loss limit leg
stopPrice: (e.g., 1)
stopStrategyId: (e.g., 1)
stopStrategyType: The value cannot be less than 1000000. (e.g., 1)
stopLimitPrice: If provided, stopLimitTimeInForce is required. (e.g., 1)
stopIcebergQty: Used with STOP_LOSS_LIMIT leg to make an iceberg order. (e.g., 1)
computeCommissionRates: Default: false See Commissions FAQ to learn more.
orderListId: Either orderListId or listClientOrderId must be provided (e.g., 1)
aboveClientOrderId: Arbitrary unique ID among open orders for the above order. Automatically generated if not sent
aboveIcebergQty: Note that this can only be used if aboveTimeInForce is GTC. (e.g., 1)
abovePrice: Can be used if aboveType is STOP_LOSS_LIMIT , LIMIT_MAKER, or TAKE_PROFIT_LIMIT to specify the limit price. (e.g., 1)
aboveStopPrice: Can be used if aboveType is STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT. Either aboveStopPrice or aboveTrailingDelta or both, must be specified. (e.g., 1)
aboveTrailingDelta: See Trailing Stop order FAQ. (e.g., 1)
aboveStrategyId: Arbitrary numeric value identifying the above order within an order strategy. (e.g., 1)
aboveStrategyType: Arbitrary numeric value identifying the above order strategy. Values smaller than 1000000 are reserved and cannot be used. (e.g., 1)
abovePegOffsetValue: (e.g., 1)
belowClientOrderId: Arbitrary unique ID among open orders for the below order. Automatically generated if not sent
belowIcebergQty: Note that this can only be used if belowTimeInForce is GTC. (e.g., 1)
belowPrice: Can be used if belowType is STOP_LOSS_LIMIT, LIMIT_MAKER, or TAKE_PROFIT_LIMIT to specify the limit price. (e.g., 1)
belowStopPrice: Can be used if belowType is STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT or TAKE_PROFIT_LIMIT Either belowStopPrice or belowTrailingDelta or both, must be specified. (e.g., 1)
belowTrailingDelta: See Trailing Stop order FAQ. (e.g., 1)
belowStrategyId: Arbitrary numeric value identifying the below order within an order strategy. (e.g., 1)
belowStrategyType: Arbitrary numeric value identifying the below order strategy. Values smaller than 1000000 are reserved and cannot be used. (e.g., 1)
belowPegOffsetValue: (e.g., 1)
workingClientOrderId: Arbitrary unique ID among open orders for the working order. Automatically generated if not sent.
workingPrice: (e.g., 1)
workingQuantity: Sets the quantity for the working order. (e.g., 1)
workingIcebergQty: This can only be used if workingTimeInForce is GTC, or if workingType is LIMIT_MAKER. (e.g., 1)
workingStrategyId: Arbitrary numeric value identifying the working order within an order strategy. (e.g., 1)
workingStrategyType: Arbitrary numeric value identifying the working order strategy. Values smaller than 1000000 are reserved and cannot be used. (e.g., 1)
workingPegOffsetValue: (e.g., 1)
pendingClientOrderId: Arbitrary unique ID among open orders for the pending order. Automatically generated if not sent.
pendingPrice: (e.g., 1)
pendingStopPrice: (e.g., 1)
pendingTrailingDelta: (e.g., 1)
pendingIcebergQty: This can only be used if pendingTimeInForce is GTC or if pendingType is LIMIT_MAKER. (e.g., 1)
pendingStrategyId: Arbitrary numeric value identifying the pending order within an order strategy. (e.g., 1)
pendingStrategyType: Arbitrary numeric value identifying the pending order strategy. Values smaller than 1000000 are reserved and cannot be used. (e.g., 1)
pendingPegOffsetValue: (e.g., 1)
pendingAboveClientOrderId: Arbitrary unique ID among open orders for the pending above order. Automatically generated if not sent.
pendingAbovePrice: Can be used if pendingAboveType is STOP_LOSS_LIMIT , LIMIT_MAKER, or TAKE_PROFIT_LIMIT to specify the limit price. (e.g., 1)
pendingAboveStopPrice: Can be used if pendingAboveType is STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT (e.g., 1)
pendingAboveTrailingDelta: See Trailing Stop FAQ (e.g., 1)
pendingAboveIcebergQty: This can only be used if pendingAboveTimeInForce is GTC or if pendingAboveType is LIMIT_MAKER. (e.g., 1)
pendingAboveStrategyId: Arbitrary numeric value identifying the pending above order within an order strategy. (e.g., 1)
pendingAboveStrategyType: Arbitrary numeric value identifying the pending above order strategy. Values smaller than 1000000 are reserved and cannot be used. (e.g., 1)
pendingAbovePegOffsetValue: (e.g., 1)
pendingBelowClientOrderId: Arbitrary unique ID among open orders for the pending below order. Automatically generated if not sent.
pendingBelowPrice: Can be used if pendingBelowType is STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT to specify limit price (e.g., 1)
pendingBelowStopPrice: Can be used if pendingBelowType is STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT or TAKE_PROFIT_LIMIT. Either pendingBelowStopPrice or pendingBelowTrailingDelta or both, must be specified. (e.g., 1)
pendingBelowTrailingDelta: (e.g., 1)
pendingBelowIcebergQty: This can only be used if pendingBelowTimeInForce is GTC, or if pendingBelowType is LIMIT_MAKER. (e.g., 1)
pendingBelowStrategyId: Arbitrary numeric value identifying the pending below order within an order strategy. (e.g., 1)
pendingBelowStrategyType: Arbitrary numeric value identifying the pending below order strategy. Values smaller than 1000000 are reserved and cannot be used. (e.g., 1)
pendingBelowPegOffsetValue: (e.g., 1)
pendingQuantity: Sets the quantity for the pending order. (e.g., 1)
omitZeroBalances: When set to true, emits only the non-zero balances of an account. Default value: false