Automating Metabase administration with the CLI and API

Scripting Metabase administration with API keys and the CLI can remove repetitive work, but Metabase does not version its API, so every script needs ownership, testing and an upgrade check.

On this page

When automating Metabase administration with the API makes sense

Automation makes sense once your admin team is handling user onboarding, group changes, permission sets and content moves by hand across an instance that keeps growing. API keys and the Metabase CLI can script these tasks, but the Metabase API is not versioned, so every script needs a named owner and a test run before each Metabase upgrade. This page covers which administrative tasks are worth scripting, what the CLI is responsible for compared with the API, and how upgrade risk should shape the way you write and store those scripts.

The tasks that usually repay scripting are repeatable ones with a clear input: creating or deactivating users from an approved roster, adding people to groups, applying the same collection and data permissions to new teams, and moving or reorganizing saved content. The CLI is better suited to instance-level operations run from a shell, while the API is what your scripts call during routine work. Before you write anything, confirm with your own environment which of these operations your plan supports, because the Metabase pricing page shows that SSO, row and column level permissions and usage analytics are limited to the Pro and Enterprise plans rather than Open Source or Starter.

Metabase states that it does not version its API and that endpoints rarely change, but that code relying on the API may still need updates. Treat that as a standing maintenance cost: record which endpoints each script calls, pin the Metabase version you tested against, and rerun the scripts in a non-production instance before each upgrade. Scripts that touch permissions or deactivate accounts deserve the most review, since a silent change in response format there can grant access or lock out administrators. The Metabase API keys documentation is the starting point for how keys are issued and scoped.

Which admin tasks to script and which to keep manual

User and group changes are the most repeatable administration work, so they are the most common candidates for scripting. Onboarding a batch of people into known groups, or deactivating accounts from a leaver list, follows a predictable pattern that a script can apply the same way every time. The risk lies in the source of truth: if the script reads from a stale spreadsheet or a partial directory export, it will grant or remove access at scale. Group membership is also tied to permissions, so a mistake here propagates quickly.

  • Batch onboarding: A script can create users and add them to existing groups from an approved export of your identity records.
  • Offboarding: Deactivation driven by a leaver list is well suited to scripting, provided the list comes from HR or your identity provider.
  • Group membership changes: Adding or removing members from groups that already have defined permissions should be scripted with a dry run and a logged diff.
  • Group creation and renaming: Treat these as reviewed changes, because group names and structure often feed permission decisions and audit reports.
  • Admin rights: Granting administrator status should stay a manual, approved action with a named owner.

Before running any user script, confirm which identity source is authoritative, whether SSO group sync is already managing membership, and whether your plan includes the directory features you rely on.

How a script reaches Metabase through an API key

The flow starts in an automation job or CI pipeline that reads its API key from a secret store, which sits inside the trust boundary. The job sends authenticated requests over the admin network path to the Metabase API on the instance. The instance applies the change, writes it to the application database and records it in the audit trail. Check who owns the key, which network path is allowed, and whether the audit trail records the key's identity.

Shows where the API key lives, the admin path it travels, and where changes are stored.

Setting up an API key and a first scripted change

