Vapi GitOps
Manage your Vapi voice agents as code. Assistants, squads, tools, structured
outputs, simulations and evals live as YAML and Markdown files in git, and this
repository's CLI syncs them to your Vapi orgs, promotes them from development to
production, and tests every pull request with simulations before it merges.
New to Vapi? Start with the Vapi documentation, then
come back here to manage what you build.
What you get
- Safe sync.
npm run apply pulls the latest platform state before it
pushes, so edits made in the dashboard aren't silently overwritten. Every
deploy writes a snapshot you can roll back to.
- Any number of orgs. Each Vapi org is a folder. Promote resources between
them (dev → staging → production) with credentials and phone numbers bound
per org.
- Tests on every pull request. Simulation suites run against the branch's
own files, with tools mocked and nothing deployed, and report a
Vapi Simulations status that links to the run.
- A field guide to Vapi.
docs/learnings/
collects hard-won gotchas and recipes for assistants, squads, transfers,
voicemail detection, latency and more.
- Ready for coding agents.
AGENTS.md and
CLAUDE.md teach Claude Code, Cursor and Codex how to work in
the repo safely.
How it works
flowchart LR
pr["Pull request<br/>validation and simulation checks,<br/>nothing deployed"] -- merge --> dev
subgraph git["Your git repository"]
direction TB
dev["resources/dev/<br/>assistants, tools, squads…"]
prod["resources/prod/"]
dev -- "npm run promote" --> prod
end
subgraph vapi["Vapi"]
direction TB
devOrg["dev org"]
prodOrg["prod org"]
end
dev -- "npm run apply" --> devOrg
devOrg -. "npm run pull" .-> dev
prod -- "applied by promote" --> prodOrg
You edit files and review changes in pull requests. The CLI turns readable
references (toolIds: [lookup-patient]) into the UUIDs each org uses, so the
same files work in every org.
Why GitOps?
|
Dashboard / Ad-hoc API |
GitOps |
| History |
Limited visibility of who changed what |
Full git history with blame |
| Review |
Changes go live immediately (can break things) |
PR review before deploy |
| Rollback |
Manual recreation |
git revert, then npm run apply |
| Environments |
Tedious to copy-paste between envs |
Same config, different state files |
| Collaboration |
One person at a time. Need to duplicate assistants, tools, etc. |
Team can collaborate and use git branching |
| Reproducibility |
"It worked on my assistant!" |
Declarative, version-controlled |
| Disaster Recovery |
Hope you have backups |
Re-apply from git |
Quick start
1. Get your own copy
Your copy will hold your agents' prompts and configuration, so make it a
private repository. Pick one:
Keep upstream history (recommended). You can pull in future updates with
an ordinary merge.
git clone https://github.com/VapiAI/gitops.git my-vapi-gitops
cd my-vapi-gitops
git remote rename origin upstream
git remote add origin <your-private-repo-url>
git push -u origin main
Use this template. Click Use this template on GitHub for a fresh
repository with clean history. Updates are still possible, but the first one
needs an extra step (see Staying up to date).
Avoid a public fork: it would publish your configuration.
2. Install
You need Node.js 20.12+ or 22.13+ (.nvmrc pins 22) and a Vapi private API
key for each org, from dashboard.vapi.ai/org/api-keys.
nvm use
npm ci
3. Connect an org
npm run setup
The wizard asks for your API key (and detects the US or EU region), a name for
the org's folder (for example my-org), and which existing resources to
download, offering their dependencies too. It creates .env.my-org (your key, gitignored) and
resources/my-org/. Run it again to add more orgs.
Without a terminal (coding agents, CI)
The wizard needs a real terminal. Coding agents (Claude Code, Cursor, Codex, …) and CI
run commands without one, so pass the org name to skip every prompt:
# Option A — a human creates the env file, so the key never passes through the agent
cp .env.example .env.my-org # then paste the private API key into VAPI_PRIVATE_API_KEY
npm run setup -- my-org
# Option B — the key is already exported under the org's own name (for example in your shell profile)
export VAPI_PRIVATE_API_KEY_MY_ORG=...
npm run setup -- my-org
Several orgs, one shell. Every command looks for the org's key in this
order: VAPI_PRIVATE_API_KEY_<ORG> (the org name upper-cased, hyphens as
underscores: acme-dev → VAPI_PRIVATE_API_KEY_ACME_DEV), then
VAPI_PRIVATE_API_KEY, then .env.<org>. Export the per-org name, not
VAPI_PRIVATE_API_KEY: the generic name applies to every org, so one org's
key would be used for all of them. When it overrides a different key in
.env.<org>, commands warn and setup refuses. A CI job that works in one
org can keep using VAPI_PRIVATE_API_KEY.
| Option |
Default |
Meaning |
--region us|eu |
VAPI_BASE_URL if set, else auto-detect (US, then EU) |
Which Vapi API to use |
--resources all|none |
all |
all downloads every resource into resources/<org>/; none only seeds state/<org>/state.json (use when you'll author from scratch) |
The private API key is never accepted as a command-line flag (it would leak into shell history and
agent transcripts). Non-interactive setup also refuses to run if resources/<org>/ or
state/<org>/state.json already exists — use npm run pull -- <org> to refresh an existing org.
4. Make a change and deploy
Edit a file under resources/my-org/ (or start from the
starter example), then:
npm run validate -- my-org # schema check, no network
npm run apply -- my-org # pull the latest, merge, push
Commit the changed files and state/my-org/state.json so your team shares the
same name → UUID mappings. Every pull request runs the same validator for
every org in CI (the Validate resources check), so a config apply would
refuse fails before it merges.
5. Test it
npm run call -- my-org -a my-assistant # talk to it from your terminal
npm run sim -- my-org --suite core --target my-squad # run a simulation suite
To test every pull request automatically, set up PR checks.
Core concepts
- One folder per org.
resources/<org>/ holds that org's resources, in
folders by type (assistants/, tools/, squads/, structuredOutputs/,
evals/, simulations/). Org names are yours to choose (acme-dev,
acme-prod).
- Resources refer to each other by ID. A resource's ID is its path under
the type folder, without the extension:
tools/lookup-patient.yml is
lookup-patient. Never paste UUIDs into resource files.
- The state file maps IDs to UUIDs.
state/<org>/state.json records which
platform resource each file is, per org. It is committed and holds no
secrets.
- Secrets stay out of git. API keys live in
.env.<org> (gitignored) or
CI secrets. Credentials are referenced by name and bound to each org's own
credentials.
- Assistant subfolders group the dashboard. Pushing
assistants/support/intake.yml sets metadata.gitops.folderPath to
support, preserving other authored metadata and sibling gitops keys.
A top-level metadata.folderPath remains a user-authored key. The full
subfolder path is preserved: assistants/support/intake/b.yml sets
metadata.gitops.folderPath to support/intake. Root assistants send
metadata.gitops.folderPath: null to clear any previous folder. This derived key is omitted
on pull and ignored for drift; do not author it in YAML. Moving files still
requires explicit --adopt <new-resourceId>=<uuid> to retain the same platform
resource; an unlinked file otherwise creates a new one. apply uses the same
folder behavior in its push phase.
- Each folder is pinned to its org. The first command that can see which
org a key belongs to records it in
state/<org>/org.json. After
that, every command checks the key against it before any request, and stops
if the key belongs to a different org, so a wrong key can't pull another
org's resources into the folder or push the folder into another org.
apply is the default deploy. It pulls first, so it won't overwrite
changes made in the dashboard since your last pull. pull only syncs down;
raw push skips the pull and is rarely what you want.
| Path |
Committed? |
What it is |
resources/<org>/ |
Yes |
Your resources. Hand-written: this is what you edit |
state/<org>/state.json |
Yes |
Name → UUID mappings for the org |
state/<org>/org.json |
Yes |
The Vapi org the folder belongs to |
state/<org>/local/ |
No |
This machine's baselines for detecting dashboard edits, and pre-deploy snapshots for npm run rollback |
.env.<org> |
No |
API key and generated binding IDs |
Everything under state/ is written by the engine. Don't edit or delete it by
hand: without state.json the next push creates every resource again as a
duplicate. state/README.md says what each file is.
More detail: How the engine works.
Commands
| Command |
What it does |
npm run setup |
Connect an org: create .env.<org> and resources/<org>/ |
npm run validate -- <org> [--strict] |
Check resource files offline, including undefined squad variables (variable-undefined); --strict blocks on that warning. transfer-number-liquid always errors on Liquid in transfer destination numbers; use per-practice literal numbers (see examples/nhs-shared-squads). |
npm run apply -- <org> |
Deploy: pull, merge, then preflight and push (the default) |
npm run pull -- <org> |
Sync platform changes down without overwriting local edits; unknown UUIDs get separate files, never name-linked |
npm run push -- <org> |
Preflight the write plan, then push without pulling first (prefer apply); --strict also blocks validation errors outside the plan and variable-undefined warnings. Review --dry-run Name collisions, and use --adopt <id>[=<uuid>] only with explicit approval to take over a resource; unchanged alias files are removed, edited/unbaselined copies need review. Push/apply support --json for one grouped link-preflight report (exit 1 on blockers); see Running in CI. |
npm run rollback -- <org> |
Restore a pre-deploy snapshot |
npm run cleanup -- <org> |
Find, and optionally delete, platform resources with no file |
npm run audit -- <org> |
Report drift between files, state and the platform |
npm run call -- <org> |
Talk to an assistant or squad from your terminal |
npm run sim -- <org> |
Run a simulation suite against deployed resources |
npm run check |
Run PR simulation checks against local files |
npm run promote |
Promote resources from one org to the next |
npm run sync-blocks |
List, and optionally deploy, the resources a shared block edit reaches |
setup, apply, pull, push, cleanup and call prompt interactively
when run without arguments. Full flags and examples:
Commands.
Guides