Skip to main content

CLI command reference

CLI command reference

Install with npm install -g @codemagic/patch-cli (Node.js >=20), then run cmpatch help for grouped topics, or cmpatch <command> --help for full flags.

React Native apps use cmpatch for server setup, sign-in, apps, releases, and diagnostics.

On a terminal, both CLIs print one line after a command when a newer version is on npm. The check runs in the background, once a day (hourly until one succeeds), and only asks registry.npmjs.org for the package's latest version; the request carries no account, project, or machine identifier. It never runs in CI, when output is piped, or with --format json. CMPATCH_NO_UPDATE_CHECK=1 turns it off, as does NO_UPDATE_NOTIFIER=1.

Auth and config​

CommandDescription
cmpatch login / logout / whoamiBrowser sign-in via the dashboard (or --token) / sign out / identity
cmpatch token create | list | revokeManage personal access tokens (cm_pat_…); revoke by --token-id or by the exact --name given at creation (confirms unless --yes). token create needs a browser login, not --token
cmpatch config list | get | set | unsetStore defaults: server-url, team, team-id
cmpatch team list | showList the teams you can see / show one (--team, --team-id, or the stored default)
cmpatch initLink a project to a server and write codemagic-patch.config.json; interactively install a server or enter an existing URL, sign in after a new install, create or select an app for each platform, then wire the SDK (--skip-wire for the link only)
cmpatch wireWire the SDK into the linked app: install the package, write each platform's deployment key and URLs, hook native bundle selection, add the build metadata step, export the root through Patch.wrap; shows the plan first (--dry-run --diff to only look) and exits 2 when steps remain for you
cmpatch contextShow the effective resolved context; add --remote to include server SDK configuration (downloadBaseUrl)

A --token login (or CODEMAGIC_PATCH_TOKEN) cannot run token create, member add, member invite, member update, member provision, member rotate-token, or app transfer; sign in with cmpatch login without --token for those.

init now returns the SDK wiring result, so it can exit 2 with the connection saved but setup incomplete. Existing scripts that only need to link the project should use init --skip-wire. It also accepts every wire flag; see cmpatch wire --help.

For unattended wiring, use --yes and, if the working tree has uncommitted changes, --allow-dirty. Request any needed CocoaPods installation with --pod-install on macOS; on Linux that step remains incomplete even with the flag. A project in React Native's SwiftPM mode has no CocoaPods step: wire never runs pod install there and ignores --pod-install.

The build metadata step (build-metadata in --format json) needs SDK 0.8.0 or later; see Build metadata step. In a bare project wire inserts it in every app target that has the Bundle React Native code and images phase and in the app module's Gradle script, and reports it for you to finish when the bundle phase is missing or unrecognised, or User Script Sandboxing is on. In an Expo project that generates its native directories wire edits nothing for it: the SDK's config plugin adds it at the next npx expo prebuild.

Local evaluation and self-hosting​

local-eval runs the evaluation stack on this machine. If you want to try an OTA with a ready-made app first, run cmpatch demo to build the bundled app and watch an OTA fix apply; the demo handles local sign-in and setup. See Local quickstart for the full walkthrough. The install, upgrade, backup, and restore commands run the repository's authoritative self-host scripts over SSH; on a Fly install they run through flyctl from this machine instead. The guided installer defaults to bundled Postgres and Silo. A separate database is for backups and point-in-time recovery, and is needed for disk space around a few million daily active users. Point the installer at a Postgres database you already run with the connection string that ends in sslmode=require, and allow the server's IP. External R2/S3/GCS storage supports automatic and guided first-install setup.

CommandDescription
cmpatch selfhost local-eval [up|down|status]Start, stop, or inspect the localhost evaluation stack; up is the default
cmpatch demo [--platform ios|android] [--checkout <path>]Run the guided OTA demo against the local evaluation stack; reuse its checkout, sign in, build the app, and publish a fix after confirmation
cmpatch selfhost install [user@vps]Check and prepare a server, then run the guided install with DNS, OAuth sign-in (GitHub, Bitbucket Cloud, or GitLab), and optional CDN setup
cmpatch selfhost install --ngrokInstall on this machine, reachable at your ngrok account's https:// address, for testing on real devices without a domain
cmpatch selfhost install --flyDeploy Patch onto Fly.io from this machine; --register records an existing Fly install on this machine
cmpatch selfhost upgrade [user@vps]Move the server checkout to the newest release and run the guarded backup-and-update workflow with its published image; on Fly, snapshot the database (when cmpatch created it) and deploy the newest release
cmpatch selfhost backup [user@vps]Take a mode-aware backup; add --download to copy it to this machine; on Fly, save the database dump on this machine
cmpatch selfhost restore [backup] [user@vps]Select or upload a backup, take a safety backup, and restore the components it contains; on Fly, restore a Fly backup from this machine

