Skip to main content
Full reference for every miramarket-cli command. For installation and a first walkthrough, see CLI. For the strategy JSON format and correctness rules, see /agent-strategy-guide.md. Every command supports --json for machine-readable output. In --json mode, stdout carries exactly one JSON object and nothing else — no banners, color, or spinner frames — except login --events and strategies watch --events, which print one JSON object per line (NDJSON), noted below. Piping to a non-TTY also disables color and spinners automatically.

Envelope and exit codes

Every command that supports --json emits the same envelope shape on both success and failure:
On failure, ok is false and the envelope also carries a human-readable error and a machine-readable code:
Prefer branching on code over parsing error text — error wording can change, code is the stable contract. code values include NOT_AUTHENTICATED, LOGIN_REFRESH_FAILED, LOGIN_DENIED, LOGIN_CODE_EXPIRED, LOGIN_OUTDATED, LOGIN_NOT_ALLOWED, FORBIDDEN, VALIDATION_ERROR, INPUT_ERROR, SERVER_ERROR, PARSE_ERROR, STRATEGY_NOT_FOUND, REGION_RESTRICTED, WALLET_NOT_DELEGATED, WATCH_TIMEOUT, INVALID_STRATEGY_STATE, NO_ACTIVE_RUN, LOCKED_NODE_EDIT, UNSUPPORTED_FIELD, RUN_EDIT_REJECTED, IDEMPOTENCY_KEY_REUSED, APPROVAL_NOT_FOUND, and more — this set grows over time, so don’t treat it as closed.

Sign-in commands

miramarket-cli login [--force] [--events] [--json]

Signs in with the OAuth device authorization grant: prints a short code and a link, you approve it in any browser (doesn’t need to be the same device — useful over SSH or on a headless machine), and the CLI finishes automatically once approved. The link opens https://app.miramarket.org/oauth/device?code=BCDF-GHJK; the code expires after 10 minutes. On that page the account owner signs in, checks the code, and chooses what this login may do: The budget (default $100) is one dollar amount for both live runs and single orders. The login stays active while it is used and ends after 30 days without use. It appears on Connected agents (https://app.miramarket.org/settings/agents) as Miramarket CLI followed by the computer’s name, where the owner can change its budget or revoke it. With --events, the first line looks like this; show the human verificationUrl and userCode:
Without --force, a valid cached login short-circuits the command with a notice. The envelope reports scopes (what was allowed) and manageAt (the Connected agents page). A denied login exits 3 with LOGIN_DENIED; a code that expired before approval exits 3 with LOGIN_CODE_EXPIRED. A login from a CLI older than 1.6.0 no longer works: commands report LOGIN_OUTDATED (exit 3) and login starts a new one. Signing in does not by itself make the account trade-ready — see account setup under Account commands below.

miramarket-cli logout

Ends this login: revokes it on the server, so it stops working at once and shows as revoked on Connected agents, and removes the cached login from this machine. The envelope’s revoked says whether the server could be reached; the local login is removed either way.

miramarket-cli auth status [--json]

Reports whether a valid login is cached, what it may do, and its live-run budget. Always exits 0 — this is a diagnostic, read the payload:
postingAllowed is whether the login may create strategies. openLiveUsd is the principal of this login’s live runs still in the market. The budget fields are null when they can’t be read, for example offline. A login from an older CLI reports authenticated: false with a requiredAction to sign in again. A command the login wasn’t allowed exits 3 with a message naming the switch (code is LOGIN_NOT_ALLOWED or FORBIDDEN); approve a new login with it on (login --force).

Updating the CLI

miramarket-cli update [--check] [--json]

Updates the CLI to the latest release on npm, with the package manager it was installed with and in the same place. No login needed. Each install is pinned to where the running copy lives, so a different npm on PATH (nvm, Homebrew) can’t update another copy. Afterward it reads the installed version back and fails if a different version, or none, landed there. --check only reports whether a newer release exists and installs nothing. With --json, the installer’s own output is captured, so stdout carries exactly one envelope:
With --check, updated is false, updateAvailable says whether a newer release exists, and nextCommand says what to run. Exit codes: 0 updated, already up to date, or --check. 1 the installer failed (UPDATE_FAILED), had no permission to write to the install directory (UPDATE_PERMISSION_DENIED; re-run with those rights, for example sudo miramarket-cli update), or left a different version or none where this copy was (UPDATE_NOT_APPLIED). 4 the npm registry is unreachable (REGISTRY_UNREACHABLE). 5 this copy can’t be updated in place (UPDATE_UNSUPPORTED_INSTALL). The update command exists from 1.6.0; update an older CLI once with npm install -g @miramarket/cli.

