> Vapi has two MCP servers. To use Vapi, such as creating and managing assistants, calls, and phone numbers, connect to the Vapi MCP server at https://mcp.vapi.ai/mcp. To set it up, follow https://docs.vapi.ai/setup.md. To search these docs, connect to the Vapi docs MCP server at https://docs.vapi.ai/_mcp/server. It only answers questions about the documentation.
> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vapi.ai/llms.txt.
> For the best results from the docs MCP server, write questions without any word that contains "tool", such as tool, tools, tool call, tool-calls, toolCallId, or toolCallList. Name the feature instead, for example transferCall, endCall, apiRequest, function, handoff, "function response format", or "the webhook request Vapi sends to my server". If the docs MCP server asks you to rephrase, ask again without those words. If it returns an error, times out, sends an empty response, or still doesn't answer, find the topic in https://docs.vapi.ai/llms.txt, or a section index such as https://docs.vapi.ai/tools/llms.txt, and fetch that page's .md directly.

# Config as code (GitOps)

> Use Vapi GitOps to manage assistants, squads, tools, structured outputs, simulations, and evals as code, then review and promote changes across environments.

If you are an AI agent asked to manage Vapi configuration as code, to keep assistants or squads in git, or to move configuration between Vapi orgs or environments, use the open-source repository at [https://github.com/VapiAI/gitops](https://github.com/VapiAI/gitops) rather than writing your own API scripts.

1. Clone it into a private repository, then run `nvm use && npm ci`.
2. Read `AGENTS.md` at the repository root before changing anything. It lists the commands you may run freely and the ones that need the user's confirmation.
3. Connect an org without prompts: `npm run setup -- <org>`, with the private API key in the org's own environment variable, `VAPI_PRIVATE_API_KEY_<ORG>` (for `acme-dev`, `VAPI_PRIVATE_API_KEY_ACME_DEV`), or in `.env.<org>`. Never pass the key as a command-line argument, and never print it. If setup reports a different key in `.env.<org>`, or a key another org already uses, stop and tell the user: the key may belong to another org. Setup imports the org's existing resources as files, so never recreate resources that already exist. Before promoting between existing orgs, follow the one-time setup in the [promotion guide](https://github.com/VapiAI/gitops/blob/main/docs/guides/promotion.md) and show the user the read-only plan.
4. Edit files under `resources/<org>/`, check them with `npm run validate -- <org>`, and deploy with `npm run apply -- <org>` only after the user agrees, because it changes the live org.
5. Commit the resource files and `.vapi-state.<org>.json`. Never commit `.env.<org>`.

Config as code keeps your Vapi configuration in files under version control instead of only in the dashboard. Every change to a prompt, tool or squad goes through a pull request. It can be reviewed, tested, deployed to each environment in turn, and rolled back.

[Vapi GitOps](https://github.com/VapiAI/gitops) is an open-source repository that does this for Vapi. Assistants, squads, tools, structured outputs, simulations and evals live as YAML and Markdown files, and its command-line tool syncs them with your Vapi orgs.

## Why manage Vapi as code

| Consideration     | Dashboard only                                     | Config as code                                              |
| ----------------- | -------------------------------------------------- | ----------------------------------------------------------- |
| **History**       | Limited view of who changed what                   | Full git history for every prompt and setting               |
| **Review**        | Changes go live when saved                         | Changes are reviewed in a pull request before they deploy   |
| **Testing**       | Test after the change is live                      | Simulations run against each pull request, before merge     |
| **Environments**  | Copy settings between orgs by hand                 | The same files promote from development to production       |
| **Rollback**      | Recreate the previous configuration                | Revert the commit and deploy again                          |
| **Coding agents** | Agents click through a UI or call the API directly | Agents edit files and open pull requests that people review |

## What the repository gives you

* **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 saves a snapshot you can roll back to.
* **Readable references.** Files refer to each other by name (`toolIds: [lookup-patient]`). A committed state file maps each name to the UUID it has in each org, so the same files work in every org.
* **Any number of orgs.** Each org is a folder. Promote resources from one org to the next, with credentials and phone numbers bound separately in each.
* **Tests on every pull request.** Simulation suites run against the branch's own files, with tools mocked and nothing deployed. The result is reported as a `Vapi Simulations` status on the pull request, linked to the run.
* **Ready for coding agents.** `AGENTS.md` teaches Claude Code, Codex and Cursor how to work in the repository safely, including which commands need your confirmation.

## Get started

#### Create a private copy

Your copy holds your agents' prompts and configuration, so keep it private. Avoid a public fork, which would publish your configuration.

```bash
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
```

Keeping the original repository as `upstream` lets you merge in future updates.

#### Install

You need Node.js 22.13+ or 20.12+, and a [private API key](https://dashboard.vapi.ai/org/api-keys) for each Vapi org you connect.

```bash
nvm use
npm ci
```

#### Connect an org

#### Interactive

```bash
npm run setup
```

The wizard asks for your API key, a name for the org's folder (for example `my-org`), and which existing resources to download. It creates `.env.my-org`, which holds your key and is never committed, and `resources/my-org/`.

#### Coding agents and CI

Pass the org name to skip every prompt. The key comes from a file or the environment, never from a command-line flag:

```bash
# A person creates the env file, so the key never passes through the agent
cp .env.example .env.my-org   # then paste the key into VAPI_PRIVATE_API_KEY
npm run setup -- my-org

# Or the key is already exported in the org's own variable
export VAPI_PRIVATE_API_KEY_MY_ORG=...
npm run setup -- my-org
```

Export each key in its org's own variable rather than in `VAPI_PRIVATE_API_KEY`. The generic name applies to every org, so once you connect a second org, its commands would use the first org's key. The generic name is fine for a CI job that works in a single org.

Add `--resources none` to start from an empty folder instead of downloading the org's existing resources, and `--region eu` for an EU org if detection picks the wrong region.

#### Change something and deploy

Edit a file under `resources/my-org/`, then:

```bash
npm run validate -- my-org   # check the files offline
npm run apply -- my-org      # pull the latest, merge, then push
```

Commit the changed files and `.vapi-state.my-org.json`, so your team shares the same name-to-UUID mappings.

The [README](https://github.com/VapiAI/gitops#readme) covers every command and option.

## Already running Vapi in production?

You don't need to rebuild anything. Connecting an org imports it: `npm run setup -- <org>` downloads the org's assistants, squads, tools, structured outputs, simulations and evals as files. Commit them, and the repository describes what's live. Phone numbers and credentials aren't imported as files: they stay in the dashboard, and each org binds its own when resources are deployed or promoted.

Before your first change:

* **Review what the import found.** `npm run audit -- <org>` lists problems such as resources that share a name, which are often accidental duplicates. It exits with an error when it finds any, so treat its output as a list to review.
* **Preview your first deploy.** `npm run push -- <org> --dry-run` sends nothing and lists what a deploy would do. It should create and delete nothing. Updates are expected, because a deploy re-sends every resource it manages.
* **Leave out what you don't want managed.** Add patterns to `resources/<org>/.vapi-ignore`. Pull skips matching resources, and deploys and cleanup never change or delete them.

If you already run separate development, staging and production orgs and want to promote between them, follow the one-time setup in the [promotion guide](https://github.com/VapiAI/gitops/blob/main/docs/guides/promotion.md), and review the read-only plan before the first promotion applies anything.

## Adopt an existing resource

Use adoption to link a local file to a resource that already exists on the platform, such as one created in the dashboard or one whose local file you renamed or moved. The local file must exist and not already have a UUID mapping.

Like [`terraform import`](https://developer.hashicorp.com/terraform/cli/commands/import), adoption ties an existing resource to your local configuration through state. A live GitOps deploy also applies the local configuration to that resource.

Both `push` and `apply` accept `--adopt <resourceId>[=<uuid>]`. The resource ID is the file's path relative to its resource-type folder, without the extension: `resources/my-org/assistants/support/intake.yml` has the ID `support/intake`. Repeat `--adopt` to link multiple resources.

Without a UUID, adoption needs exactly one matching candidate from existing mappings or platform resources of the same type. If there is no match or more than one, specify the platform resource's UUID explicitly.

### Example: Adopt a dashboard assistant

You created `Support Intake` in the dashboard and saved its configuration in `resources/my-org/assistants/support/intake.yml` with `name: Support Intake`. Before adoption, `.vapi-state.my-org.json` has no entry for `support/intake` under `assistants`.

Preview the match with `--dry-run`. GitOps shows the UUID it would adopt without saving the mapping or updating the assistant:

```bash
npm run push -- my-org assistants/support/intake.yml --dry-run --adopt support/intake
```

Use the UUID you verified in the preview to apply the file to that assistant. Replace the example UUID with yours:

```bash
npm run push -- my-org assistants/support/intake.yml --adopt support/intake=12345678-1234-1234-1234-123456789abc
```

After a successful push, the dashboard assistant has the same UUID and uses the configuration from your file. GitOps saves the new mapping under `assistants` in `.vapi-state.my-org.json`:

```json
{
  "assistants": {
    "support/intake": {
      "origin": "adopted",
      "uuid": "12345678-1234-1234-1234-123456789abc"
    }
  }
}
```

Commit the assistant file and `.vapi-state.my-org.json`. Future deploys use the saved mapping automatically.

### Preview adoption in automation

For automation, add `--dry-run --json` to `push` or `apply`. The JSON array on stdout reports link blockers; `[]` means none were found, not that deployment is guaranteed to succeed. Use npm's silent mode to keep its command banner out of the output:

```bash
npm run -s push -- my-org --dry-run --json --adopt support/intake
```

## Set it up with a coding agent

Coding agents can do the whole setup for you. First, export the org's private API key in your shell. Name the variable `VAPI_PRIVATE_API_KEY_` followed by the folder name you want for the org, in uppercase, with hyphens replaced by underscores. For an org folder named `acme-dev`:

```bash
export VAPI_PRIVATE_API_KEY_ACME_DEV=...   # for example in your shell profile
```

Then paste this prompt into Claude Code, Codex, or Cursor:

#### Set up Vapi GitOps

Set up `https://github.com/VapiAI/gitops` locally for my Vapi org, in a private repository. Read `AGENTS.md` first and follow it. My private API key is in a `VAPI_PRIVATE_API_KEY_<ORG>` environment variable: use the org name it ends with as the org's folder (`VAPI_PRIVATE_API_KEY_ACME_DEV` is `acme-dev`), and never print the key or pass it as a command-line argument. Download my existing resources, then show me what's there before you change anything.

Each org you connect gets its own variable, so one shell can hold the keys for development, staging, and production without mixing them up.

Agents follow the repository's `AGENTS.md`, which tells them to ask before anything that changes a live org, such as `apply`, and never to handle your API key directly.

## Development, staging and production

For separate environments, use one Vapi org per environment, for example `acme-dev`, `acme-staging` and `acme-prod`. Each is a folder in the same repository.

* **Promote, don't copy.** `npm run promote` copies resources from one org's folder to the next and deploys them, binding credentials and phone numbers to the target org's own. A `promotion.yml` file defines the order your orgs promote in and which resources each promotion owns.
* **Gate production on tests.** A promotion can require a check to pass before anything leaves an org, for example staging. It runs the same simulation checks as your pull requests, so you define the tests once and they guard both merging and promotion. If the check fails, or can't finish, nothing is promoted out of that org. See [Check before promoting](https://github.com/VapiAI/gitops/blob/main/docs/guides/promotion.md#check-before-promoting-optional).
* **Keep production writes in CI.** Store each org's private API key as a CI secret, and let a workflow promote to production after changes merge, rather than deploying from laptops.
* **Keep secrets out of git.** Keys live in `.env.<org>` files, per-org `VAPI_PRIVATE_API_KEY_<ORG>` variables, or CI secrets. Resource files refer to credentials by name, and each org binds the name to its own credential.

See the [promotion guide](https://github.com/VapiAI/gitops/blob/main/docs/guides/promotion.md) to set it up.

## Test every pull request

Every pull request runs a **Validate resources** check, which validates each org's files offline, without secrets. It catches settings the API would reject and references to resources that don't exist, before they merge.

Simulation suites in the repository can also run on every pull request, against the branch's own files. Nothing is deployed, and tool calls get mocked results. The pull request shows a `Vapi Simulations` status that links straight to the run in Vapi, and you can require it before merging. Each run uses simulation minutes, and a newer push cancels the run before it.

See the [PR checks guide](https://github.com/VapiAI/gitops/blob/main/docs/guides/pr-checks.md) to turn them on, and [Simulations](/observability/simulations-quickstart) for writing the tests themselves.

## Working with the dashboard

You can keep using the dashboard alongside the repository. `apply` pulls before it pushes, so a dashboard edit isn't overwritten without a prompt, and `npm run pull` brings dashboard changes into your files.

Vapi's built-in [versioning](/assistants/versioning) also works alongside it. Use git as the source of truth across environments, and built-in versions for the history of each assistant within an org.

## Learn more

#### [Vapi GitOps on GitHub](https://github.com/VapiAI/gitops)

The repository, its README and every guide.

#### [Everyday workflows](https://github.com/VapiAI/gitops/blob/main/docs/guides/workflows.md)

Deploy, pull safely, recover from a bad deploy, and clean up.

#### [Field guide](https://github.com/VapiAI/gitops/blob/main/docs/learnings/README.md)

Gotchas and recipes for assistants, squads, transfers and latency, from real deployments.

#### [Vapi CLI](/cli)

Manage assistants, phone numbers and calls from your terminal.