Account Operations
Execute advanced account operations including contract calls, upgrades, and asset withdrawals.
1. Owner Contract Call
Endpoint: POST /v1/accounts/call
Description: Execute a contract call as the account owner.
Headers
Request Body
curl -X POST \
"https://api.o2.app/v1/accounts/call" \
-H "Accept: application/json" \
-H "O2-Owner-Id: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"contract_id": "0xabc123",
"signature": "0xdef456",
"nonce": "1",
"call": "{}"
}'Source: packages/api/src/app/routes/v1/accounts.rs:owner_call_contract_handler
2. Owner Multiple Contract Calls
Endpoint: POST /v1/accounts/calls
Description: Execute multiple contract calls in batch as account owner.
Headers
Request Body
curl -X POST \
"https://api.o2.app/v1/accounts/calls" \
-H "Accept: application/json" \
-H "O2-Owner-Id: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"contract_id": "0xabc123",
"signature": "0xdef456",
"nonce": "1",
"calls": "[]"
}'Source: packages/api/src/app/routes/v1/accounts.rs:owner_call_contracts_handler
3. Upgrade Account
Endpoint: POST /v1/accounts/upgrade
Description: Upgrade trading account contract to newer version.
Headers
Request Body
curl -X POST \
"https://api.o2.app/v1/accounts/upgrade" \
-H "Accept: application/json" \
-H "O2-Owner-Id: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"contract_id": "0xabc123",
"signature": "0xdef456",
"nonce": "1",
"implementation": "0x789..."
}'Source: packages/api/src/app/routes/v1/accounts.rs:upgrade_account_handler
4. Withdraw Assets
Endpoint: POST /v1/accounts/withdraw
Description: Withdraw assets from trading account.
Headers
Request Body
curl -X POST \
"https://api.o2.app/v1/accounts/withdraw" \
-H "Accept: application/json" \
-H "O2-Owner-Id: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \
-H "Content-Type: application/json" \
-d '{
"contract_id": "0xabc123",
"signature": "0xdef456",
"nonce": "1",
"asset_id": "0x789...",
"amount": "1000000"
}'Source: packages/api/src/app/routes/v1/accounts.rs:withdraw_handler