Account commands

A login is not the same as a trade-ready account — Polymarket orders and live strategy runs also require accepting the platform’s Terms/Privacy/Risk Disclosure and having a delegated deposit wallet with the necessary on-chain approvals.

miramarket-cli account status [--json]

Diagnoses trade-readiness across auth, API reachability, region availability, policy acceptance, wallet delegation, and capital. Always exits 0 — ok:true means “the check ran,” not “everything passed.” Read ready and blockers[]:
If humanRequired is true on a blocker (not authenticated, wallet not delegated, policies not accepted, region-restricted), surface requiredAction and stop — an agent should never attempt to work around these. Blocker codes: NOT_AUTHENTICATED, API_UNREACHABLE, REGION_RESTRICTED, POLICIES_NOT_ACCEPTED, WALLET_NOT_DELEGATED, WALLET_CHECK_FAILED. The region check is sent with your login when there is one. An account that is exempt from the region rules reads as available: checks.geo.exempt is true and there is no REGION_RESTRICTED blocker. Logged out, the check reports the region’s own rules.

miramarket-cli account setup [--json]

Idempotent — attaches the wallet-level policy and bootstraps the deposit wallet’s on-chain approvals; safe to re-run any time. Cannot complete onboarding by itself: wallet delegation only happens in the web app in a browser, and this command never accepts policies on your behalf. It reports exactly what’s still needed and points at account accept-policies or a browser sign-in. Needs a login allowed to trade (Trade with real money or Place orders and bridge).

miramarket-cli account policies [--json]

Read-only. Shows the current Terms/Privacy/Risk Disclosure versions, your acceptance status, and canonical URLs.

miramarket-cli account accept-policies

Records legal acceptance of the current Terms, Privacy Policy, and Risk Disclosure. This is a human-only action — it requires typing I accept in an interactive terminal (or, for a human scripting their own machine, pinning the exact current document versions with --i-have-read-and-accept --terms-version=... --privacy-version=... --risk-version=...). An AI agent should never call this on a user’s behalf. When any of the three documents changes, the earlier acceptance no longer counts: account status reports POLICIES_NOT_ACCEPTED until you accept the new versions.

miramarket-cli account capital [--json]

Shows capital currently locked by active strategy runs and pending withdrawal holds — the gap between gross wallet balance and what’s actually spendable.

miramarket-cli account withdraw --recipient <address> [--amount <usd>] --confirm [--json]

Needs the Withdraw funds switch, which is off by default: approve a login with it on (login --force). Without it, exits 3 with a message naming the switch. Withdraws spendable USDC to an external address. Spendable cash is your USDC on Polygon and Base plus your free perps balance on Hyperliquid; the withdrawal moves the Hyperliquid part out when it needs it, and a small transfer fee comes out of the amount. Margin backing open perp positions does not count until they are closed. Omit --amount to withdraw all spendable cash. Requesting more than spendable cash is rejected before anything is moved.
Exit codes: 0 ok, 3 auth error, 4 server error (a failed transfer releases its hold automatically), 5 bad input.

Strategy authoring commands

See /agent-strategy-guide.md for the JSON format itself and the rules for building a strategy that behaves correctly, not just one that passes validate.

miramarket-cli schema [--format=ts|json|markdown]

Prints the strategy schema — ts for TypeScript types, json for a JSON Schema document, markdown for a prose authoring guide with worked examples.

miramarket-cli strategies generate [prompt] [flags]