cmpatch selfhost install --no-telemetry turns off the daily anonymous usage report the server would otherwise send (it writes SERVER_TELEMETRY=false); on an installed server, pass it with --repair.

After a first install succeeds, the CLI asks once per machine how you heard about Codemagic Patch. The question is optional: Enter skips it and sends nothing, and an answer sends only the choice you pick, the install method (ssh, ngrok, or fly), and for Other the text you type. --no-telemetry and DO_NOT_TRACK=1 turn the question off too, and a run that cannot prompt never asks.

Scripted install​

Every answer has a flag, so the same install runs unattended. Add the two DNS records and let them resolve first. An unattended run does not prompt for them, and the install fails when the server cannot obtain its certificates.

# the secret travels in the environment, never on the command line
export GITHUB_OAUTH_CLIENT_SECRET=<github_client_secret>

cmpatch selfhost install ubuntu@203.0.113.7 \
--non-interactive \
--api-domain updates.example.com \
--storage-domain storage-updates.example.com \
--email admin@example.com \
--github-oauth-client-id Iv1.xxxxxxxxxxxxxxxx \
--install-docker

Pass --bitbucket-oauth-client-id and --bitbucket-oauth-client-secret, or --gitlab-oauth-client-id and --gitlab-oauth-client-secret, instead of or as well as the GitHub pair. At least one provider is required. GitLab sign-in has the app settings for gitlab.com and for self-hosted GitLab.

To run the installer on the server itself, clone the repository there and run scripts/selfhost/install.sh with the same domain, email, and OAuth flags. Create the OAuth app yourself:

OAuth App settingValue
Homepage URLhttps://updates.example.com
Authorization callback URLhttps://updates.example.com/auth/callback

The installer writes .env.selfhost with random secrets and refuses to overwrite an existing file. The first boot prepares the default-team.

DNS setup​

--dns-setup auto|manual|cloudflare|domain-connect selects setup-time DNS handling. Interactive auto offers to add the records for you where it can — on Cloudflare, or through Domain Connect when your DNS provider advertises the Patch templates — with a manual alternative; where it cannot, it prints the records without asking. Unattended auto uses manual DNS. For Cloudflare, supply a setup-only token through CMPATCH_DNS_CLOUDFLARE_API_TOKEN with Zone Read and DNS Edit permissions. Existing records require interactive approval before replacement. Domain Connect requires browser approval.

--public-ip <address> supplies the public IPv4 address the DNS records point at, for a server that cannot report its own — one behind NAT (Oracle Cloud, a VM behind a router) or IPv6-only. The wizard asks for it when it needs it; a scripted run with --dns-setup cloudflare must pass the flag.

ngrok flags​

FlagsPurpose
--ngrokInstall on this machine at the address your ngrok account comes with; takes --email and the sign-in flags, and reads the authtoken from NGROK_AUTHTOKEN or asks for it
--ngrok-domain <domain>The domain to install on, instead of whichever address ngrok picks: your account's own dev domain (free plans included) or one a paid plan has reserved
--checkout <path>Run from this checkout of the repository instead of the copy the CLI keeps
--start-dockerStart Docker on this machine without asking

An ngrok install takes no user@vps and none of the DNS, CDN, or external storage flags. Details: Local quickstart.

Fly flags​

FlagsPurpose
--company, --fly-region, --fly-orgApp and bucket names, region, and Fly organization for install --fly
--create-database, --database-urlCreate a Postgres machine on Fly, or use a database you already run
--registerRecord an existing Fly install on this machine without creating anything; with --non-interactive, add --database-app <name> or --external-database
--install-flyctl, --install-tigrisInstall a missing flyctl or Tigris CLI without asking; a --non-interactive run needs them when the tool is missing
upgrade --tag <tag>Deploy this codemagic-patch-server-v* release instead of the newest
upgrade --redeployAllow a target equal to the release already running; with --tag <running tag> it deploys that release again
restore <backup> --yesRestore the named backup without the confirmation prompt

--image <ref> and --build-from-source work on install and upgrade, Fly included: the first runs a server image you name instead of the release's published one, the second builds it (on the server, or on Fly's remote builder) instead of pulling it. A build on the server needs at least 2 GB of memory.

