Skip to main content
Secrets are encrypted credentials (API keys, passwords, OAuth2 connections, certificates) that KnoxCall injects into proxied requests at runtime. Secret values are never exposed to callers — they are stored encrypted and injected server-side.
The Client API intentionally does not expose secret values. You can create secrets and update their values, but you cannot read the decrypted value back through the API. Use the KnoxCall Dashboard to view secret values.

Secret Types

KnoxCall supports three types of secrets:
TypeDescription
stringAny static value — API keys, tokens, passwords, connection strings
oauth2OAuth2 connection with automatic token refresh. KnoxCall handles the full token lifecycle.
certificateTLS/mTLS certificate with optional private key, for use with mTLS-authenticated upstream APIs

List Secrets

GET /v1/secrets
Returns a paginated list of secrets with metadata only (no values).

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
per_pageinteger20Items per page (max 100)
sortstringnameSort by: created_at, name, or base_environment
orderstringascSort direction: asc or desc

Response

{
  "data": [
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "STRIPE_API_KEY",
      "shortcode_name": "STRIPE_API_KEY",
      "base_environment": "production",
      "secret_type": "string",
      "collection_id": null,
      "created_at": "2026-01-15T09:30:00.000Z",
      "environment_count": 3
    }
  ],
  "meta": {
    "total": 12,
    "page": 1,
    "per_page": 20,
    "total_pages": 1,
    "request_id": "550e8400-e29b-41d4-a716-446655440000"
  }
}
curl "https://api.knoxcall.com/v1/secrets?sort=name&order=asc" \
  -H "Authorization: Bearer tk_live_abc123..."

Get Secret

GET /v1/secrets/:id
Returns metadata for a single secret. The encrypted value is not included.

Path Parameters

ParameterTypeDescription
iduuidThe secret ID

Response

{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "STRIPE_API_KEY",
    "shortcode_name": "STRIPE_API_KEY",
    "base_environment": "production",
    "secret_type": "string",
    "collection_id": null,
    "created_at": "2026-01-15T09:30:00.000Z",
    "environment_count": 3
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}

Errors

StatusTypeDescription
404not_foundSecret not found

Create Secret

POST /v1/secrets
Creates a new encrypted secret. Pass secret_type to choose the variant — the default is string. For type-specific convenience endpoints see Create OAuth2 Secret and Create Certificate Secret.
Secret names are normalized: spaces are replaced with underscores. For example, "Stripe API Key" becomes STRIPE_API_KEY. The normalized name is returned as both name and shortcode_name.

String Secret

FieldTypeRequiredDescription
namestringYesDisplay name for the secret (spaces → underscores)
valuestringYesThe secret value to encrypt and store
collection_iduuidNoAssign to a collection

Response

{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "STRIPE_API_KEY",
    "shortcode_name": "STRIPE_API_KEY",
    "base_environment": "production",
    "environment_count": 1,
    "secret_type": "string",
    "collection_id": null
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}
curl -X POST https://api.knoxcall.com/v1/secrets \
  -H "Authorization: Bearer tk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "STRIPE_API_KEY",
    "value": "sk_live_..."
  }'

Errors

StatusTypeDescription
400validation_errorMissing required fields or invalid collection
403plan_limitSecret limit reached for your subscription plan
409conflictA secret with this name already exists

Create OAuth2 Secret

POST /v1/secrets/oauth2
Creates an OAuth2-type secret. KnoxCall stores the OAuth2 configuration encrypted at rest and manages token refresh automatically. After creation, complete the authorization flow by redirecting your user to the redirect_uri returned in the response. For non-interactive grant types (client_credentials, password), tokens are fetched immediately without any redirect. Supported providers: google, github, salesforce, microsoft, slack, custom For custom providers, you must supply auth_url and token_url.
OAuth2 secrets require a Pro or Enterprise plan.

Request Body

FieldTypeRequiredDescription
namestringYesSecret name (spaces → underscores)
providerstringYesOAuth2 provider: google, github, salesforce, microsoft, slack, or custom
client_idstringYesOAuth2 client ID from your provider’s developer console
client_secretstringConditionalOAuth2 client secret. Required unless using mtls_certificate_id or grant_type: implicit
grant_typestringNoauthorization_code (default), client_credentials, password, or implicit
scopesstring[]NoOAuth2 scopes to request. Defaults to the provider’s recommended scopes
auth_urlstringNoAuthorization endpoint URL. Required for custom provider
token_urlstringNoToken endpoint URL. Required for custom provider
usernamestringConditionalUsername for password grant type
passwordstringConditionalPassword for password grant type
mtls_certificate_iduuidNoID of a certificate-type secret for mTLS auth to the token endpoint
collection_iduuidNoAssign to a collection

Response