This sequence gives a scripted Metabase administration task its own identity, a scoped key and a tested path from a read-only check to one controlled write. Each step ends with a check so the team can confirm the key, the tooling and the change before automation runs against production.

  1. Create a dedicated automation account

    An administrator creates a separate user for the script in the Metabase admin settings, not a personal login, so its actions show up under its own name in the audit trail. Put the account in only the groups the task needs, and record who owns it and why it exists. Done when the account appears in the People list, signs in only through the intended path, and shows the expected group memberships.

  2. Generate a scoped API key

    Under the admin settings for API keys, create a key for the automation account and assign the narrowest group or permission level the task requires. Give the key a name that states its purpose and its owner. Done when the key is listed with its name and group, and a test request made with it returns the account's own identity rather than an error. Metabase does not version its API, so record the Metabase version the script was written against alongside the key.

  3. Store the key in a secrets manager

    Move the key into your organization's secrets manager and reference it from the script's runtime environment, so it never appears in source control, shell history or job logs. Restrict read access to the service that runs the script. Done when a search of the repository and CI logs finds no copy of the key and the script retrieves it at run time from the vault.

  4. Install the Metabase CLI if needed

    If the task uses the Metabase CLI rather than direct HTTP calls, install it on the machine or runner that will execute the script, pin the version to match your Metabase instance, and confirm which commands it exposes before relying on them. Check the CLI documentation for the supported commands and for how it authenticates. Done when the CLI reports its version and a help command runs without error on the test host.

  5. Run a read-only call on a test instance

    Point the script at a test Metabase instance that holds a copy of production configuration, then run a read-only request such as listing users, groups or collections. Compare the output with the same list in the admin UI, using the same key. Done when the returned counts and names match what the admin UI shows, and the call fails cleanly when the key is wrong or revoked.

  6. Apply one write call on the test instance

    Make a single, small write on the test instance, such as adding one test user to one group or renaming one test collection. Record the object ID and the state before the change. Done when the write returns success and the admin UI shows the new state, and the audit trail or activity view records the change under the automation account. Keep the before state available so the change can be reversed.

  7. Verify the result in the admin UI

    Before any production run, a administrator checks the changed objects directly in the admin UI and confirms that no other objects were affected by comparing a read-only listing before and after. Confirm that the key's scope still matches the task and that no unexpected permissions were granted. Done when the reviewer signs off the test run in the change record and the production run plan names the same key, the same scope and the same rollback steps.

Why an unversioned API makes scripts a maintenance commitment

Metabase does not version its API and says endpoints rarely change, but code that relies on it may still need updates. The cards below cover where that gap shows up in practice: after upgrades, in silent behavior changes, in API key ownership and in the testing you run before each release.

Breakage after each upgrade

Every Metabase upgrade is a point where a script written against today's endpoints can stop working. Because there is no versioned API contract to pin against, a request that succeeded on one release may fail, return a different shape or require a new parameter on the next. Keep a list of every endpoint your scripts call, so that after each upgrade you know which automation to re-check first.

Upgrading Metabase docs

Silent behavior changes

Some of the most costly problems do not return an error. A script may still succeed while granting a different permission, adding a user to an unexpected group or skipping a collection it used to touch. Compare the resulting permission graph and group membership against an expected baseline after each run, rather than trusting the HTTP status alone.

API key ownership and lifecycle

An API key acts with the access of the account it is tied to, so a key created by a departing administrator can outlive their role. Record who owns each key, which scripts use it, what group permissions it inherits and when it was last reviewed. Plan rotation and revocation as part of the script's maintenance, not as an afterthought.

API keys docs

Named owner for each script

Automation without an owner tends to break at the worst time, usually during an upgrade freeze. Assign a named team member to each script or CLI task, with a short runbook covering its purpose, inputs, the Metabase versions it has been tested against and who approves changes. Ask whether your organization already has a process for maintaining internal tooling that can absorb these scripts.

Staging test before every upgrade

Run an automated test suite against a staging Metabase at the same version you plan to upgrade to, before touching production. The suite should create and remove a test user, group, collection and permission, then check the results. Failures found on staging become a known list of script changes, rather than an incident on the production instance.

Metabase version support

Version pinning and change tracking

Store scripts in version control and record which Metabase release each change was verified against. When a script fails after an upgrade, the commit history shows what changed on each side. Ask your team how they will decide whether to fix a script, hold the upgrade or roll back, and confirm the rollback path for the application database before you begin.

Questions teams ask before automating Metabase administration

Can our own team automate Metabase administration without a partner?

Yes, most teams with an engineer who knows the Metabase API and a test instance can script routine tasks in-house. The deciding factors are how many tasks you want to automate, whether your team has time to maintain the scripts, and whether anyone on staff owns the API key and its permissions. Start with a small, well-defined task such as provisioning users into a group, then decide whether the same pattern is worth extending. Metabase does not version its API and says endpoints rarely change, but code that relies on it may still need updates, so plan for that maintenance from the start. Review the Metabase CLI docs and the API keys docs before you decide.

What drives the effort of scripting Metabase administration?

