Lock, unlock or close everything on many demo accounts
/accounts/actions- Base URL
https://api.chartnaut.com/partner/v1- Auth
- Bearer key
- Operation ID
accountActions
Your demo accounts only, for users who still grant demo_accounts:write. Named by ids
(up to 1,000, each acc_…) or by labels, never both. labels needs expected_count.
When expected_count is given (with ids or labels) and the number of accounts found
differs, it is 409 expected_count_mismatch with details.expected and details.actual,
and nothing is done. Labels matching more than 1,000 accounts are 400 invalid_request.
Each account answers on its own in data: {id, result, error?}. result is:
result |
Meaning |
|---|---|
locked / unlocked |
this call locked or unlocked it |
closed |
close_all: locked, and nothing is left open |
closing |
close_all: locked, positions still closing (a closed market, or past the call's 20 seconds); error may say why. Read the account for the result |
already |
it was already in that state, or it has ended (lock, unlock) |
not_found |
not one of yours, or its user no longer grants demo_accounts:write |
error |
it failed; error says why. Retry |
Ids not found come first, then the rest in account id order. Acting by labels, accounts whose user no longer grants the scope are left out rather than listed.
lock: frozen. The user can place, change, cancel or close nothing, and nothing fills: a resting entry, stop or target that is crossed stays armed and fills only after an unlock, if the price is still there. A margin stop-out still runs. The user sees "Locked by <partner>".unlock: trading resumes.close_all: locks, then cancels positions whose entry hasn't filled and closes the rest at market. It closes inline for up to 20 seconds; the rest are queued (closing). It works on locked accounts and is safe to repeat.
close_all counts toward 2,000 items an hour per partner, shared with session end. Past
that nothing is done and the whole call waits for Chartnaut's approval: 202 with
{"pending_action_id": n} only. 403 switched_off while bulk actions are paused.
Headers#
Idempotency-KeystringRequiredRequired on every POST (400 invalid_request without it): any unique string of 1–255
visible ASCII characters (a UUID is ideal). Keys are per environment. A retry with the same
key, path and body within 24 hours returns the first response with Idempotent-Replayed: true and runs nothing. The same key with a different path or body is 422 idempotency_key_reused; while the first request is still running, 409 conflict. 5xx
and 429 answers are not stored, so a retry with the same key runs again.
Request bodyapplication/json#
Includes BulkTarget
idsarray of stringlabelsmap of stringThe labels every target must hold (exact values, ANDed).
expected_countintegerRequired with labels: how many you expect to match. Refused (409 expected_count_mismatch, nothing done) if different.
actionstringRequiredResponses#
200OKapplication/json
Done; one result per account.
Headers
Idempotent-Replayedstringtrue when this is the stored response of an earlier request with the same Idempotency-Key.
Body
dataarray of objectRequiredShow item fields
idstringRequiredresultstringRequirederrorstringWhy, for error; for closing, why a position is still open when known.
202Acceptedapplication/json
close_all over the hourly ceiling: nothing done, waiting for approval.
Headers
Idempotent-Replayedstringtrue when this is the stored response of an earlier request with the same Idempotency-Key.
Body
pending_action_idintegerRequiredErrorAny other statusapplication/json
Error. Every response to a request whose key checked out, errors included, carries
RateLimit-Limit (requests a minute), RateLimit-Remaining and RateLimit-Reset (seconds
until the minute resets). A 401, the 403 switched_off when the whole API is off for
you, and the 429 for too many bad keys from one IP come before that check and carry
none. A 429 also carries Retry-After (seconds).
Headers
RateLimit-LimitintegerRateLimit-RemainingintegerRateLimit-ResetintegerRetry-AfterintegerBody
Show fields
codestringRequiredStable. Branch on this, never on message.
| Code | Status | Meaning |
|---|---|---|
unauthorized |
401 | missing, unknown or revoked key (no RateLimit headers) |
scope_not_granted |
403 | the user didn't grant details.scope |
forbidden |
403 | your partner account isn't allowed this (details.reason, e.g. no_access for frame:live when live mode isn't enabled for you; details.scope) |
permission_denied |
403 | this key lacks the key permission the call needs (details.permission, e.g. users:export; details.reason: "key_permission"): use a key that has it, or add it in the partner portal |
not_managed |
409 | the call is for managed users only, and this user is linked (their own Chartnaut account and plan apply; details.reason: "not_managed") |
switched_off |
403 | this part of the API is paused for you (everything, writes, frames, links, demo account creation, bulk actions); contact [email protected] |
not_linked |
404 | the user isn't linked to you (details.user when the user was named in the request) |
not_found |
404 | no such object for you; an id of the wrong type or shape is this too |
conflict |
409 | external_ref already used (sessions: details.existing_id; accounts: details.field); the same Idempotency-Key still running; lock or unlock on an ended session |
expected_count_mismatch |
409 | a bulk action matched a different number (details.expected, details.actual) |
invalid_request |
400 | malformed body or unknown field (named in message, no details), a bad field (details.field where the endpoint names it), bad id, missing Idempotency-Key, invalid rules. Also 413 for a body over 2 MiB |
idempotency_key_reused |
422 | the Idempotency-Key was used with a different path or body |
plan_limit |
422 / 403 | the user's Chartnaut plan doesn't allow it (details.reason), or your developer plan's cap (details.owner: "developer", details.limit: apps (an app past your plan's count after a downgrade takes no new users), free_linked, managed_users, data; with used, cap). No auto top-up: upgrade on the Developers page |
seat_limit |
403 | your Business seats are full this month (details.limit seats or pro_seats, used, cap): a new managed user can't start until you add seats; users active this month carry on |
partner_limit |
422 | one of your partner limits (details.limit, and for demo accounts details.max) |
rate_limited |
429 | your rate limit: details.limit is rate_minute or rate_burst. Also, with no details and Retry-After: 60, any call from an IP that sent 30 bad keys this minute, good keys included. See Retry-After |
internal |
500 | retry; if it persists contact [email protected] |
messagestringRequireddetailsobject