Text-to-strategy. Describe what the strategy should do in plain English and get authoring JSON back, built by the same assistant that powers the visual builder. Requires authentication. Nothing is validated or posted on your behalf: run validate, preview, and post on the result exactly as you would for a hand-written file. result is one of four values. ok is true for all of them, because each is a real outcome rather than a failure:
  • strategy — built. strategyPath or strategy, plus markets[] (what it trades, with the price the generator saw), stats, notices[], unmatched[], changeSummary[] (edits only), thesis, and nextCommands[]. A non-empty unmatched means something the prompt named was substituted or left out; read it before posting. A tokenized stock comes back as a BASE_STOCKS leg and a perp as a HYPERLIQUID leg, both with PRICE_USD conditions in dollars, ready to post. An exit asked for as a profit or loss in percent (“take profit at +20%, stop at -10%”, “once I’m up 15%”) comes back as an ROI_PCT condition under its buy; a percent move in the price (“if BTC drops 5%”) comes back as a price level. A take-profit no price can reach is left out, and a notice says so. By default a trade named on one venue also gets one related position on another venue for 30% of the budget, named in notices (as in the example below); a prompt with “just”, “only”, or “nothing else” keeps one venue, and a notice says when the strategy stays on one venue and why. thesis is set when the prompt asked what to trade about a situation, event, or asset instead of choosing the position (“build a strategy around this week’s Fed meeting”). The command researched the news and the markets it moves first, and thesis says what the strategy bets on (bet), whether it bets with or against the situation (stance: WITH_SITUATION, CONTRARIAN, or MIXED), why each market is in it (legs[]), what the strategy does (rules[]), what would break it (breaks_if), the headlines it rests on (news[]), and a two-sentence summary. Without --json the summary prints as a short note. A researched strategy buys when it starts, and a market it watches is usually an exit; it waits for a condition before buying only when the prompt asks it to wait. thesis is null for every other prompt.
  • market_selection — the request was ambiguous between several markets. candidates[] is numbered (choice) and the question is saved locally under selectionId. When resumable is true, answer with strategies generate --choose <marketId|choice> --selection <selectionId> on the next call; at an interactive terminal the choice is prompted for in place instead. When resumable is false the question cannot be answered with a choice (the request was an edit, or it named several markets) and reason says so; re-run with a prompt that names the market precisely. Any new prompt discards the saved question. A candidate can also be one reading of a vague request rather than a market: it has outcome and venue set to OPTION and its title is the reading. Choose it the same way.
  • clarification — nothing was built; question says what is missing. Re-run with a prompt that answers it.
  • answer — the prompt was a question rather than a build request; answer is the reply.
Exit codes: 0 for every result, 3 auth error, 4 generation failed, 5 bad input (code says which).

miramarket-cli validate <file> [--json]

Validates a strategy JSON file’s structure, including where each ROI_PCT condition sits (under the BUY it measures, watching that BUY’s token). Once the structure is valid, it also refuses an ROI_PCT take-profit that no price can reach, judged from the token’s best ask now, or from the level of the price condition the buy waits on when that is its only condition and it watches the same token (a buy behind any other condition, or a token it cannot price within 5 seconds, is not judged); see rule 2 of the agent strategy guide. Exit 0 valid, 2 validation errors, 5 bad input (missing file, malformed JSON).
warnings[] lists each entry buy under Polymarket’s minimum order at the price now: $1, and the market’s minimum size (5 shares unless its order book says otherwise) at the price the buy is expected to fill at. That price is the best ask for a straight buy, or the gate’s level for a buy that waits on a price. Each entry is { "message": "..." }, and the message says what the buy gets and what the venue needs, for example:
A warning does not fail the command, because the price can move before the buy fires. Raise initial_principal_usd or the buy’s allocation_pct. Only the buys a run opens with are judged: a later buy is funded by what an earlier leg returned, and perps and stocks are not judged.

miramarket-cli preview <file> [--json]

Summarizes a strategy without contacting the server — node/edge counts, required principal, and warnings[] for anything that will be silently dropped or misbehave at import, including any PNL_USD condition (compared as a raw value). ROI_PCT is not warned on: Miramarket arms it from the real fill of the BUY above it.

miramarket-cli edit <file> [flags]

Updates fields in a local strategy JSON file. Edits apply in memory and the result is fully re-validated before writing — if validation fails, the source file is left untouched and the output reports the errors. edit never contacts the server; to change a strategy you have already posted, use strategies pull and strategies update.

miramarket-cli post <file> [flags]