upgrade shows its plan and asks before it changes anything, on a server and on Fly; --yes skips the question, and a run that cannot ask (--non-interactive, CI) needs it. An install still on the default branch is moved onto the newest release tag and its published image.

On a server, upgrade pulls the target server image and runs that image's own schema check before it asks; --skip-schema-check upgrades without it, which is unsafe and only for a database the check cannot read or an image from before the check.

On Fly, upgrade refuses --local-image, --skip-smoke, --skip-schema-check, --i-have-a-backup and --ssh-key; backup refuses --download and --ssh-key; restore refuses --restore-env, --smoke, --skip-smoke and --ssh-key.

External storage install flags​

FlagsPurpose
--storage-mode bundled|r2|s3|gcsStorage choice; bundled is the default
--storage-setup automatic|guidedCreate new resources or use console instructions; complete runtime settings skip provisioning
--download-domainViewer domain for guided delivery; external modes reject --storage-domain
--s3-bucket, --s3-internal-bucket, --s3-regionS3/R2 public/private buckets and region
--s3-endpoint, --s3-force-path-style true|falseExplicit S3-compatible addressing
--s3-access-key-id, --s3-secret-access-keyRuntime credentials; prefer S3_ACCESS_KEY_ID / S3_SECRET_ACCESS_KEY environment values
--gcs-public-bucket, --gcs-internal-bucket, --gcs-credentials-fileGCS buckets and local runtime JSON path
--gcp-project, --gcs-location, --gcp-accountInteractive GCS setup context
--aws-profile, --cloudflare-account-idExplicit setup account selection
--public-base-urlFinal anonymous download URL, including any required bucket prefix
--cloudflare, --cloudfrontDelivery; CloudFront uses the existing distribution/purge-key flags
--skip-storage-checkSkip only the subsequent on-server check; CLI pre-install verification still runs

Setup-only credentials use CMPATCH_R2_SETUP_TOKEN, CMPATCH_AWS_SETUP_ACCESS_KEY_ID / CMPATCH_AWS_SETUP_SECRET_ACCESS_KEY, or CMPATCH_GCP_SETUP_CREDENTIALS_FILE. Their flag equivalents are --r2-setup-token, --aws-setup-access-key-id, --aws-setup-secret-access-key and --gcp-setup-credentials-file; prefer environment/file inputs. These are disposable and are never installer runtime values.

A complete runtime configuration (buckets, credentials, and --public-base-url) skips provisioning. If automatic setup created buckets and then failed, rerun with --storage-setup guided and the printed names. That re-verifies existing resources; it does not resume an API call or delete what it already created. Replacing storage keys later is a manual edit of .env.selfhost. See Configuration reference.

Apps and deployments​

CommandDescription
cmpatch app create | list | show | rename | remove | setting | transferManage apps; app setting shows whether an app requires code signing and changes it with --require-code-signing=<true|false>; move an app to another team with --dest-team (confirms unless --yes)
cmpatch deployment create | list | rename | remove | clearManage deployments

cmpatch-capacitor has no transfer command. To move a Capacitor app, find its ID with cmpatch-capacitor app list, then run cmpatch app transfer --app-id <id> --dest-team-id <id> --yes.

Releases​

CommandDescription
cmpatch release-reactBuild and publish from a React Native project
cmpatch bundleBuild a .cmpatch artifact without uploading
cmpatch release createPublish a pre-built bundle / .cmpatch
cmpatch release list | show | inspectBrowse releases; list --binary-version <version> or --binary-version-prefix <prefix> keeps releases that target that version; inspect --wait to poll
cmpatch release patch | enable | disableEdit metadata / toggle availability
cmpatch release promoteCopy a release to another deployment
cmpatch release rollbackRevert to the previous release

release-react bundles JS, resolves a target binary version, and uploads in one step. For iOS, release-react and bundle detect the binary version from the Xcode application target, excluding extensions. If the project has multiple apps, select one with --xcode-project-file and/or --xcode-target-name. Use --build-configuration-name when configurations have different versions. --plist-file selects a plist directly; --plist-file-prefix selects a prefixed plist in the chosen app's directory. If SDK/architecture conditions affect the detected version, or the project or build settings cannot be resolved, pass --target-binary-version with the installed app's version. cmpatch doctor --platform ios accepts the same selection flags.