Effort grows with four things: the number of tasks you automate, the Metabase plan you run, how thoroughly you test the scripts, and how often you upgrade. Each additional task type, such as groups, collection permissions, data permissions or content moves, adds mapping logic and edge cases to handle. Plan matters because some identity and permission features only exist on Pro or Enterprise, so scripts that depend on them cannot run on a free instance. Test coverage determines how much manual checking remains after every change. Upgrade frequency matters because Metabase LTS releases are supported for 14 months and non-LTS releases usually reach end of life after 2 months, so scripts may need checking more often than you expect.

What must our team provide before a partner starts automation work?

Your team should provide a non-production Metabase instance that matches the production version, plan and connected data sources as closely as possible. You also need to name an owner for the API keys, decide how those keys are stored and rotated, and confirm which accounts are allowed to run automation with admin rights. A change approval process matters because scripts that change permissions or delete content can affect many users at once. Provide a written list of the tasks in scope, the current permission model, and the people who approve changes to production. Ask any partner to confirm how they will test against your environment before anything runs in production.

Will our scripts keep working after a Metabase upgrade?

They may not, so you should expect to test them at every upgrade. Metabase does not version its API, and while endpoints rarely change, the docs note that code relying on the API may need updates. Upgrades also run application database migrations automatically, and the docs recommend backing up the application database first. Build a regression run of your scripts into the upgrade process, compare results on a staging copy, and keep the previous version available so you can roll back. Confirm the exact behavior of each endpoint you depend on against the release you are moving to, rather than assuming the previous behavior still holds.

How should we secure API keys used for automation?

Treat each API key as a privileged credential. Create keys for a specific purpose, give them the narrowest group permissions that work, store them in a secrets manager rather than in scripts or repositories, and set a rotation and revocation process with a named owner. Log which script uses which key so that a revoked or leaked key can be traced quickly. Because an admin-level key can change users, groups and permissions, ask whether your security team needs to approve its creation. Check the API keys docs for how keys are created and managed in your version.

How should we scope a partner engagement for Metabase automation?

Scope the engagement in writing before work starts, listing each administration task, the systems involved, the Metabase version and plan, the test environment, and the deliverables such as scripts, documentation and a runbook. DeployOpen plans and delivers most engagements as fixed-scope work, so the written scope sets what is included and how it is accepted. Ask for a quote that separates the initial build, the testing, the handover and any recurring maintenance. Add a clear list of exclusions, such as changes to your identity provider or data sources. A quote follows from the written scope, and the scope should name who approves production changes.

When is automating Metabase administration not worth the effort?

Automation is rarely worth building for a handful of one-time changes or for an instance with few users and little turnover. In those cases, a documented manual procedure is simpler to maintain and easier for auditors to follow. Automation pays off when the same tasks repeat often, such as onboarding users into groups, applying consistent collection permissions across teams, or reporting on content. Weigh the upkeep of scripts against the time saved, and remember that scripts add a dependency on an API that has no versioning promise. Document the manual process either way, so the team can still operate Metabase if the scripts break.

Securing API keys, scripts and admin actions

Scripts that call the Metabase API can create users, change group membership and edit permissions, so they carry administrator power. The cards below cover the controls that keep that power contained, from how each key is scoped and stored to how changes are reviewed and recorded.

Scope and rotate each key

Create a separate API key for each script or job rather than sharing one administrator key across tools. Name keys after their purpose so you can tell which job made a change. Set a rotation schedule your team can actually follow, and confirm in your own instance how keys are revoked and how long a revoked key stops working. A key that only reads usage data should never be able to edit permissions, so review what each automation really needs before you issue it.

API keys docs

Store keys in a secrets manager

Keep API keys in a secrets manager that your platform team already operates, and inject them into jobs at run time. Never commit them to a repository, paste them into a wiki, or place them in shell history or container images. Confirm who can read each secret, log access to it, and remove the secret when the job that used it is retired. Scan repositories for accidental commits, since a key in version control stays exposed even after it is deleted from the latest commit.

Separate staging and production keys

