TermlessDocs

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

GET/api/v1/keys

Every key, newest first. The full key is never shown again; prefix helps you tell them apart.

Scope admin

Headers

  • X-Request-Id string

    Your 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.

  • id string required

    Key id, used to revoke it.

  • name string required

    What the key is for.

  • prefix string required

    The key's first 12 characters (tl_ and 9 more), to recognise it.

  • scopes array of string required

    One scope.

    readtradeadmin
  • accounts array or null required

    Account ids the key may use. null = every account.

  • created_at integer required

    Unix seconds (UTC).

  • last_used_at integer or null required

    Unix seconds (UTC) of the last request, null if never used.

  • max_volume number or null required

    The most lots one order that opens something may have (0.6.0); null: no limit.

  • max_open_per_min integer or null required

    The most orders that open something this key may send in 60 s (0.6.0); null: no limit.

  • max_daily_loss number or null required

    The 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_pct number or null required

    The 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_since integer or null required

    When the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0).

Errors

  • 400 bad_request A 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 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 429 too_many_requests This 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
curl -s "$TERMLESS_URL/api/v1/keys" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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())
Python, stdlib
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))
JavaScript
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());
Response 200
[
  {
    "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

POST/api/v1/keys

Pick 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.

Scope admin

Headers

  • X-Request-Id string

    Your 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

  • name string required

    What the key is for, for example "EA bridge (gold)". Up to 80 characters.

  • scopes one of

    Exactly one scope. trade includes read; admin includes everything. Defaults to ["read"].

    ["read"]["trade"]["admin"]
  • accounts array of string

    Limit the key to these account ids. Omit for every account. Not allowed with admin (400); an unknown id is 400 too.

  • max_volume number

    The 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_min integer

    The 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_loss one of

    A 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_pct one of

    More 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.

  • id string required

    Key id, used to revoke it.

  • name string required

    What the key is for.

  • prefix string required

    The key's first 12 characters (tl_ and 9 more), to recognise it.

  • scopes array of string required

    One scope.

    readtradeadmin
  • accounts array or null required

    Account ids the key may use. null = every account.

  • created_at integer required

    Unix seconds (UTC).

  • last_used_at integer or null required

    Unix seconds (UTC) of the last request, null if never used.

  • max_volume number or null required

    The most lots one order that opens something may have (0.6.0); null: no limit.

  • max_open_per_min integer or null required

    The most orders that open something this key may send in 60 s (0.6.0); null: no limit.

  • max_daily_loss number or null required

    The 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_pct number or null required

    The 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_since integer or null required

    When the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0).

  • key string required

    The full key, tl_ and 48 hex characters. It is shown only in this response, so store it now.

Errors

  • 400 bad_request A 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 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 429 too_many_requests This 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
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}'
Python
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())
Python, stdlib
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))
JavaScript
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());
Response 201
{
  "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

PATCH/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).

Scope admin

Path parameters

  • id string required

    Key id.

Headers

  • X-Request-Id string

    Your 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).

  • name string

    A new name, up to 80 characters.

  • scopes one of

    Exactly one scope, as on create.

    ["read"]["trade"]["admin"]
  • accounts one of

    The account ids it may use; null or [] for every account. Not allowed with admin (400); an unknown id is 400 too.

  • max_volume one of

    The most lots per order that opens something; null for no limit.

  • max_open_per_min one of

    The most orders that open something in 60 s, 1 to 600; null for no limit.

  • max_daily_loss one of

    A 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_pct one of

    More 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.

  • id string required

    Key id, used to revoke it.

  • name string required

    What the key is for.

  • prefix string required

    The key's first 12 characters (tl_ and 9 more), to recognise it.

  • scopes array of string required

    One scope.

    readtradeadmin
  • accounts array or null required

    Account ids the key may use. null = every account.

  • created_at integer required

    Unix seconds (UTC).

  • last_used_at integer or null required

    Unix seconds (UTC) of the last request, null if never used.

  • max_volume number or null required

    The most lots one order that opens something may have (0.6.0); null: no limit.

  • max_open_per_min integer or null required

    The most orders that open something this key may send in 60 s (0.6.0); null: no limit.

  • max_daily_loss number or null required

    The 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_pct number or null required

    The 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_since integer or null required

    When the drawdown limit was set, unix milliseconds; its high counts from then (0.7.0).

Errors

  • 400 bad_request A 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 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This 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
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"]}'
Python
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())
Python, stdlib
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))
JavaScript
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());
Response 200
{
  "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

DELETE/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).

Scope admin

Path parameters

  • id string required

    Key id.

Headers

  • X-Request-Id string

    Your 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_request A 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 unauthorized No valid API key or session.
  • 403 forbidden The key lacks the scope, or may not use this account, or a cookie request came from another site.
  • 404 not_found No such account, symbol, ticket, key or route.
  • 429 too_many_requests This 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
curl -s -X DELETE "$TERMLESS_URL/api/v1/keys/key_3f9a1c07" \
  -H "Authorization: Bearer $TERMLESS_KEY"
Python
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 body
Python, stdlib
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/key_3f9a1c07", data=None, headers=headers, method="DELETE")
with urllib.request.urlopen(req, timeout=35) as r:
    print(r.status)  # 204, no body
JavaScript
const 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 body
Response
HTTP/1.1 204 No Content