Android auto-detection supports a static defaultConfig.versionName and a literal common versionNameSuffix. Simple properties are read from the selected module and its Gradle root. Flavor/build-type version overrides and dynamic expressions require --target-binary-version; the CLI does not evaluate Gradle or CI overrides. For those projects, extract the version from the published APK/AAB.

Metrics​

cmpatch help metrics lists these commands.

CommandDescription
cmpatch deployment metricsPer-release counters for a deployment, with a total row and success rate for the returned page, each package counted once; the total says whether it covers this page or all releases. --format json adds each release's success_rate and that summary, whose coverage is deployment only when the page holds every release
cmpatch deployment timeseriesDaily counters for a deployment, one row per UTC day; --range 7d|30d|90d|1y or --from / --to, --binary-version / --binary-version-prefix; under the table, the range totals with success rate and the last complete day's active devices; --format json adds the per-release series with cumulative Applied counts
cmpatch deployment failuresThe codes under one failure reason (--reason); add --code <code> for that code's top exit reasons and messages, or --no-code for the failures that reported no code
cmpatch deployment failure-eventsSingle failure events for one reason and code (--reason, --code or --no-code); --limit, and --cursor for the next page
cmpatch deployment historyRelease history with per-release metrics, most recent 50
cmpatch release metricsMetrics for one release, with diff and full download counts and sizes, the split by binary version, and failure reasons; --format json includes success_rate, overall and per binary version
cmpatch release failuresdeployment failures for one release
cmpatch release failure-eventsdeployment failure-events for one release

The failure drill-down starts from a failure reason: one listed by cmpatch release metrics, or a key of failure_reasons in cmpatch deployment metrics --format json. For a Capacitor app, pass the IDs from cmpatch-capacitor deployment list or release list as --deployment-id / --release-id.

Webhooks​

cmpatch help webhook lists these commands. What a webhook sends, and how to verify it, is in Webhooks.

CommandDescription
cmpatch webhook createRegister --url for the team and print its signing secret once; --event <type> repeats to limit the events, --description adds a note
cmpatch webhook list | showList the team's webhooks with each one's latest delivery, or show one by --webhook-id
cmpatch webhook updateChange --url, the events (--event, or --all-events), --description, or --status active|disabled
cmpatch webhook removeDelete a webhook and its delivery history
cmpatch webhook rotate-secretReplace the signing secret and print the new one once; the old one stops verifying at once
cmpatch webhook testSend a ping event to check the receiver
cmpatch webhook deliveries | deliveryList deliveries (--status pending|succeeded|failed, --limit, --offset), or show one with the body that was sent
cmpatch webhook redeliverSend a finished delivery again

webhook create, webhook update, and webhook rotate-secret need a browser sign-in. webhook remove and webhook rotate-secret ask before they act; pass --yes in CI.

Members and diagnostics​

CommandDescription
cmpatch member add | invite | provision | rotate-token | list | remove …Team membership and invitations; member rotate-token replaces the token of a service account the team provisioned. member remove, member update, member rotate-token, and member invite-revoke confirm unless --yes
cmpatch doctorDiagnose React Native / Expo setup on configured platforms; optionally verify delivery with --verify-delivery
cmpatch server statusShow the server's own health checks (database, storage, disk, download URL, version), as on the dashboard's Status page
cmpatch fingerprint --platform ios|androidCompute the project's native fingerprint; --format json adds fingerprintEngine, what computed it; --verbose lists the files that fed it
cmpatch fingerprint --artifact <path>Read the fingerprint, embedded bundle hash and binary version a built .xcarchive, .ipa, .apk or .aab recorded

List/metrics commands accept --format table|json.

cmpatch fingerprint --artifact​

Reads CodemagicPatchBuild.json and the binary version from a built app, as described in Fingerprinting. It needs no project, sign-in or server, and never computes a fingerprint in place of a missing record. It cannot be combined with --platform, --project-root or --verbose (exit 2).

--format text and table print one labeled line per field. --format json, the default when output is piped, prints platform, binaryVersion, metadataPresent, fingerprint, fingerprintEngine, embeddedPackageHash, embeddedFileCount, embeddedFiles and sha256 (of the file you passed; null for an .xcarchive directory):

{
"platform": "android",
"binaryVersion": "1.0.0",
"metadataPresent": true,
"fingerprint": "f31360ba2b065d9b83b09e32075b7d783f330413",
"fingerprintEngine": "@expo/fingerprint@0.21.9 codemagic-patch-rules@1 version-normalization@1",
"embeddedPackageHash": "34f5d7cf3077…eeeae61b",
"embeddedFileCount": 1,
"embeddedFiles": ["index.android.bundle"],
"sha256": "781335faecfb…9500eb59f"
}