Use different keys and different Metabase instances for staging and production automation. A script tested against a staging instance should not hold a production key, and a copy of production data should not be needed to test a permission change. Confirm which instance each key points to in its configuration, and make the production key available only to the pipeline stage that is allowed to deploy to production.

Review permission changes before they run

Route scripts that edit groups, data permissions or collection access through the same review you use for infrastructure code. Require a second person to approve a dry-run report listing the users and groups affected. Keep the script in version control so every permission edit has an author, a reviewer and a commit that shows what changed. Treat bulk changes to administrator group membership as the highest-risk category and require explicit sign-off for them.

Audit automated changes

Ask whether your plan includes usage analytics and auditing before you rely on Metabase's own record of who changed what. According to the Metabase pricing page, that feature is limited to the Pro and Enterprise plans, so open source and Starter installs need another record. Plan to log each API call from your automation with the job name, the key used and the target object, and ship those logs to a store your security team controls.

Metabase pricing

Confirm controls against your plan

Some controls depend on the plan you run. The pricing page places SSO, row and column level permissions and auditing in Pro and Enterprise, so an automation that depends on them must be checked against the edition you have licensed. Before you build, list each control your security policy requires, confirm which plan provides it, and record the result so an edition change does not silently remove a control.

Designing scripts that survive Metabase upgrades

Treat every administration script as software that will outlast the Metabase version it was written against. The core habit is to keep all automation in version control, so each change has an author, a review and a history that you can line up against the Metabase release in use. Wrap each API call in a small function with its own tests, so that when a response shape changes, the fix lands in one place rather than in every script that touches that endpoint. Metabase does not version its API and says endpoints rarely change, but it also notes that code relying on the API may need updates, so you should not assume a script written today will still run unchanged after an upgrade.

Run the test suite against a staging copy of the instance before every Metabase upgrade, not after. The staging copy should be restored from a recent backup of the production application database and run the same Metabase version you plan to move to. Record which Metabase version the suite last passed against, and pin that version in your deployment configuration so that a casual image update cannot move production ahead of the tested state. When a test fails, decide whether the script or the platform is wrong before changing either, and keep the failing case in the suite so the regression stays visible.

The upgrade steps themselves, including application database backups, migration behavior and rollback, are covered on the Metabase upgrade pages, so this section does not repeat them. Before you rely on the suite as a gate, confirm with your own environment which accounts and API keys the scripts use, and make sure the staging copy does not send email or write to live data sources. Ask your DeployOpen or internal reviewer to check that the test coverage includes the permission and group changes your governance process depends on, since those are the changes an auditor is most likely to ask about.

How DeployOpen scopes and supports Metabase automation

DeployOpen plans, builds, documents and supports Metabase automation inside your own infrastructure, starting from a written scope that names the admin tasks, API keys and permission model involved. Each script or CLI workflow is tested against your instance and handed over with the operating notes your team needs to run it.

How we scope

  • Engagements are fixed-scope, with the admin tasks to automate agreed in writing before work starts.
  • The scope lists which users, groups, permissions and collections the scripts may change, and which stay manual.
  • We confirm your Metabase plan, since SSO and some permission features depend on Pro or Enterprise.
  • The written scope names the API key ownership model and who approves changes to automated tasks.

How we build

  • Scripts use API keys scoped to a dedicated service account rather than a personal administrator login.
  • We run each workflow against a non-production Metabase instance before any change reaches production.
  • Automation is kept in version control with a record of the Metabase version each script was tested against.
  • Scripts include error handling, logging and a dry-run mode for bulk changes to users and permissions.

How we hand over

  • Deliverables include the scripts, a runbook for each task and the list of endpoints each script depends on.
  • Handover covers how to rotate and revoke API keys and where the credentials are stored.
  • Documentation records the test results and the steps to repeat them after a Metabase upgrade.
  • Your team receives a checklist to review automated changes against group and permission design.

How we support

  • Ongoing support and upgrade testing are available as a retainer, covering scripts after each Metabase release.
  • Retesting of automation runs after upgrades, since Metabase does not version its API and endpoints can change.
  • Your team confirms the support boundary, response expectations and who owns script changes before the retainer starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.