create_trading_token
POST
/admin/trading-tokens
curl --request POST \ --url http://localhost:3001/admin/trading-tokens \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{"label":null,"portfolio_id":"00000000-0000-0000-0000-000000000000","principal_id":"00000000-0000-0000-0000-000000000000"}'import requests
url = "http://localhost:3001/admin/trading-tokens"
payload = { "label": None, "portfolio_id": "00000000-0000-0000-0000-000000000000", "principal_id": "00000000-0000-0000-0000-000000000000"}headers = { "Authorization": "Bearer <token>", "Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "http://localhost:3001/admin/trading-tokens";
let payload = json!({ "label": json!(null), "portfolio_id": "00000000-0000-0000-0000-000000000000", "principal_id": "00000000-0000-0000-0000-000000000000" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
label
Human label for this key (shown in the token list). Optional.
string
portfolio_id
Optionally entitle the principal to trade this portfolio (adds a can_trade
grant). Omit if the principal is already granted, or to grant separately.
string format: uuid
principal_id
required
Mint the token under this existing principal (the trader/strategy/service it belongs to). Create principals on the Principals admin surface first.
string format: uuid
Example generated
{ "label": "example", "portfolio_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "principal_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"}Responses
Section titled “Responses”Created — single bearer token included once
Media typeapplication/json
object
key_id
required
string
label
string
portfolio_id
string format: uuid
principal_id
required
string format: uuid
token
required
The single bearer token — Authorization: Bearer <token>. Shown once.
string
Example generated
{ "key_id": "example", "label": "example", "portfolio_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "principal_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "token": "example"}Auto-provision needs an active broker connection