A binary built without the step exits 0 with metadataPresent: false and null in the record fields. An artifact it cannot read exits 3 with one code and the path, for example unreadable-artifact: /builds/app.ipa: no such file or directory. The codes are unsupported-artifact-type, unreadable-artifact, invalid-artifact, application-not-found, ambiguous-application, missing-binary-version, unsupported-binary-version and malformed-build-metadata. The Android version must be a literal versionName; one that is a string resource reference is unsupported-binary-version.

member remove, member update, member rotate-token, member invite-revoke, and token revoke show what they change and ask before changing access, as app remove does. In CI, when stdin or stderr is not a terminal, with --non-interactive, or with --format json, they exit 2 unless you pass --yes.

cmpatch-capacitor​

CLI for Capacitor and Ionic apps. Install it with npm install -g @codemagic/capacitor-patch-cli (Node.js 20.19+ or 22.12+). It is a 0.x release, so its flags may still change. Run cmpatch-capacitor --help for the command list, or cmpatch-capacitor <command> --help for a command's flags.

CommandDescription
cmpatch-capacitor login / logout / whoamiSign in through the browser (or with --token), sign out, show the current user. --no-browser prints the sign-in URL
cmpatch-capacitor token create | list | revokeManage personal access tokens. token create needs a browser login, not --token. token revoke takes --token-id or --name and confirms unless --yes
cmpatch-capacitor team list | showList the teams you can see and show one, to find what to pass as --team
cmpatch-capacitor config list | set | unsetManage the default server URL
cmpatch-capacitor app create | list | show | rename | setting | removeManage apps (one per platform). app create adds Staging and Production deployments; app setting without a flag shows the current settings
cmpatch-capacitor deployment create | list | rename | remove | clear | metrics | historyManage deployments and view deployment keys and metrics
cmpatch-capacitor release createPublish built web assets. release with no subcommand is the same
cmpatch-capacitor deployment timeseriesA deployment's counters per day, as the dashboard's chart shows them
cmpatch-capacitor deployment failures | failure-events, release failures | failure-eventsBreak failures down by reason and code, and list single failure events, as the dashboard's failure dialog does
cmpatch-capacitor release list | show | inspect | metricsView releases and metrics. release list --binary-version / --binary-version-prefix narrows the list; inspect --wait waits for processing to finish
cmpatch-capacitor release patch | disable | enable | promote | rollbackChange rollout, availability, or metadata, promote, or roll back
cmpatch-capacitor doctorDiagnose why the app may not receive updates; --verify-delivery also checks what is published. Exits 1 when a check fails

Differences from cmpatch​

cmpatch-capacitor
Project configNone. There is no init, context, or codemagic-patch.config.json. Select the app and deployment with --app and --deployment (or --deployment-id), and the server with --server-url, CODEMAGIC_PATCH_SERVER_URL, or config set
PlatformNo --platform flag, except on doctor. Each app is a single platform
Publishingrelease create --bundle-path <dir|zip> uploads a built webDir (or a ZIP of its contents) with index.html at the top level. No build step
Binary version--target-binary-version is required and must be exact. No native fingerprint. See Binary version compatibility
App lookupNames resolve only to Capacitor apps. IDs (--app-id, --deployment-id, --release-id) skip the lookup and are recommended in CI
Output--format text or --format json (raw server response); without --format, text on a terminal and JSON when output is piped. table is not accepted
Not includedServer management (cmpatch selfhost), team members (dashboard Members page). doctor has no --fix

Credentials are resolved in this order: --token, CODEMAGIC_PATCH_TOKEN, then the stored sign-in in ~/.codemagic-patch/credentials-capacitor.json.

Confirmation​

Commands that change what devices receive or delete data (release create, patch, disable, enable, promote, rollback, app remove, deployment remove, deployment clear) show a summary and ask for confirmation. The prompt appears only in an interactive terminal. In CI (when CI is set), when stdin or stderr is not a terminal, or with --format json, these commands fail unless you pass -y / --yes. There is no --non-interactive flag.

Exit codes​

CodeMeaning
0Success
1Server or runtime error (not found, duplicate release, network failure, …), or confirmation declined
2Usage error, missing --yes, not signed in, or token rejected by the server
3Validation error, release processing failed or timed out (inspect --wait), stored sign-in expired or revoked, or browser sign-in denied or timed out
4Account disabled
130Confirmation prompt interrupted (Ctrl-C)