Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions fern/config-as-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,55 @@ Before your first change:

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to draw the analog to terraform import for people to quickly understand what this means


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`:
Expand Down
Loading