# conduyt

Command-line interface for [Conduyt CRM](https://conduyt.app) — manage contacts, deals, pipelines, and run AI insight queries from your terminal.

## Install

```bash
npm install -g conduyt
# or run without installing
npx conduyt --help
```

## Authentication

Generate an API key in Conduyt under **Settings → API** (keys start with `cdy_`), then either save it:

```bash
conduyt config set --key cdy_your_key_here
```

or set environment variables (these override the saved config):

```bash
export CONDUYT_API_KEY=cdy_your_key_here
export CONDUYT_API_URL=https://conduyt.app   # optional, defaults to https://conduyt.app
```

The saved config lives at `~/.conduyt/config.json` and is written owner-only (`chmod 600`).

A secret given as a flag (`config set --key`, `fromk connect --key`, `fromk webhook-secret --secret`, `zoom connect --client-secret`, `call-flows functions create|update --secret`, `agent listen --pair-code`, `project-blue connect --key`, `project-blue voice-connect --api-key-secret`) stays in your shell history; where the command allows it, set the environment variable instead (`FROMK_API_KEY`, `FROMK_WEBHOOK_SECRET`, `ZOOM_CLIENT_SECRET`, `PROJECT_BLUE_API_KEY`). A usage error raised by one of these commands, by the program or by a group above them never prints what you typed: it is one fixed sentence that names the command and points to its `--help` (no "Did you mean"). Every other command's usage errors are Commander's own.

## Commands

```bash
conduyt whoami                          # show the authenticated user
conduyt contacts list --limit 25        # list contacts (supports --cursor, --query)
conduyt contacts list --tag-id <uuid> --limit 1   # contacts carrying a tag (repeatable --tag-id / --tag <name>: ANY-of, max 20); --limit 1 is only an existence probe, the total can be deferred
conduyt contacts count --tag-id <uuid>    # the exact total of a list filter (the filters shared with list, not the list-only --deal-context-*: with those page with has_more; incl. --source, --assigned-to, --company, --company-id, --created-from/--created-to, --updated-from/--updated-to, --import-id, --min-score, --smart-view, --smart-list, --tags, --filters, --reachability, --cf, --custom-field key=value; use it when the list's total is deferred: a stderr note says so)
conduyt companies list --count-mode none  # skip the total count (meta.total null, meta.has_more exact)
conduyt companies related <id> --kind contacts|deals|children [--cursor <c>] [--all]   # GET /companies/{id}/related: the pages after the first page `companies get` embeds (contactsNextCursor / dealsNextCursor / childNextCursor); prints { kind, rows, total, nextCursor }, pass nextCursor back until null; --all follows it to the end
conduyt contacts get <id>               # fetch one contact (carries `revision`, `hasOutboundSms` and `hasOutboundEmail`: a proven send only)
conduyt contacts update <id> --assigned-to <userId> [--keep-previous-owner]   # reassign the lead; --keep-previous-owner keeps the previous owner as a read-only collaborator instead of releasing them (400 without --assigned-to)
conduyt contacts update <id> --first Ann --expected-revision <n>   # PATCH; a contact changed since revision n is refused: 409 contact_changed, exit 1, code and current revision printed
conduyt contacts merge <primaryId> <secondaryId...> [--confirm [--yes]]   # DESTRUCTIVE: a dry run by default (prints the impact); --confirm shows it, asks y/N, then merges (the losers are deleted); --yes skips the question; moved counts 409 and 503 merge_contacts_busy / merge_budget_exhausted + Retry-After exit 1, never retried
conduyt contacts duplicates <id> [--cursor <c>] [--limit <n>] [--held-cursor <c>] [--held-limit <n>]   # GET /contacts/{id}/duplicate-proposals; prints { proposals, heldIdentifiers, total, nextCursor, membershipRevision, heldIdentifiersTotal, heldIdentifiersNextCursor, heldIdentifiersMembershipRevision } (open and not_sure possible duplicates; keyset paged; read-only)
conduyt imports duplicates <importId> [--page <n>] [--per-page <n>]  # GET /imports/{id}/duplicate-proposals; the proposals one import raised on the records it created, every status, oldest first; prints { rows, meta: { page, per_page, total } }
conduyt contacts duplicates decide <id> <proposalId> --as not_sure|different|merge   # POST the decision; not_sure keeps both visible, different is final, merge only records a pair ALREADY merged (never merges); 409 already_decided / not_merged and 403 other_record_not_editable exit 1
conduyt contacts collaborators add <contactId> <userId> [--expected-revision <n>]      # POST /contacts/{id}/collaborators; prints { added, revision }
conduyt contacts collaborators remove <contactId> <userId> [--expected-revision <n>]   # DELETE with a body; prints { removed, revision }; 404 when not a collaborator
conduyt chat channels                   # GET /chat/channels: your channels; also CREATES your auto-channel memberships the first time
conduyt chat unread                     # GET /chat/unread: per channel { channelId, unread, soundUnread, newestSeq, latestSeq }
conduyt chat messages <channelId> [--limit 1-100] [--cursor <messageId> | --after-seq <n>]   # newest first; --after-seq = only messages committed after that seq (catch-up read, never with --cursor); each message also carries `version`; prints { data, hasMore, nextCursor }; every message carries `seq`; does not move the read marker; a 403 "Not a member of this channel" is retried once after `chat channels`
conduyt chat mark-read <channelId> <messageId>   # readUpTo: marker moves to that message's seq, forward only (older or foreign message = no-op, exit 0); prints the channel's newest message; same one-retry membership bootstrap
conduyt chat realtime-token [--channel <id>]...   # GET /realtime/token: signed Ably token request (up to 10 --channel); { enabled: false, reason } when the account switch is off; prints accountId / userId
conduyt chat notifications <channelId>   # GET .../notifications: { level, isDefault, notify, updatedAt, membershipId, membershipSince, membershipSeq }
conduyt chat set-notifications <channelId> --level all|mentions|mute|default --expected-updated-at <iso|none> --expected-membership-id <id> --account-id <id> --user-id <id>   # compare-and-set, sent once; 409 stale prints the current membership and exits 1
conduyt chat settings [--realtime on|off] [--presence on|off] [--quiet-hours HH:MM-HH:MM|none] [--digest-minutes 0|15-240]   # PATCH /settings teamChat, owner/admin only
conduyt notifications list [--page n] [--per-page 1-200]   # prints { data, meta }: meta.latestByType = { type: { latest, count } } over the last 24 h, next to unreadCount / unreadByType
conduyt deals list --pipeline <id>      # list deals
conduyt deals list --health-summary --pipeline <id>   # Pipeline health strip for the filtered set (totalOpenDeals, atRiskValue, checks[]); add --health-check stale --health-limit 20 for one check's deals, --health-cursor <nextCursor> to page, --health-rows-only for just the page
conduyt deals list --board-snapshot --pipeline <id> --board-columns <stageId>[:<limit>],...   # every named column of one pipeline from ONE database snapshot (a moved deal is in exactly one column); prints { columns: [{ stageId, limit, deals }], meta: { board_snapshot: true } }; --page / --all / --stage / --stage-name / --health-* refused before any request; 503 board_snapshot_busy or gate_busy exits 1 with Retry-After
conduyt deals health --pipeline <id> --check needs_action   # GET /deals/inspection: the six checks over open deals; --check adds its deals, --cursor/--offset pages
conduyt deals health-fix <dealId> --check stale --expected-updated-at <iso> --stage-id <uuid>   # Pipeline health quick fix (PATCH /deals/{id} with checkOrigin): stale = --stage-id, unassigned = --assigned, missing_close_date = --close-date, missing_contact = --contact; 409 deal_changed / deal_check_cleared and 400 health_fix_mismatch exit 1 verbatim, never retried
conduyt deals health-next-action <dealId> --check needs_action --expected-updated-at <iso> --title "Call back" --idempotency-key <key>   # "Set next action" (POST /tasks with checkOrigin): one non-done quick-fix task per deal, 409 deal_has_next_action / deal_changed / deal_check_cleared exit 1 verbatim
conduyt deals card-fields set value,contact,custom:next_contact_at   # the kanban card fields (1-8, built-ins or custom:<fieldKey>); `card-fields get` reads them
conduyt settings import-rule                                          # (#1272) the contact import's required-field rule: { all, anyOf, scoped }
conduyt settings import-rule set --all firstName,lastName --any-of email,phone   # replace it whole; repeat --any-of for more groups, or --json '{"all":[...],"anyOf":[[...]]}'; a legacy account is refused 422
conduyt settings invoicing                                            # the invoice payment link (the business's OWN Stripe payment link, PayPal or ACH page; Conduyt never takes the payment): { paymentLink, defaultButtonLabel, settingsRevision }; `settings invoicing get` is the same read
conduyt settings invoicing set --url https://buy.stripe.com/… [--label "Pay now"] [--instructions "Pay within 14 days"] [--expected-settings-revision <n>]   # save the link; it is REPLACED whole, so a label or instructions you leave out are cleared; without --expected-settings-revision the command reads the revision first
conduyt settings invoicing set --clear                                # remove the link (paymentLink null); refusals: 409 stale_settings_revision, 422 invalid_payment_link_url / _label / _instructions, 503 payment_link_ownership_unverifiable (nothing saved, run it again)
conduyt pipelines stage-rules set <pipelineId> <stageId> --required-fields contactId,custom:loan_amount --required-documents 2 [--lost-reason-allow-other true] [--entry-by-automation-only true] [--closes-other-open-deals true [--closes-other-open-deals-reason "Won elsewhere"]] [--assigns-contact-owner true]   # what a deal needs to enter the stage (--entry-by-automation-only true: only an automation can move or create a deal into it, every other entry is refused 422 stage_automation_only; `pipelines list` shows it on each stage; --closes-other-open-deals true: a deal entering the stage marks the contact's other open deals lost, reason 1-200 characters; --assigns-contact-owner true: the entering deal's owner becomes the contact owner and the previous contact owner stays a collaborator); other stages untouched; `stage-rules get [pipelineId] [stageId]` reads
conduyt deals bulk-update --file updates.json   # update up to 100 deals at once ([{id, stageId, value, ...}]); per-item results, exit 1 if any failed
conduyt deals update <id> --assigned-to <userId> [--keep-previous-owner]   # reassign a deal; --keep-previous-owner keeps the previous owner as a read-only collaborator of the contact (400 without --assigned-to or with a contact change)
conduyt deals bulk-edit --ids <id>,<id> --stage <stage>   # the SAME change on up to 500 deals (POST /bulk/deals/edit { ids, updates }); failed deals are listed with their code (e.g. stage_automation_only), exit 1 if any failed
conduyt pipelines                       # list pipelines and stages (each carries color, automationOnly, sortOrder)
conduyt pipelines list --archived       # the archived pipelines (owner / admin key): name, archivedName, openDeals, stageCount
conduyt pipelines archive <id> --move-open-deals-to <pipelineId|none> [--expected-settings-revision N]   # archive + move the open deals in one transaction; refusals print their code (stale_settings_revision, target_not_open, dpp_post_close, archive_too_large, target_archived, intake_target, pipeline_archived) and exit 1
conduyt pipelines settings-revision   # the account settingsRevision to pass as --expected-settings-revision to archive / delete-stage (409 stale_settings_revision when settings changed since)
conduyt pipelines restore <id>          # bring an archived pipeline back (last in the menu, never the default; 409 name_taken)
conduyt pipelines reorder --order id1,id2 --expected-revision id1,id2   # board-menu order in one transaction (409 order_changed prints the current revision); `reorder-stages <pipelineId>` does the same for a pipeline's columns
conduyt pipelines delete-stage <pipelineId> <stageId> [--move-to <stageId>] [--expected-settings-revision N]   # soft delete: an empty stage always deletes (hidden everywhere, then 404, no restore, name reusable); --move-to re-homes live deals first; 409s print the server message (deals in it, used by N active automation(s), DPP map, pipeline_archived, intake_target, stale_settings_revision); a run parked before the delete fails at that step
conduyt pipelines rot-days set <pipelineId> 21   # days without activity (1-90) before a deal reads "Stale in stage"; `rot-days get [pipelineId]` reads
conduyt status-metadata list --stage-id <id>   # the status codes + buckets attached to stages; `get | create | update | delete | import` (update / delete take --expected-updated-at; 409 metadata_changed)
conduyt status-metadata import --file rows.json --mode replace   # set-based import (max 1000; an item key outside stageId, code, bucket, lifecycleStage, dripEligible, dripTrackName, isTerminal, notes is refused before any request); per-item errors print and exit 1; `--mode replace` with no items is refused unless `--confirm-empty-replace` (it deletes every row). Timeouts: archive 75 s, import and the Mailchimp write / action commands 60 s; on a timeout the server may have applied it, so read the state first
conduyt integrations mailchimp settings  # the Mailchimp audience sync (API key scope integrations); `set | audiences | push | retry-unsubscribes | reconcile-statuses [--restart] | confirm-reconciliation`. Connecting is browser-only (OAuth): do it in the app
conduyt pipelines update <id> --automation-only true   # only automations, API keys and owners / admins move or edit its cards (owner / admin key); also --color <palette hex> and --sort-order
conduyt automations dry-run <id> [--contact <id>] [--deal <id>] [--company <id>] [--execution <id>]   # preview one trigger occurrence without side effects; --deal for a deal occurrence, --company for a company occurrence, --execution (admin or owner only) replays a stored run of this automation and supplies the company its payload carried; no test-node command exists in this CLI
conduyt search "acme corp"              # search across the CRM
conduyt insights summary                # run an AI insight query
conduyt insights saved_report --report "Lead Activity" --period last_7_days   # run any saved report as a tool
conduyt insights dashboard --dashboard Floor --period today                   # run every tile of a board
conduyt insights report_catalog                                                # what this key can run
conduyt sequences list --type sms --on   # Email and SMS sequences (--archived, --summary)
conduyt sequences senders sms           # who can send an SMS sequence (each member's line)
conduyt sequences stats <id>            # sends, opens, clicks in total and per step
conduyt sequences people <id> --all-active   # every live run; status and endedReason per run
conduyt sequences check <id> <contactId...>  # who is eligible before enrolling
conduyt messages transports             # what a workflow Send SMS step can speak through today (Twilio numbers, Project Blue lines, the WhatsApp sender)
conduyt whatsapp status                 # WhatsApp via your Twilio: connected? from which sender
conduyt whatsapp senders                # the senders Twilio lists for the account (ONLINE = connectable)
conduyt whatsapp connect <senderSid>    # connect a sender (verified with Twilio first)
conduyt whatsapp templates              # approved / pending / rejected templates with their {{n}} placeholders
conduyt dialer calling-hours   # the window the dialer enforces (effectiveCallingWindow: source, enabled, start/end HH:MM, timezone or null = contact zone, then number area code, then account)
conduyt dialer set-calling-hours --enabled on --start 09:00 --end 17:30 [--timezone America/Chicago|none]   # (omit keeps the stored zone, none clears it; an unknown zone is the settings route's 422) settings.callingWindow (the API merges it into the saved window) (enabled, start, end always sent; end after start); --enabled off needs --acknowledge-any-hour (else 400 calling_hours_acknowledgement_required)
conduyt email opt-outs list [--page n] [--per-page 1-100]   # the workspace email opt-out list (owner / admin key; hash-only rows { id, source, reason, createdAt } plus paging meta)
conduyt email opt-outs add <email> --reason "vendor request"   # put an address on the list by hand (reason 1-200 required; 201 new, 200 promoted from an unsubscribe-link / Mailchimp row, 409 already listed by hand with the existing row)
conduyt email opt-outs resubscribe <email>   # take an address off the list (prints { removed })
conduyt me get   # the caller's own identity and account incl. user.ringtone (GET /users/me, same as /auth/me and whoami); editing the profile is a signed-in person's action, not exposed to API keys
conduyt short-links create <url> [--json '{...}']   # make (or reuse) the Conduyt short link for a public link-shortener address the Message check flagged (messages scope); prints { url, target }; errors verbatim, once: 400 not_shortenable / invalid_body, 403 forbidden, 413 body_too_large, 429 rate_limited (Retry-After), 503 short_link_unavailable
conduyt files upload <path> [--name n] [--content-type t]   # upload a local file as a CRM file, end to end (up to 50 MB; key scope files): size check, intent, streamed PUT to the signed URL, finalize; prints { uploadId, filename, size, contentType }; attach with POST /files { entityType, entityId, uploadId }
conduyt files upload-intent --name <fileName> --size <bytes> [--content-type t]   # step 1 of a direct upload: prints the signed PUT target { uploadId, uploadUrl, method, contentType, size, expiresIn, maxBytes }
conduyt files upload-finalize <uploadId>   # step 3, after the bytes were PUT: prints { uploadId, filename, size, contentType }
conduyt chat upload <channelId> <path> [--name n] [--content-type t]   # the same end to end for a Team Chat attachment (up to 10 MB; key scope chat, member of the channel); prints { url, name, size, type } for a message's metadata.attachments
conduyt chat upload-intent <channelId> --name <fileName> --size <bytes> [--content-type t]   # step 1 for a chat attachment
conduyt chat upload-finalize <channelId> <uploadId>   # step 3 for a chat attachment (an unfinalized attachment in a message is refused 409 attachment_unavailable). Intent errors print as sent, once: 400 file_name_required / file_type_not_allowed / file_size_required / file_empty, 413 file_too_large, 429 (Retry-After), 503 uploads_unavailable. Finalize (120 s timeout): 400 upload_id_required, 404 upload_not_found, 409 upload_incomplete, 409 upload_in_progress, 413 file_too_large, 422 upload_size_mismatch, 400/415 file_rejected, 429, 503 uploads_unavailable; `upload` repeats only a finalize 409 upload_in_progress (at most 4 total attempts)
conduyt chat send <channelId> --body "Update"   # canonical audited Team Chat message write
conduyt chat reply <channelId> <parentMessageId> --body "Done" [--idempotency-key reply:<sourceId> --claim-token <generation>:<listenerId>]   # thread reply; an agent's reply to an inbox turn names its claim (the turn prompt gives both): it completes that turn only in the source's channel and thread with the current claim; otherwise 409 (reply_wrong_channel / reply_wrong_thread / reply_stale_claim) and nothing is posted; without the token 400 reply_token_required
conduyt chat react <channelId> <messageId> --emoji "✅" [--claim-token <generation>:<listenerId> [--source-message-id <turn message id>]]   # add/remove your reaction; an AI teammate's reaction with the turn's claim token ends that turn (outcome reacted); 409 reaction_stale_claim / turn_finished write nothing
conduyt chat stay-silent <turnMessageId> --claim-token <generation>:<listenerId>   # an AI teammate ends its turn with no response (the claim route's silent action, outcome silent); 409 turn_finished when it already replied or reacted
conduyt chat linked-record <channelId>   # the channel's linked deal or contact, read-only summary { kind, record } under your own visibility; one 404 for not a member / no link / not visible
conduyt chat link-record <channelId> --deal-id <id> | --contact-id <id>   # link a deal or contact to a general channel (owner/admin member, admin-tier key with the chat scope; AI teammates refused); prints { id, dealId, contactId, changed }
conduyt chat unlink-record <channelId>   # remove the channel's link (idempotent; the record is untouched)
conduyt chat messages <channelId> --top-level [--limit n] [--cursor id]   # (#684, thread view on) the channel as the thread view shows it: top-level messages with `thread` (replyCount, lastReplyAt, repliers, replierCount) and the replies shown in the channel with `threadReply` { reason: aiFirstAnswer | alsoInChannel, root }; never with --after-seq
conduyt chat thread <channelId> <rootMessageId> [--limit 1-50] [--before <earlierCursor>]   # (#684) one thread by its root: { root, replies (oldest first), total, earlierCount, hasEarlier, earlierCursor, aiReactions, replying }; latest page by default
conduyt chat thread-files <channelId> <rootMessageId>   # (#684 lane D) the files shared in one thread, oldest first, { data, hasMore } (200 per read)
conduyt chat reply <channelId> <parentMessageId> --body "Sent" --also-in-channel   # (#684) "Also send to #channel" on a person's reply (one message, shown in the channel too)
# The thread view (#684) works only while the workspace's switch is on (`chat channels` then carries teamChatThreads: true). Its
# parameters are sent only when their flag is given. While it is off each answers 409 team_chat_threads_off, printed with the hint
# "The thread view is not switched on for this workspace (account setting teamChatThreads)." in the final details object. Against a
# server that predates the thread view: `chat thread` / `chat thread-files` answer 404 (the hint says so), `chat messages
# --top-level` exits 1 saying the server did not apply it, and `chat reply --also-in-channel` posts the reply in the thread only and
# says so on stderr (exit 0, never re-sent).
conduyt agent pair <singleUseCode>   # exchanges a 15-minute code; prints the raw agent key once and never saves it (use `agent listen --pair-code` to have it stored)
conduyt agent listen --adapter codex [--pair-code <code>] [--turn-start-timeout <s>]   # long-poll + heartbeat; (1.91.2) runs each turn in the listener's OWN Codex thread with `codex exec resume` and completes it when the reply lands
conduyt agent listen --adapter codex --codex-mode queue --thread <desktopCodexThreadId>   # the old bridge: queues each turn with `codex queue`; the Codex desktop app runs it only while that thread is open
conduyt agent listen --adapter claude-code [--model sonnet]   # one-shot non-interactive `claude --print` per turn with only the reply/react/stay_silent/linked_record/read_thread/read_messages/search_messages tools (not the Claude Code channels protocol)
conduyt agent listen --adapter command --command ./agent.sh [--command-arg x] [--provider grok]   # prompt on stdin, stdout posted as the thread reply (empty output = a failed turn)
# A Grok Bot as an AI teammate (#1140; owners and admins; create the teammate in Settings > AI with the provider Grok Bot first):
conduyt agent connect <teammateId>   # step 1: prints the message to paste into Grok Bot and the teammate's token, shown once (never saved); running it again issues a new token and the old one stops working
pbpaste | conduyt agent webhook set <teammateId> --stdin   # step 3: the routine's address and key as Grok Bot shows them; checked, stored, tested, then waits for the hello (Listening, exit 0; otherwise one sentence of what to fix, exit 1)
conduyt agent webhook set <teammateId> --url <routineAddress>   # the same, with the key in CONDUYT_GROK_ROUTINE_KEY (or `--url <address> --stdin` with the key alone on stdin); the key is never a flag and never printed; --no-wait, --json
conduyt agent webhook test <teammateId> [--no-wait] [--json]   # the card's Test button: the hello again to the stored routine
conduyt agent webhook status <teammateId> [--json]   # Not connected / Waiting for Grok Bot to say hello / Listening / Not listening, the sentence of what to fix, the address masked
conduyt agent disconnect <teammateId> [--json]   # revokes the token, clears the routine's key, cancels pending deliveries; the teammate and its messages stay
conduyt agent list [--json]   # (#1153) the workspace's AI teammates (an owner's or admin's key): id, @handle, name, provider, state, Grok Bot connection; nothing secret
# <teammateId> is the teammate's id (a UUID) or its @handle (`agent list` shows both); the server resolves the handle.
# Against a server without these routes (it answers an HTML 404) each command says "This Conduyt server does not have the Grok Bot
# connection yet (it predates it); connect the teammate in Settings > AI instead." and exits 1.
conduyt agent keys list [--key-file <path>]   # the teammate keys stored on this computer: origin, @handle, agent id, workspace id (never the key)
conduyt agent keys remove --origin https://conduyt.app (--agent-id <uuid> | --agent <handle>) [--key-file <path>]   # remove ONE stored key; an ambiguous handle (two workspaces) is refused and the candidates listed
# Setup notes:
# - --url (and CONDUYT_API_URL) is the Conduyt site root, e.g. https://conduyt.app. The listener's own calls go to /api/v1/... on that
#   origin; the same value reaches each turn as CONDUYT_API_URL, and `conduyt chat reply` and the Conduyt MCP add /api/v1 themselves,
#   so an /api/v1 URL there would double the prefix;
# - Codex (1.91.2, job 58), exec mode (the default): the listener OWNS its Codex thread. On its first run it creates a headless
#   session with `codex exec` and keeps the id at ~/.conduyt/agent-listener/<listener>.codex-thread (owner-only), reusing it on every
#   later start; --thread is refused ("exec mode runs its own thread; use --codex-mode queue to drive a desktop thread"). Never open
#   that thread in the Codex desktop app. Migration from a queue-mode listener: the old desktop thread's memory is NOT carried over;
#   each turn reads its history with read_thread / read_messages (search_messages finds an older message by its text). Each turn is `codex exec resume --json <own thread> -` (the prompt
#   on stdin), run in a private empty folder (~/.conduyt/agent-listener/codex-<listener>), with the listener's own per-turn Conduyt
#   tools server (reply / react / stay_silent / linked_record / read_thread / read_messages / search_messages, and local_files with the reply's
#   localFiles / attach on an owner's local-files turn, as Claude Code) as the turn's conduyt_agent MCP server, so a turn replies even
#   when a Conduyt connector in your Codex setup fails to start. The listener key never enters the Codex process environment: the
#   tools server reads it from ~/.conduyt/agent-listener/<listener>.codex-key (owner-only, written exactly like keys.json: 0600 on
#   macOS / Linux, an owner-only ACL on Windows, protected before the key is written; rewritten at every start and kept). <listener>
#   names ONE teammate on ONE Conduyt origin (its agent id plus a hash of the origin; for a key from CONDUYT_AGENT_API_KEY a hash of
#   origin and key), never the handle, so two teammates that share a handle never share a thread, a key file or a folder,
#   and every turn pins Codex's shell environment policy (core variables only, *KEY* / *TOKEN* / *SECRET* / *PASSWORD* and CONDUYT_
#   names excluded, shell snapshots off). A turn with no turn event within --turn-start-timeout (60 s) fails at once as NEEDS
#   ATTENTION ("Codex turn never started: <reason>" in the log);
# - Codex, --codex-mode queue --thread <id>: the old `codex queue` bridge: the Codex desktop app runs the turn only while it has that
#   thread open, and replies with its own Conduyt MCP (register it in Codex with CONDUYT_API_URL, the site root, and CONDUYT_API_KEY
#   in its environment);
# - Claude Code: every turn is isolated from your own Claude Code setup. It runs in a fresh empty temporary directory (removed after
#   the turn, also when it fails or times out), on an explicit model (--model, default sonnet, never your pinned default), with
#   `--setting-sources ""` (no user / project / local settings, so none of their hooks, permission rules or plugins, and no user or
#   project CLAUDE.md), `--strict-mcp-config` (only the Conduyt tools server), `--disable-slash-commands` (no skills), `--tools ""`
#   (no built-in tools: only reply / react / stay_silent / linked_record / read_thread / read_messages / search_messages), `--no-session-persistence` (no saved transcript) and `--output-format json` (the
#   turn's cost is logged). Admin-managed (policy) settings and your Claude login still apply;
# - logging: every line carries a timestamp; a startup line "listening as @<handle>, heartbeat every <n> s, health <address>", then per
#   turn "turn received" and one of "turn replied" / "turn reacted" / "turn silent" / "turn consumed" (paused for a human, agents
#   muted) / "turn failed", each with its
#   duration in ms and, for Claude Code, its cost.
# Connection test and turn rules (1.91.1, capability threshold 1.91.0, app #1228):
# - Settings > AI shows a Test on a listener teammate's row once its listener reports 1.91.0 or later (every heartbeat sends the
#   version): Test queues a chat.agent_test item on the inbox page, and the listener posts "Hello, I'm connected." in AI Team Chat
#   once with that test's token; the row reads Listening only after that hello (an older listener keeps the heartbeat rule, and its
#   test is to mention it with hello in AI Team Chat); (1.91.2) an exec-mode Codex listener first runs one real test turn in its
#   thread and posts the hello only when the AI answered it, so Test fails when the AI cannot answer;
# - a claimed turn prints the server's turn rules (the event's instructions) verbatim in place of the listener's own end-of-turn
#   sentence; against an app without them the listener's own sentence stays.
# Thread-aware turns (#802, the app listener's #655 phase 1 behaviour):
# - every turn's prompt carries the thread so far ("Recent thread (oldest first)": the last 20 messages before it, above the
#   teammate's visibility fences, bodies cut at 2,000 characters) and, when the channel is linked to a deal or contact this teammate
#   may read, the line "This channel is linked to deal <id>" (or contact);
# - Claude Code and Codex end a turn with exactly ONE of: a reply (the reply tool with the idempotency key and claim token), a
#   reaction (the react tool, which passes the claim token: `chat react --claim-token` from a shell) or stay_silent (`chat
#   stay-silent`). The first ends the turn; a second, different one is refused 409 turn_finished. The listener logs "turn replied",
#   "turn reacted" or "turn silent" and acknowledges each; none of them is a NEEDS ATTENTION. linked_record (`chat linked-record`)
#   is the read-only lookup of the linked record. Codex reaches these through the Conduyt MCP (conduyt_react_chat_message with
#   claimToken, conduyt_stay_silent, conduyt_get_chat_linked_record: conduyt-mcp 4.105.4 or later);
# - the generic command adapter gets the same thread history and linked record line on stdin, but it still CANNOT react, stay
#   silent or look the record up: it has no tools, its stdout is always posted as the reply, and an empty stdout is a failed turn
#   (NEEDS ATTENTION). Its prompt says so ("this adapter can only reply");
# - the daily turn budget (200 turns per workspace day): a spent budget is a definite refusal (429 agent_daily_budget_exhausted);
#   nothing is claimed and the cursor does not move; the listener logs the count and sleeps until the reset (10 minutes at most),
#   then polls again.
# How a listener delivers (the shipped contract):
# - the cursor is the SERVER's; every turn is CLAIMED before the coding agent runs, under a lease renewed every minute;
# - a turn completes only on the server's reply receipt (the reply posted with the turn's claim token); a turn that fails, times out
#   (20 min) or produces nothing is NEEDS ATTENTION and is never re-run on its own: `--retry-claimed <ids>` re-runs it once (a turn
#   that already replied is acknowledged instead, never re-run; one whose outcome stayed unknown for 60 minutes is "possibly
#   replied" and re-runs only with `--force`);
# - every request is abandoned after 30 s; an unreadable or incomplete answer is treated as unknown and asked again, never acted on;
# - 402 (the workspace is not on a plan that includes AI teammates), at start or later, PAUSES the listener: it checks every
#   5 minutes and resumes by itself after an upgrade; 401 (revoked), 403 (permission) and 404 (switched off / not found) stop it;
# - the paired key is stored (one record per Conduyt origin + teammate, default ~/.conduyt/agent-listener/keys.json, --key-file to
#   choose, --agent <handle|id> to pick one of several), so a restart or a paused listener never needs a new pair code. Storage is
#   checked BEFORE a pair code is used. macOS / Linux: the file is mode 0600 (its directory created 0700); Windows: the file's ACL
#   grants only your account, inheritance removed (icacls), read back and checked; if that cannot be verified nothing is stored.
#   A malformed store is refused and left untouched (the previous copy is kept as keys.json.bak);
# - heartbeats run every 30 s on their own timer; a loopback-only health check on 127.0.0.1 serves Settings > AI "Test connection",
#   on port 47631 by default (the port Settings > AI fetches; if it is taken the listener logs "health endpoint not started" and
#   keeps running without it). A second listener on one computer: --health-port 0 takes a free port (printed in the startup line; the
#   Settings page cannot find it, so its "Test connection" only sees the 47631 listener); --health-port <n> pins one;
#   --app-url <origin> names the app allowed to read it; --no-health turns it off
conduyt dialer voice-drop --contact <id> [--recording "Missed you"] [--if-human play]   # a call that plays a Voicemail Drop recording to a machine
conduyt messages send-sms --contact <id> --transport whatsapp --whatsapp-template HX… --whatsapp-variables '{"1":"Alex"}' --body "…"
conduyt messages send-sms --contact <id> --invoice <invoiceId> [--resend] --body "… https://<app>/pay/<invoiceId>"   # Text it (1.91.3): sends an invoice by text; the contact must be the invoice's own and the body must carry its link (`invoices send-options` returns the exact text); refusals print with their code (409 invoice_send_pending, invoice_not_sendable, no_contact, invoice_contact_mismatch; 400 invoice_link_missing)
conduyt invoices list [--status draft,sent] [--contact <id>] [--from <date>] [--to <date>] [--search <q>]   # (1.91.3, invoicing 1a-1) newest first; also `invoices get|next-number|payments|activity|send-options <id>`
conduyt invoices create --contact <id> --items '[{"description":"Setup","unitPrice":100,"quantity":1,"taxRateId":"<id>"}]' [--payment-terms …] [--discount-percent 5] [--attachment <id>]   # a DRAFT; `invoices update <id>` takes the same flags (--items REPLACES the lines); `invoices duplicate <id>` copies into a new draft; `invoices delete <id>` removes a draft (409 invoice_send_in_flight while a send is in flight)
conduyt invoices send <id> [--resend]   # Email; 409 invoice_send_pending / invoice_send_complained / invoice_send_in_flight, 503 gate_busy print with their code and are never retried
conduyt invoices mark-sent <id> --via manual|link   # went out another way; no email
conduyt invoices record-payment <id> --amount 12.50 [--method card|bank|bank_transfer|cash|check|other] [--reference …] [--notes …] [--paid-at 2026-11-10]
conduyt invoices void <id> --reason "billed twice"   # the reason (1-500 characters) is required and kept on the invoice
conduyt tax-rates list [--include-archived]; conduyt tax-rates create --name "NJ" --percent 6.625; conduyt tax-rates update <id> [--name …] [--percent …] [--active true|false]; conduyt tax-rates delete <id>   # delete archives; 409 tax_rate_cap
conduyt products list|get|create|update|delete   # the product catalog; --default-tax-rate <id|none> sets the saved tax rate new lines start with
conduyt messages check --channel sms --body "…" [--context first|conversation] [--provider twilio] [--clean] [--body-file draft.txt]   # grade a DRAFT before sending (score, grade, flagged words with safer alternatives, Unicode code-point offsets); --provider twilio (texts only) words the notices in Twilio's wording, --clean adds the cleaner's proposal; prints `englishDictionary` (`loaded` / `not_loaded`: the final grade is only meaningful when `loaded`) and `engine.version` (2.2.1); educates, never blocks, nothing stored or sent; 20 per minute; 400 / 403 / 413 / 429 exit 1 with the code
conduyt ai improve-sms (--body "…" | --body-file draft.txt | --json '{"body":"…"}') [--transport twilio|project_blue|whatsapp|fromk]   # AI rewrite of one text, checked by the server before it is returned (links, times, prices, opt-out lines and merge fields kept as written); an opt-out-only draft is refused 422 ai_rewrite_rejected before any AI credit is spent; prints { body }; nothing is sent or saved
conduyt messages minimum-grade   # the admin's Message check minimum grade to send (settings.messageCheck.minimumGrade): enabled, sms / email minimum (A-F, 0-100 or null), adminOverride; groundwork, stored but not enforced yet; owner / admin only (anyone else sees visible: false)
conduyt messages set-minimum-grade [--sms A|B|C|D|F|0-100|none] [--email ...] [--admin-override on|off] [--enabled on|off]   # sends the whole block with the settings revision it read; --enabled on is refused 400 minimum_grade_not_available_yet; 403 forbidden for a non-owner / non-admin; all exit 1 with the code
conduyt sms providers options   # the workspace's active SMS providers, redacted: [{ id, name, color }] (needs email_templates.view or settings.view)
conduyt templates list [--channel email|sms] [--active true]   # email / SMS templates; each row carries bodyMode (blocks | html); the pasted html is not repeated in a list row
conduyt templates get <id>   # one template with its full content (an HTML-mode template answers its pasted source in `html`)
conduyt templates create --name "Promo" --channel email --subject "Hi" --body-mode html --html-file email.html   # pasted HTML (email only, 102,400 bytes at most); blocks: --body "…" [--body-html …]; 400 codes (html_too_large, html_script, html_conditional_comment, html_office_markup, html_duplicate_attribute, template_corrupt, …) exit 1 verbatim
conduyt templates update <id> [--name …] [--body-mode html --html-file email.html] [--active false]   # partial update
conduyt dialer history --q "refund" --recorded-only [--disposition X] [--user <id>] [--from D] [--to D] [--mine]   # QA search of the call log: per-row `match`, meta.incomplete (a lower-bound total when a number search is capped), stats, per-row `audioDiagnostics` (what the softphone reported about the call's audio: warning / cleared / gap rows, [] when nothing); 200 per page
conduyt dialer history --unmatched --line <number>   # only calls no contact is linked to, only inbound calls to our line (the unknown-caller counter's list)
conduyt dialer unknown-callers --line <number> --since <ISO instant>   # the counter: { line, since, total, unmatched } (since = the start of day, within 31 days)
conduyt dialer link-call <callId> --contact <id> [--attach] [--dry-run]   # link a contact-less call to a contact; --attach adds its number to the next free phone slot; --dry-run writes nothing
conduyt contacts create --first X --call <callId>   # the lead for a contact-less inbound call, linked in the same transaction (the server sets source Inbound Call and the owner)
conduyt dialer calls --status voicemail --q "+1555…"   # the recordings / voicemail list with the same search (100 per page)
conduyt dialer recording download <callId> [--voicemail] [-o file] [--force]   # stream the call audio to a file (named by the API when no -o); never over an existing file without --force
conduyt activities export --out activities.csv [--type <t>] [--search <q>] [--contact-id <id>] [--deal-id <id>] [--from-date YYYY-MM-DD] [--to-date YYYY-MM-DD] [--overwrite]   # GET /activity/export.csv: WRITES a CSV file (the Activity page's Export columns) and follows the server's continue trailer by itself (same filters plus the cursor, no repeated header); all or nothing: the file appears only when the last part says complete (413 export_too_large over 100,000 rows prints its code and hint; too_large at 50 MB, a part cut 3 times or any refusal leave no file); progress on stderr, stdout { saved }; never over an existing file without --overwrite
conduyt privacy export <id>             # GDPR data-portability export (owner/admin)
conduyt privacy forget <id> --confirm FORGET  # GDPR erasure — IRREVERSIBLE, owner only
conduyt reply-capture status            # inbound reply capture: state, DNS records, provider health
conduyt reply-capture setup             # create the receiving subdomain (--domain optional)
conduyt reply-capture verify            # promote it to live once DNS is confirmed
conduyt reply-capture remove --confirm REMOVE  # remove capture — replies to already-sent email are lost
conduyt integrations calendly status   # the Calendly connection: event types, selection, live sync (on | pending | plan_refused), import progress, last booking / error (integrations scope; connecting is browser-only)
conduyt integrations calendly import-progress [--connection-id <id>]   # the import alone: status, eventsSeen, imported, skipped, error
conduyt integrations calendly event-types   # re-read the event types from Calendly (the picker list)
conduyt integrations calendly set-event-types --uri https://api.calendly.com/event_types/<id> [--uri …] | --none   # ONLY these sync; the first save or an added type starts the silent import
conduyt integrations calendly disconnect [--connection-id <id>]   # removes the webhook and the connection; appointments stay
conduyt integrations wordpress-forms status   # is any intake address active, and how many ({ hasActive, activeCount }; count only, read-only, integrations scope)
conduyt integrations wordpress-forms list    # WordPress form intake addresses: full URL of every active one, received counts
conduyt integrations wordpress-forms create --name "Contact page" --default-tag "Website lead"   # prints the full URL
conduyt integrations wordpress-forms revoke <id>   # the address answers 404 from now on; the row is kept
conduyt lifecycle set-booking-creates-own-card --enable   # a booking creates its own card owned by the host instead of reusing the contact's open intake card (--disable = default; `lifecycle settings` shows bookingCreatesOwnCard)
conduyt api GET /api/v1/companies       # raw authenticated request (escape hatch)
conduyt config show                     # show resolved config (key masked)
```

Pass `--input '{"...":"..."}'` to `insights` and `--body '{"...":"..."}'` to `api` to send a JSON payload.

All output is JSON, ready to pipe into `jq`.

## Error output grammar

A refused call (HTTP 4xx/5xx) prints one line on stderr and exits 1:

```
Error: Conduyt API <status>: <server message>[ [Retry-After: <N>s]][ <details>]
```

`[Retry-After: Ns]` appears only when the server sent the header (shown, never acted on: nothing is retried; the one exception is the finalize POST of the upload convenience commands `files upload` and `chat upload`: on a 409 `upload_in_progress` only, at most 4 total attempts, the Retry-After is honoured (capped at 10 s, 5 s when absent or unreadable); finalize is idempotent on the server for the same upload id, so a repeat cannot double-finalize). `<details>` appears
only when the body had more than `error`: it is ONE JSON object and the FINAL token. To extract it, try each `{` from the left
until the rest of the line parses as JSON (a server message may itself contain a brace). Scalars (`code`, revision) come
first, nested objects whole; `HealthFixRefusal.row` is always whole, any other nested object too large for the bound is left
out and named in `_omitted`. Every HTTP refusal takes this path (JSON calls, text exports and streams alike). The settings-conflict commands merge their hint and the current settings INTO that final object (`{...details, hint, current}`), never after it. Example:

```
Error: Conduyt API 503: Contact merge in progress [Retry-After: 5s] {"code":"merge_in_progress"}
```

The contact merge route (`POST /contacts/merge`, command `contacts merge`) answers a retryable 503 with `Retry-After` and the code `merge_contacts_busy` (a contact stayed busy for the whole lock budget) or `merge_budget_exhausted` (the request's time budget ran out), nothing changed. A command that reaches it prints the refusal in this grammar, exits 1 and does not retry; run it again after the stated seconds.

## License

MIT