Validates and posts a strategy, then starts a run (unless --no-start). Like validate, it refuses an ROI_PCT take-profit that no price can reach (exit 2), except on a retry whose --idempotency-key already posted. A live (non-demo) run is judged against the login’s budget: within it, the run starts at once after a Polymarket market-health and balance check; beyond it, nothing starts and the strategy waits for the account owner’s approval on Connected agents (below). Demo posts need only Create strategies and skip the health check.
The envelope also carries warnings[]: the same minimum-order warnings validate reports, empty when there are none. A warning does not stop the post, and a live run within the login’s budget has already started by the time you read this response. To review warnings before trading begins, run validate first, or post with --no-start. A live start beyond the login’s budget posts the strategy but starts nothing (started: false, runId: null) and returns the approval to wait on:
Once the owner approves, the run starts on its own. strategies approval reports it, and re-running the same post with the same --idempotency-key returns it too. After the owner denied the request, or it expired or failed, a retry reports that in approval.status and requiredAction; post again with a new key to ask again. Exit codes: 0 ok (including a start waiting for approval), 2 validation error, 3 auth error, 4 server error, 5 bad input (including IDEMPOTENCY_KEY_REUSED).

miramarket-cli strategies approval <approvalId> [--json]

Where a live start that went beyond the login’s budget stands: pending (waiting for the owner, with approveAt), started (with its runId), denied, expired (approvals last a day), or failed (with error). Exits 5 with APPROVAL_NOT_FOUND for an approval that isn’t this login’s.

Market data commands

None of these require authentication. markets orderbook and markets prices-history take a token id, or any handle that names one market (market id, condition id, market slug, or link). --outcome picks the side to read when the handle is not itself a token id (default yes), and the envelope’s tokenId is the token that was read. A handle that names several markets, such as an event, exits 5 and lists them. A handle nothing answers to also exits 5.

miramarket-cli markets resolve <handle> [--json]

Resolves any Polymarket handle to every id the market goes by. Each place wants a different one: a strategy node names the market id and an outcome token id, the order book and price history read a token id, Polymarket’s order system names a market by its condition id, and the site’s URL carries slugs. Give this command any one of them and it returns all of them. <handle> is an outcome token id, a condition id (0x followed by 64 hex characters), a market id, an event id, a market or event slug, or a polymarket.com/event/... link. Closed markets are found too.
matchedAs is token_id, condition_id, market_id, event_id, market_slug, or event_slug. An event match also carries event: { eventId, slug, title } and lists every market of the event. A short number can be a market id and an event id at once: both readings are returned. When nothing answers, the result is found: false with exit 0, not an error. Exit codes: 0 ok (including found: false), 4 market data unreachable, 5 empty handle.

Tokenized stock commands

Tokenized stocks on Base (AAPLc, TSLAc, NVDAc, PLTRc, MUc, and others) are real equities wrapped as tokens. They are not prediction markets: a strategy buys and sells them as token swaps, and a condition watches them by share price in dollars. markets search never finds them, so these commands exist instead. None require authentication.
Two prices appear, and they mean different things. priceUsd is the pool price, what a swap actually pays, and what a position is sized from. oraclePriceUsd is the reference price of the underlying share, what a PRICE_USD condition watches; the gap between them is poolPremiumBps. conditionPriceSource says what a condition watches: chainlink for the reference price, or aerodrome_pool_twap for a stock with no reference feed yet (MUc, PLTRc), whose oraclePriceUsd is null and whose conditions watch the pool’s 15-minute average price instead. Both are dollars per share, never a 0–1 probability. A large oracleAgeSeconds outside US market hours is expected, not a fault.
stocks history charts the pool price (priceSource names it), not the reference price. stale: true means fresh history was unavailable and the last good reading was returned. stocks show and stocks history exit 5 for a company that is not in the registry, and, distinctly, for one that is listed but has no pool to trade in yet (COINc, CRCLc, INTCc). portfolio reports stock holdings separately from cash (stockPositions, stockValueUsd), because a share has to be sold before a strategy can spend the proceeds. Tokenized stocks are geo-restricted: where they are not offered, posting a live strategy that buys one is refused with “Tokenized stocks are not available in your region”. account status --json shows the region check under checks.geo.

Hyperliquid perp commands

Perps are perpetual futures on Hyperliquid, margined in USDC. They are not prediction markets: a perp has two sides, LONG and SHORT, never resolves, and is priced in dollars. A strategy action on a perp may carry an integer leverage (default 1x), and a condition watches a perp by its mark price in dollars (signal: "PRICE_USD"). Every price these commands print is dollars, never a 0–1 probability. There are two kinds of perp:
  • Perps on Hyperliquid’s main dex: crypto such as BTC, ETH, and SOL. Positions are cross margin: your whole main-dex balance and your other cross positions back them together, so a position’s liquidation price depends on all of them, not on its leverage alone.
  • HIP-3 perps, listed on Hyperliquid by other providers (the xyz, para, io, and mkts dexes): stocks, indices, commodities, FX, rates, and pre-IPO names. Their coin carries the dex (xyz:NVDA, para:10Y) and their positions are always isolated margin: only that position’s margin backs it.
