---
title: "Create a vault connection (managed credential)"
method: POST
path: "/v1/connections"
---

# Create a vault connection (managed credential)

`POST /v1/connections`

## Request

- Base URL: `https://api.klanexai.com`
- URL: `https://api.klanexai.com/v1/connections`
- Auth: API key in header `X-API-Key`

Store a credential once and reference it by connection_id on a target, instead of passing raw headers. Secrets are KMS-sealed; OAuth tokens are refreshed automatically at execution time.

## Request body

- object
  - `provider` string, required: Label; known values (github, google, slack, hubspot, salesforce, stripe) auto-fill OAuth endpoints.
  - `grant_type` 'static_bearer' | 'oauth2_client_credentials' | 'oauth2_authorization_code', required
  - `token` string: static_bearer only.
  - `client_id` string: oauth2 grants.
  - `client_secret` string: oauth2 grants.
  - `authorize_url` string, uri
  - `token_url` string, uri
  - `scopes` string[]
  - `inject_header` string
  - `token_prefix` string

## Response `201`

Created. For oauth2_authorization_code the response includes an authorize_url to open in a browser for consent.

- Connection: Secret-free view of a vault connection.
  - `connection_id` string
  - `provider` string
  - `grant_type` 'static_bearer' | 'oauth2_client_credentials' | 'oauth2_authorization_code'
  - `status` 'pending' | 'connected' | 'error'
  - `inject_header` string
  - `scopes` string[]
  - `expires_at` string, date-time
  - `authorize_url` string: Present on create for authorization-code connections.
  - `last_error` string
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

- `400`: Malformed request (bad URL, unsupported method, invalid JSON, bad filter).
- `401`: Missing or invalid X-API-Key.
- `429`: Per-tenant rate limit exceeded; retry after Retry-After seconds.

---

[API](https://skmtc.dev/klanexai/apis/klanex-api.md) · [All operations](https://skmtc.dev/klanexai/apis/klanex-api/llms.txt) · [OpenAPI document](https://skmtc.dev/klanexai/apis/klanex-api/revisions/daf36597612f?raw)
