Command-line Interface
fob-mdm does from the terminal everything the MDM API does: define objects and fields, create and edit golden records, read their history, connect apps, and check and fix conformance. It prints tables for people and JSON for scripts and AI agents.
The same package is also a JavaScript client you can import in workers and agents. See JavaScript Client.
Install
npm install -g @finopsbricks/fob-mdm
It needs Node.js 18 or later. The package is @finopsbricks/fob-mdm on npm, and the source is at github.com/finopsbricks/fob-mdm.
Check it works:
fob-mdm --version
fob-mdm getting-started
Set up a profile
The CLI uses an API key saved as a profile, one per organization. It doesn't read keys from environment variables or flags.
- In the app, open Settings → API Keys and create a key. Choose Full Access if you'll change data; Read Only is enough to look.
- Save it. You'll be asked for the key and the secret, and the key is checked before it's saved:
fob-mdm config profiles add acme
✔ API key (fob_mdm_…) fob_mdm_xxxxxxxxxxxxxxxxxx
✔ API secret ************************
Saved profile 'acme' (https://mdm.finopsbricks.com). The key works.
It is the current profile.
Every command now uses acme. If you have more than one organization, add a profile for each, then switch with fob-mdm config profiles use <name>, or pick one for a single command with --profile <name>:
fob-mdm records list --object vendor --profile acme-labs
Profiles are kept in ~/.fob/fob-mdm/config.yml, readable only by you. See config.
Command pattern
fob-mdm <resource> <action> [target] [options]
The action is always named: fob-mdm objects lists the actions for objects rather than guessing one. Every level has --help:
fob-mdm --help
fob-mdm records --help
fob-mdm records edit --help
| Resource | Actions | What it's for |
|---|---|---|
| objects | list, show, create, edit, delete | The kinds of record you keep, such as Vendor |
| fields | list, show, create, edit, delete | An object's attributes, such as Name or GSTIN |
| records | list, show, create, edit, delete, history | Golden records, their values and their history |
| integrations | list, show, create, edit, delete, pull, lookups | Connected apps, and the links between their records and yours |
| contracts | list, show, create, edit, delete | Which fields an app's copy must match, and how drift is fixed |
| conformance | run, status, enforce, confirm, events | Find where apps differ from golden, and fix it |
| config | profiles add, profiles list, profiles use, profiles remove | Saved API keys |
Objects can be given by id or slug (vendor). Values are set by field key: --set bank_ifsc=HDFC0005678.
A first session
fob-mdm objects list
fob-mdm fields list --object vendor
fob-mdm records list --object vendor --where gstin=29ABCDE1234F1Z5
fob-mdm records edit 100 --set bank_ifsc=HDFC0005678
fob-mdm records history 100
100 stands for a record id: take a real one from records list.
To connect an app and check it matches, follow Check and Fix Drift.
JSON output
Every command that reads, creates or changes data takes --json and prints the API's response instead of text, ready for jq or an AI agent. (delete and the config commands don't.)
fob-mdm records show 100 --json | jq '.values.bank_ifsc'
A list prints one page (100 rows unless you pass --limit, up to 500) as { "data": [...], "page_context": {...} }, the same as the API. When there are more pages, a hint saying so goes to stderr. Add --all to fetch every page, up to 15,000 rows; with --json it then prints just the array of rows.
Data goes to stdout and hints, prompts and errors go to stderr, so piping the output never picks up anything else.
Deleting
delete asks before it deletes. Without a terminal to ask on, such as in a script or an agent, it refuses and says to pass --yes:
fob-mdm records delete 100 --yes
Deleting a field retires it instead: its values and history stay.
Errors
A failed command prints the error to stderr and exits with code 1. A command that worked exits 0. Errors from the API show their code and the details that say what to fix:
$ fob-mdm records edit 100 --set ifsc=HDFC0005678
Error [VALIDATION_ERROR]: Unknown field: ifsc
unknown: ["ifsc"]
fields: ["name","gstin","bank_ifsc"]
Common ones:
| Error | What to do |
|---|---|
No profile set up. Run fob-mdm config profiles add <name>, then try again. | Add a profile, as in Set up a profile |
Profile 'acme-labs' doesn't exist. Run fob-mdm config profiles add acme-labs. | Check the name with fob-mdm config profiles list, or add the profile |
Error [NOT_FOUND]: Record not found | The id or slug isn't in this profile's organization. Find it with fob-mdm records list --object vendor (or objects list, fields list) |
Error [UNAUTHORIZED]: Invalid API credentials | The key was revoked or mistyped. Create a new one and run fob-mdm config profiles add again with the same name |
Error [FORBIDDEN]: API key lacks records:edit permission | The key is Read Only. Create a Full Access key |
Error [FIELD_RETIRED]: Retired field: bank_ifsc | The field was retired. List the live ones with fob-mdm fields list --object vendor |
error: required option '--object <object>' not specified | Add the option. --help on the command lists them |
Set FOB_DEBUG=1 to print the stack trace as well.
Related
- JavaScript Client: the same calls from code
- API Authentication: API keys and their permissions
- Check and Fix Drift: the conformance loop, step by step
Using an AI agent? Give it the raw Markdown of this page, or the docs index.