curl -sS -X POST "$BMA_BASE_URL/v1/vaults/vlt_zppdgwodanyrnl7ee7tsokkpta/credentials" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID" \
-H "Idempotency-Key: $(uuidgen)" \
-H "content-type: application/json" \
-d '{
"display_name": "GitHub API token",
"auth": {
"type": "environment_variable",
"secret_name": "GITHUB_TOKEN",
"secret_value": "ghp_example_value",
"networking": {
"type": "limited",
"allowed_hosts": [
"api.github.com"
]
},
"injection_location": {
"header": true
}
}
}'{
"type": "vault_credential",
"id": "vcrd_pdkul5ljnr2o5b3ijqmnv4zkka",
"vault_id": "vlt_zppdgwodanyrnl7ee7tsokkpta",
"display_name": "GitHub API token",
"metadata": {},
"auth": {
"type": "environment_variable",
"secret_name": "GITHUB_TOKEN",
"networking": {
"type": "limited",
"allowed_hosts": [
"api.github.com"
]
},
"injection_location": {
"header": true,
"body": false
}
},
"created_at": "2026-11-21T09:30:55.270113Z",
"updated_at": "2026-11-21T09:30:55.270113Z",
"archived_at": null
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}Create a credential
Stores a new credential in an active vault and returns it without its secret. auth.type picks the kind: static_bearer (a bearer token for one MCP server URL), mcp_oauth (an OAuth access token for one MCP server URL, optionally with the refresh token and token endpoint to renew it) or environment_variable (a secret that a session’s sandbox sees as an environment variable holding a placeholder; the real value is swapped in only in outgoing HTTPS requests to the allowed hosts). Among a vault’s active credentials the key must be unique: the MCP server URL, shared by static_bearer and mcp_oauth and compared with lower-cased scheme and host and without a trailing slash or fragment, or the case-sensitive secret_name. Secret values are stored encrypted and never returned; expires_at and the refresh settings are stored as given, and nothing is probed. With an Idempotency-Key, repeating the same request within 24 hours replays the first answer instead of creating another credential. An invalid body, an archived vault or a vault that already holds 20 active credentials is a 400 invalid_request_error without an error.code; an unknown vault, or one in another workspace, is a 404 not_found_error without an error.code.
Authorization: Organization API key (x-api-key: bma_org_v1_…), personal access token (Authorization: Bearer bma_pat_v1_…), signed-in user token or dashboard session; user credentials name the organization with bma-organization-id. The request acts in one workspace: the one named by bma-workspace-id, which may be left out when the credential resolves to a single workspace (the workspace an API key is bound to, or a member’s only workspace). The caller’s workspace role must be admin or developer (organization owners and admins act as workspace admins in every workspace of their organization); operators and viewers are refused, as are machine, executor and session credentials.
Limits:
- Request body: at most 256 KiB (262,144 bytes).
- At most 20 active credentials per vault (archived ones do not count).
display_name: 1-255 characters on a single line.metadata: at most 16 pairs; keys 1-64 characters, values at most 512 characters.mcp_server_urlandrefresh.token_endpoint: https URLs of at most 2048 characters.secret_name: at most 128 characters.networking.allowed_hosts: 1-16 hosts.Idempotency-Key: 1-255 visible ASCII characters; the answer of a completed request is replayed for 24 hours.- Rate limit: one request of the organization’s write budget (Rate limits).
Errors (besides the common errors (401 authentication, 429 rate_limited, 500)):
| Status | error.type | error.code | Cause | Fix |
|---|---|---|---|---|
| 400 | invalid_request_error | idempotency_key_reused | The Idempotency-Key was used in this workspace with a different request in the last 24 hours. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | invalid_idempotency_key | Idempotency-Key is longer than 255 characters or not visible ASCII. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | organization_required | A personal access token or user token names no organization with bma-organization-id. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | project_required | The credential can use several workspaces and the request names none with bma-workspace-id. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 400 | invalid_request_error | workspace_id_conflict | bma-workspace-id and anthropic-workspace-id name different workspaces. | Correct the request as the message describes and send it again; the same request will keep failing. |
| 403 | permission_error | permission_denied | The caller’s workspace role is operator or viewer, or the credential is neither an organization API key nor a user credential. | Use a credential with the required role or access; retrying with the same credential will not help. |
| 409 | conflict_error | credential_key_taken | An active credential of the vault already has this mcp_server_url (static_bearer or mcp_oauth) or this secret_name. | Archive or delete the existing credential, or update it instead of creating a new one. |
| 409 | conflict_error | idempotency_key_in_use | A request with the same Idempotency-Key is still running. | Retry the same request after a short delay. |
| 413 | request_too_large | request_too_large | The request body is larger than 256 KiB. | Reduce the size of the request body or upload in smaller parts. |
curl -sS -X POST "$BMA_BASE_URL/v1/vaults/vlt_zppdgwodanyrnl7ee7tsokkpta/credentials" \
-H "x-api-key: $BMA_API_KEY" \
-H "bma-workspace-id: $BMA_PROJECT_ID" \
-H "Idempotency-Key: $(uuidgen)" \
-H "content-type: application/json" \
-d '{
"display_name": "GitHub API token",
"auth": {
"type": "environment_variable",
"secret_name": "GITHUB_TOKEN",
"secret_value": "ghp_example_value",
"networking": {
"type": "limited",
"allowed_hosts": [
"api.github.com"
]
},
"injection_location": {
"header": true
}
}
}'{
"type": "vault_credential",
"id": "vcrd_pdkul5ljnr2o5b3ijqmnv4zkka",
"vault_id": "vlt_zppdgwodanyrnl7ee7tsokkpta",
"display_name": "GitHub API token",
"metadata": {},
"auth": {
"type": "environment_variable",
"secret_name": "GITHUB_TOKEN",
"networking": {
"type": "limited",
"allowed_hosts": [
"api.github.com"
]
},
"injection_location": {
"header": true,
"body": false
}
},
"created_at": "2026-11-21T09:30:55.270113Z",
"updated_at": "2026-11-21T09:30:55.270113Z",
"archived_at": null
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"bma_error_code": "<string>"
},
"request_id": "<string>"
}Headers
Path Parameters
Body
Response
Success.
A credential of a vault, with its non-secret settings only; secret values are never returned.