Reference
API keys
Keys for apps, scripts and agents. Each has one scope; a read or trade key can be limited to some accounts. The full key is shown once, when you create it.
List keys
/api/v1/keysEvery key, newest first. The full key is never shown again; prefix helps you tell them apart.
Headers
X-Request-IdstringYour own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.
Response 200 Keys.
A JSON array of ApiKey objects.
idstring requiredKey id, used to revoke it.
namestring requiredWhat the key is for.
prefixstring requiredThe key's first 12 characters (tl_ and 9 more), to recognise it.
scopesarray of string requiredOne scope.
readtradeadminaccountsarray or null requiredAccount ids the key may use. null = every account.
created_atinteger requiredUnix seconds (UTC).
last_used_atinteger or null requiredUnix seconds (UTC) of the last request, null if never used.
max_volumenumber or null requiredThe most lots one order that opens something may have (0.6.0); null: no limit.
max_open_per_mininteger or null requiredThe most orders that open something this key may send in 60 s (0.6.0); null: no limit.
max_daily_lossnumber or null requiredThe most the account may lose in a forex day (from 17:00 New York, account currency) before this key opens nothing (0.7.0); null: no limit.
max_drawdown_pctnumber or null requiredThe most percent the account's equity may fall below its high since the limit was set before this key opens nothing (0.7.0); null: no limit.
limits_sinceinteger or null requiredWhen the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0).
Errors
- 400
bad_requestA field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes;key=is accepted anywhere). - 401
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl -s "$TERMLESS_URL/api/v1/keys" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.get(f"{base}/keys", headers=auth)
r.raise_for_status()
print(r.json())import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/keys", data=None, headers=headers, method="GET")
with urllib.request.urlopen(req, timeout=35) as r:
print(json.load(r))const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/keys`, {
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());[
{
"id": "key_3f9a1c07",
"name": "EA bridge (gold)",
"prefix": "tl_4be1a09c7",
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
],
"created_at": 1790709498,
"last_used_at": 1790974298,
"max_volume": 0.5,
"max_open_per_min": 10,
"max_daily_loss": 500.0,
"max_drawdown_pct": null,
"limits_since": null
}
]Create a key
/api/v1/keysPick one scope: read (prices and account state), trade (read plus orders) or admin (everything, including accounts, keys, servers and diagnostics). Limit a read or trade key to some accounts with accounts; an admin key cannot be limited (400). Keys look like tl_ and 48 hex characters; only a SHA-256 hash is stored, so the response is the only time the full key appears.
Headers
X-Request-IdstringYour own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.
Request body ApiKeyCreate
namestring requiredWhat the key is for, for example "EA bridge (gold)". Up to 80 characters.
scopesone ofExactly one scope. trade includes read; admin includes everything. Defaults to ["read"].
["read"]["trade"]["admin"]accountsarray of stringLimit the key to these account ids. Omit for every account. Not allowed with admin (400); an unknown id is 400 too.
max_volumenumberThe most lots one order that opens something may have; above it the order answers 403 key_limit and is not sent. Closing is never limited. Omit for no limit (0.6.0).
max_open_per_minintegerThe most orders that open something this key may send in 60 s, 1 to 600; past it 429 key_limit with Retry-After, not sent. Omit for no limit (0.6.0).
max_daily_lossone ofA positive amount in the account's currency; past it (from the forex day's start) orders that open something answer 403 key_limit, not sent (0.7.0). null or left out: no limit.
max_drawdown_pctone ofMore than 0, at most 100: past that many percent below the equity's high since it was set, orders that open something answer 403 key_limit, not sent (0.7.0). Setting or changing it starts its high afresh.
Response 201 Created. Store key now.
A ApiKeyCreated object.
idstring requiredKey id, used to revoke it.
namestring requiredWhat the key is for.
prefixstring requiredThe key's first 12 characters (tl_ and 9 more), to recognise it.
scopesarray of string requiredOne scope.
readtradeadminaccountsarray or null requiredAccount ids the key may use. null = every account.
created_atinteger requiredUnix seconds (UTC).
last_used_atinteger or null requiredUnix seconds (UTC) of the last request, null if never used.
max_volumenumber or null requiredThe most lots one order that opens something may have (0.6.0); null: no limit.
max_open_per_mininteger or null requiredThe most orders that open something this key may send in 60 s (0.6.0); null: no limit.
max_daily_lossnumber or null requiredThe most the account may lose in a forex day (from 17:00 New York, account currency) before this key opens nothing (0.7.0); null: no limit.
max_drawdown_pctnumber or null requiredThe most percent the account's equity may fall below its high since the limit was set before this key opens nothing (0.7.0); null: no limit.
limits_sinceinteger or null requiredWhen the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0).
keystring requiredThe full key, tl_ and 48 hex characters. It is shown only in this response, so store it now.
Errors
- 400
bad_requestA field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes;key=is accepted anywhere). - 401
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 429
too_many_requestsThis IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl -s -X POST "$TERMLESS_URL/api/v1/keys" \
-H "Authorization: Bearer $TERMLESS_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "EA bridge (gold)", "scopes": ["trade"], "accounts": ["pepperstone-12345678"], "max_volume": 0.5, "max_open_per_min": 10}'import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.post(f"{base}/keys", headers=auth, json={
"name": "EA bridge (gold)",
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
],
"max_volume": 0.5,
"max_open_per_min": 10
})
r.raise_for_status()
print(r.json())import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
payload = {
"name": "EA bridge (gold)",
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
],
"max_volume": 0.5,
"max_open_per_min": 10
}
headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/keys", data=json.dumps(payload).encode(), headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=35) as r:
print(json.load(r))const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/keys`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"name": "EA bridge (gold)",
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
],
"max_volume": 0.5,
"max_open_per_min": 10
})
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"id": "key_3f9a1c07",
"name": "EA bridge (gold)",
"prefix": "tl_4be1a09c7",
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
],
"created_at": 1790981179,
"last_used_at": null,
"max_volume": 0.5,
"max_open_per_min": 10,
"max_daily_loss": 500.0,
"max_drawdown_pct": null,
"limits_since": null,
"key": "tl_4be1a09c7d2e5f8b1a3c6e9d0f2b4a7c8e1d3f5a7b9c0e2d"
}Edit a key
/api/v1/keys/{id}Change a key's name, scope or accounts in place (0.6.0). The key itself and its id stay the same, so nothing that holds it has to change. Every request sees the change at once; a stored Idempotency-Key answer is not replayed to a key that may no longer trade on its account (403); a stream it opened on an account it may no longer read ends with reason key changed. Audited (kind key, route update).
Path parameters
idstring requiredKey id.
Headers
X-Request-IdstringYour own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.
Request body ApiKeyUpdate
Any of the fields; the ones left out stay as they are (0.6.0).
namestringA new name, up to 80 characters.
scopesone ofExactly one scope, as on create.
["read"]["trade"]["admin"]accountsone ofThe account ids it may use; null or [] for every account. Not allowed with admin (400); an unknown id is 400 too.
max_volumeone ofThe most lots per order that opens something; null for no limit.
max_open_per_minone ofThe most orders that open something in 60 s, 1 to 600; null for no limit.
max_daily_lossone ofA positive amount in the account's currency; past it (from the forex day's start) orders that open something answer 403 key_limit, not sent (0.7.0). null or left out: no limit.
max_drawdown_pctone ofMore than 0, at most 100: past that many percent below the equity's high since it was set, orders that open something answer 403 key_limit, not sent (0.7.0). Setting or changing it starts its high afresh.
Response 200 The key as listed (the secret is never shown again).
A ApiKey object.
idstring requiredKey id, used to revoke it.
namestring requiredWhat the key is for.
prefixstring requiredThe key's first 12 characters (tl_ and 9 more), to recognise it.
scopesarray of string requiredOne scope.
readtradeadminaccountsarray or null requiredAccount ids the key may use. null = every account.
created_atinteger requiredUnix seconds (UTC).
last_used_atinteger or null requiredUnix seconds (UTC) of the last request, null if never used.
max_volumenumber or null requiredThe most lots one order that opens something may have (0.6.0); null: no limit.
max_open_per_mininteger or null requiredThe most orders that open something this key may send in 60 s (0.6.0); null: no limit.
max_daily_lossnumber or null requiredThe most the account may lose in a forex day (from 17:00 New York, account currency) before this key opens nothing (0.7.0); null: no limit.
max_drawdown_pctnumber or null requiredThe most percent the account's equity may fall below its high since the limit was set before this key opens nothing (0.7.0); null: no limit.
limits_sinceinteger or null requiredWhen the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0).
Errors
- 400
bad_requestA field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes;key=is accepted anywhere). - 401
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl -s -X PATCH "$TERMLESS_URL/api/v1/keys/key_3f9a1c07" \
-H "Authorization: Bearer $TERMLESS_KEY" \
-H "Content-Type: application/json" \
-d '{"scopes": ["trade"], "accounts": ["pepperstone-12345678"]}'import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.patch(f"{base}/keys/key_3f9a1c07", headers=auth, json={
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
]
})
r.raise_for_status()
print(r.json())import json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
payload = {
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
]
}
headers["Content-Type"] = "application/json"
req = urllib.request.Request(f"{base}/keys/key_3f9a1c07", data=json.dumps(payload).encode(), headers=headers, method="PATCH")
with urllib.request.urlopen(req, timeout=35) as r:
print(json.load(r))const base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/keys/key_3f9a1c07`, {
method: "PATCH",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
]
})
});
if (!res.ok) throw new Error((await res.json()).error.message);
console.log(await res.json());{
"id": "key_3f9a1c07",
"name": "EA bridge (gold)",
"prefix": "tl_4be1a09c7",
"scopes": [
"trade"
],
"accounts": [
"pepperstone-12345678"
],
"created_at": 1790709498,
"last_used_at": 1790974298,
"max_volume": 0.5,
"max_open_per_min": 10,
"max_daily_loss": 500.0,
"max_drawdown_pct": null,
"limits_since": null
}Revoke a key
/api/v1/keys/{id}The key stops working at once, its traffic in the connections view is dropped, and the streams it opened end (reason key revoked).
Path parameters
idstring requiredKey id.
Headers
X-Request-IdstringYour own id for the request, kept and echoed in the response header of the same name (and written on every log line and audit row of the request). Anything else is replaced by one the server makes.
Response 204 Revoked.
Errors
- 400
bad_requestA field is missing or not valid, or the query string has a parameter the route does not take (the message names the ones it takes;key=is accepted anywhere). - 401
unauthorizedNo valid API key or session. - 403
forbiddenThe key lacks the scope, or may not use this account, or a cookie request came from another site. - 404
not_foundNo such account, symbol, ticket, key or route. - 429
too_many_requestsThis IP is locked out for 15 minutes (5 wrong passwords or setup tokens lock it out of sign-in, 30 unknown API keys in 15 minutes lock it out of key auth), or a stream cap was hit (1,024 open streams per server, 256 per key or dashboard session), or a password check could not start (one at a time per IP, two at a time per server). Retry-After has the seconds to wait.
curl -s -X DELETE "$TERMLESS_URL/api/v1/keys/key_3f9a1c07" \
-H "Authorization: Bearer $TERMLESS_KEY"import os
import requests
base = os.environ["TERMLESS_URL"] + "/api/v1"
auth = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
r = requests.delete(f"{base}/keys/key_3f9a1c07", headers=auth)
r.raise_for_status() # 204, no bodyimport json
import os
import urllib.error
import urllib.request
base = os.environ["TERMLESS_URL"] + "/api/v1"
headers = {"Authorization": "Bearer " + os.environ["TERMLESS_KEY"]}
req = urllib.request.Request(f"{base}/keys/key_3f9a1c07", data=None, headers=headers, method="DELETE")
with urllib.request.urlopen(req, timeout=35) as r:
print(r.status) # 204, no bodyconst base = `${process.env.TERMLESS_URL}/api/v1`;
const res = await fetch(`${base}/keys/key_3f9a1c07`, {
method: "DELETE",
headers: { Authorization: `Bearer ${process.env.TERMLESS_KEY}` }
});
if (!res.ok) throw new Error((await res.json()).error.message);
// 204: no bodyHTTP/1.1 204 No Content