Ids are hl:<COIN> (hl:BTC) or hl:<dex>:<COIN> (hl:xyz:NVDA), spelled exactly as perps list prints them. Coins are case-sensitive (hl:kPEPE); never upper-case them.

perps list

count is the rows after the filters and total the whole catalog. In a row, dex is "" on the main dex. funding is the hourly rate as a fraction; positive means longs pay shorts. markPx: null means the price could not be read, not that the perp was delisted.

perps show <coin>

Accepts a ticker (BTC, any case), a HIP-3 coin (xyz:NVDA), or an id (hl:BTC, hl:xyz:NVDA). A bare ticker that no main-dex perp carries, such as NVDA, resolves to a HIP-3 listing (the one with the most 24-hour volume when several dexes list it), and resolution says which; name the dex to pick another. Otherwise resolution is null. actionTarget is the side --side picked (default LONG), with leverage set only when --leverage was given. actionTargets always carries both sides. --leverage must be a whole number from 1 up to the asset’s maxLeverage; a higher value exits 5. markPx is what a PRICE_USD condition watches, and minNotionalUsd is the smallest order the exchange accepts, in position size (margin times leverage).
An unknown coin exits 5.

perps history <coin>

--interval is one of 1m, 5m, 15m, 30m, 1h (default), 4h, 12h, 1d, 1w. Without --from, the window is the 168 bars ending at --to (default now). Both accept an ISO-8601 date or unix milliseconds. A HIP-3 perp needs its dex here: a bare NVDA is looked up on the main dex only.
A malformed coin or window exits 5; an unreachable upstream exits 4.

perps positions

withdrawableUsd is your free USDC on Hyperliquid, summed over every dex; withdrawableByDex splits it per dex ("" is the main dex). It is part of your cash: a withdrawal or a strategy leg on another chain moves it out when needed. accountValueUsd also counts margin backing open positions. liquidationPx is the mark price at which the exchange force-closes a position, before any exit of yours fires.
Exits 3 without a login and 4 when Hyperliquid is unreachable. Each perp order needs at least $10 of position size (margin times leverage), checked when the order is placed, not by validate. Funding is charged every hour a position is open. Hyperliquid perps are not available in some regions, including the United States: there, posting a live strategy that opens a perp position is refused with “Hyperliquid perps are not available in your region”. See /agent-strategy-guide.md for authoring a perp leg.

Trading and portfolio commands

miramarket-cli trade [flags]

Places a CLOB limit order directly — for manual/tactical orders, not strategy automation (use post under Strategy authoring commands for that). Requires authentication and --confirm. Needs the Place orders and bridge switch. Each buy must cost (price x size, in USDC) no more than the login’s budget, or it exits 3 before anything is signed; sells are never capped. A budget raised on Connected agents applies at once.
Exit codes: 0 ok, 3 auth error, 4 server error, 5 bad input.

Strategy management commands

What a run has made and still holds

strategies show and strategies runs report a run’s money as three figures: realizedPnlUsd and unrealizedPnlUsd together are the run’s whole profit or loss so far. Do not value an open position from its cost alone: a fresh $11 buy is worth about $11, not $0. Each entry in openPositions[] has its own valueUsd, unrealizedPnlUsd, and valuedAt. valuedAt is "mark" when the value comes from the last polled price, and "cost" when no price has been read yet. After a partial exit, a position keeps its full cost until it closes, so unrealizedPnlUsd also counts what the exits already returned (openPositions[].bankedProceedsUsd). For example, with ten shares bought for $100, five sold for $50, and the five left worth $10 each, `unrealizedPnlUsd` is $0, not -$50. A perp’s figure covers only the size still held.

strategies watch <strategyId> [flags]

Editing a running strategy

strategies pull and strategies update round-trip a strategy that is already running. Only the future part of the graph can change: nodes the run has executed or is waiting on are locked, and so are root_node_id and initial_principal_usd. Drafts and finished strategies cannot be edited in place — post a new strategy instead.

