You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement credential management and enhance error handling
- Added credential management functionality to automatically resolve and map environment-specific credential UUIDs to human-readable names.
- Introduced a new `credentials.ts` module for credential resolution, including functions for building forward and reverse maps.
- Enhanced error handling in API requests by introducing a custom `VapiApiError` class for better error reporting.
- Updated the `pull` and `push` processes to incorporate credential resolution, ensuring seamless integration across environments.
- Improved logging for unresolved credentials and API errors to provide clearer feedback during operations.
- Revised the README to document the new credential management features and their usage.
Credentials (API keys, JWT secrets, etc.) are environment-specific and managed automatically through the state file. No secrets are stored in resource files or git.
534
+
535
+
**How it works:**
536
+
537
+
1. **Pull** fetches all credentials from `GET /credential` and stores `name-slug → UUID` in the state file
538
+
2. **Pull** replaces credential UUIDs with human-readable names in resource files
539
+
3. **Push** reverses the mapping — resolves credential names back to UUIDs before sending to the API
540
+
541
+
```yaml
542
+
# Resource file stores credential NAME (environment-agnostic)
543
+
server:
544
+
url: https://my-api.com/endpoint
545
+
credentialId: my-server-credential # ← human-readable name
546
+
```
547
+
548
+
```json
549
+
// State file stores credential UUID (environment-specific)
Each environment has its own state file with its own credential UUIDs. The same resource file works across all environments — only the state file differs:
> **Note:** Credentials are auto-discovered from the Vapi API by name. Create credentials with the same name in each environment's Vapi org, and pull will populate the mappings automatically.
568
+
530
569
### State File
531
570
532
571
Tracks mapping between resource IDs and Vapi UUIDs:
533
572
534
573
```json
535
574
{
575
+
"credentials": {
576
+
"my-server-credential": "uuid-0000"
577
+
},
536
578
"tools": {
537
579
"my-tool": "uuid-1234"
538
580
},
@@ -593,6 +635,17 @@ Check the state file has correct UUID:
593
635
2. Find the resource entry
594
636
3. If incorrect, delete entry and re-run push
595
637
638
+
### "Credential with ID not found" errors
639
+
640
+
The credential UUID doesn't exist in the target environment. Fix:
641
+
1. Run `npm run pull:{env}` to fetch credentials into the state file
642
+
2. If the credential doesn't exist in the target org, create it in the Vapi dashboard with the same name
643
+
3. Pull again — the mapping will be auto-populated
644
+
645
+
### "Unresolved credential" warnings
646
+
647
+
A resource file has a `credentialId` that couldn't be resolved to a UUID. This means the credential name isn't in the state file. Run `pull` to populate credential mappings.
648
+
596
649
### "property X should not exist" API errors
597
650
598
651
Some properties can't be updated after creation. Add them to `UPDATE_EXCLUDED_KEYS` in `src/config.ts`.
0 commit comments