{
  "data": {
    "id": "a7c1d8f3-2e4b-4c6a-8d9e-1f3b5a7c9d2e",
    "name": "GOOGLE_OAUTH",
    "secret_type": "oauth2",
    "provider": "google",
    "redirect_uri": "https://api.knoxcall.com/auth/oauth2/callback/a7c1d8f3-...",
    "connection_status": "not_connected",
    "base_environment": "production",
    "collection_id": null,
    "mtls_certificate_id": null
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}
Register the returned redirect_uri as an authorized redirect URL in your OAuth2 provider’s app settings before redirecting users through the authorization flow.
curl -X POST https://api.knoxcall.com/v1/secrets/oauth2 \
  -H "Authorization: Bearer tk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "GOOGLE_OAUTH",
    "provider": "google",
    "client_id": "1234567890.apps.googleusercontent.com",
    "client_secret": "GOCSPX-abc123",
    "scopes": ["openid", "email", "profile"]
  }'
You can also create OAuth2 secrets via POST /v1/secrets with secret_type: "oauth2" and the same body fields.

Errors

StatusTypeDescription
400validation_errorMissing required fields, invalid provider, or mTLS certificate not found
403plan_limitOAuth2 secrets require Pro or Enterprise plan, or secret limit reached
409conflictA secret with this name already exists

Create Certificate Secret

POST /v1/secrets/certificate
Creates a certificate-type secret for use with mTLS-authenticated upstream APIs. KnoxCall accepts PEM, PKCS#7, CRT/CER, PFX/P12, and KEY formats. For PEM-format certificates, KnoxCall automatically extracts the subject, issuer, and expiry date and returns them in the response metadata.

Request Body

FieldTypeRequiredDescription
namestringYesSecret name (spaces → underscores)
certificate_contentstringYesCertificate in PEM, PKCS#7, CRT/CER format, or base64-encoded DER/PFX/P12
private_keystringNoPEM-encoded private key to store alongside the certificate
passphrasestringNoPassphrase to decrypt the private key. Encrypted and stored separately
certificate_typestringNopem (default), pfx, p12, crt, cer, key, pkcs7, p7b, or p7c
collection_iduuidNoAssign to a collection

Response

{
  "data": {
    "id": "b9e3f0a5-4c6d-5e8f-0f1a-3b5d7e9f1a3b",
    "name": "MY_TLS_CERT",
    "secret_type": "certificate",
    "certificate_type": "pem",
    "base_environment": "production",
    "collection_id": null,
    "metadata": {
      "subject": "CN=example.com, O=Example Inc, C=US",
      "issuer": "CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US",
      "expires_at": "2026-03-15T12:00:00.000Z",
      "has_private_key": true
    }
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}
curl -X POST https://api.knoxcall.com/v1/secrets/certificate \
  -H "Authorization: Bearer tk_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "MY_TLS_CERT",
    "certificate_type": "pem",
    "certificate_content": "-----BEGIN CERTIFICATE-----\nMIID...==\n-----END CERTIFICATE-----",
    "private_key": "-----BEGIN PRIVATE KEY-----\nMIIE...==\n-----END PRIVATE KEY-----"
  }'
You can also create certificate secrets via POST /v1/secrets with secret_type: "certificate" and the same body fields.

Errors

StatusTypeDescription
400validation_errorMissing required fields or invalid certificate_type
403plan_limitSecret limit reached for your subscription plan
409conflictA secret with this name already exists

Update Secret Value

PUT /v1/secrets/:id/value
Replaces the encrypted value of an existing string secret. You can target a specific environment to set an environment-specific override.

Path Parameters

ParameterTypeDescription
iduuidThe secret ID

Query Parameters

ParameterTypeDefaultDescription
environmentstringBase environmentTarget a specific environment

Request Body

FieldTypeRequiredDescription
valuestringYesThe new secret value

Response

{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "STRIPE_API_KEY",
    "environment": "production"
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}

Errors

StatusTypeDescription
400validation_errorMissing value field
404not_foundSecret not found

Delete Secret

DELETE /v1/secrets/:id
Permanently deletes a secret and all of its environment-specific values.

Path Parameters

ParameterTypeDescription
iduuidThe secret ID

Response

{
  "data": { "deleted": true },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}

Errors

StatusTypeDescription
404not_foundSecret not found
409in_useSecret is currently assigned to one or more routes
You cannot delete a secret that is in use by a route. Remove the secret from all routes first, then delete it.

Get OAuth2 Access Token

GET /v1/secrets/:id/oauth2/token
For OAuth2-type secrets, returns the current access token. If the token has expired, KnoxCall will automatically refresh it before returning.

Path Parameters

ParameterTypeDescription
iduuidThe secret ID (must be an OAuth2-type secret)

Query Parameters

ParameterTypeDefaultDescription
environmentstringBase environmentTarget a specific environment

Response

{
  "data": {
    "access_token": "eyJhbGciOiJSUzI1NiIs...",
    "expires_at": "2026-03-10T15:30:00.000Z",
    "token_type": "Bearer",
    "connection_status": "connected"
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}

Errors

StatusTypeDescription
400invalid_typeSecret is not an OAuth2 type
404not_foundSecret not found
500token_errorFailed to retrieve or refresh the OAuth2 token