strategies pull <strategyId> [--out <file>] [--json]

Writes the strategy as authoring JSON (embedded in the envelope, or to --out) and reports which nodes you may touch: Nodes keep their node_id across the round trip, so nodes[i] positions from pull are stable for --set.

strategies update <strategyId> [file] [--set <path>=<value>] [--unset <path>] [--json]

Uploads either a file (usually one written by pull --out) or the posted graph with dot-path edits applied directly, then saves it. Before anything is sent, the CLI checks the locks and validates the result; the server repeats the checks and additionally rejects edges rewired into the executed past. An ABSOLUTE_TIME condition whose trigger time has already passed is accepted only if you leave it, its decision group, and the actions it gates exactly as pulled; change anything it gates and you must also give it a future time.

Bridging commands

Move USDC between Base and Polygon, swap Polygon USDC to USDC.e, or move USDC into your perps balance on Hyperliquid, before trading. All require authentication (the wallet address is resolved from your login). bridge execute also needs the Place orders and bridge switch, and each --amount must be within the login’s budget; bridge quote needs only read access. --direction is one of base-to-polygon, polygon-to-base, polygon-usdc-to-usdce, polygon-usdce-to-usdc, polygon-to-hyperliquid, base-to-hyperliquid. polygon-usdc-to-usdce and polygon-usdce-to-usdc are same-chain swaps on Polygon, which have no bridge to poll. The two *-to-hyperliquid directions deliver USDC into your perps balance on Hyperliquid. They are one-way: there is no direction back out. Money leaves Hyperliquid automatically when a withdrawal or a leg on another chain needs it. By default bridge execute waits: ok: true means a transfer between Base and Polygon filled, or a same-chain swap confirmed on-chain. It exits 4 in three cases, and none of them is a reason to run bridge execute again, because the transaction is already on-chain and a retry would move the funds a second time:
  • BRIDGE_FAILED: the cross-chain bridge failed. The envelope says whether the funds were refunded on the origin chain.
  • BRIDGE_PENDING: the cross-chain transfer is still in flight after the polling window. For a transfer between Base and Polygon, poll it with bridge status <txHash> --chain-id <chainId> using the values in the envelope. For a *-to-hyperliquid transfer, follow it as described below instead.
  • SWAP_UNCONFIRMED: a same-chain swap on Polygon was submitted but not confirmed within the wait window. There is no bridge to poll. Look up the txHash from the envelope on a Polygon block explorer, or run balance --chain polygon until the USDC and USDC.e balances reflect the swap.
A *-to-hyperliquid transfer is confirmed only by your Hyperliquid balance. bridge status cannot see delivery into Hyperliquid, so neither it nor ok: true from bridge execute proves the USDC arrived. Before you run bridge execute, record withdrawableUsd from perps positions --json. After it returns, whether ok: true or BRIDGE_PENDING, run perps positions --json until withdrawableUsd reaches the recorded value plus the amount, less fees; delivery can take up to about ten minutes. A running strategy, a withdrawal, or a perp position opening or closing in the meantime also changes withdrawableUsd, so account for those, or move funds while nothing else is using the balance. If it has not arrived after that, check the origin txHash on a Base or Polygon block explorer rather than running bridge execute again.
A strategy funds itself. Posting one that needs USDC on another chain, or on Hyperliquid, moves it on demand, so a manual bridge is only for moving funds ahead of time or for withdrawing.

miramarket-cli status

Shows local CLI state: auth, last strategy worked on, last post result, remaining required actions.

Environment variables

Session lifetime

The cached access token lasts 15 minutes, but the CLI also caches a 30-day refresh token (rotated on every use) and silently redeems it at the start of every command, and again before any request a long-running command such as strategies watch makes after the token has run out. There’s no re-login to babysit, on a laptop or an unattended server alike, for as long as the login is used at least once every 30 days: each refresh moves the login’s end date to 90 days out. A refresh whose answer is lost (a timeout, or a command killed mid-refresh) does not end the login; the next command presents the same refresh token again and it is accepted, for up to a day. If the login is revoked (on Connected agents or with logout) or has ended, the next command reports NOT_AUTHENTICATED (exit 3) with the reason, and you run miramarket-cli login again. If the login could not be renewed only because Miramarket was unreachable or slow, the command reports LOGIN_REFRESH_FAILED (exit 4) instead: the login is still valid, so retry the command and do not log in again.