{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/knoxcall/json-schema/knoxcall-create-db-connection-request-schema.json",
  "title": "CreateDbConnectionRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/knoxcall-dynamic-db-credentials-api-openapi.yml#/components/schemas/CreateDbConnectionRequest",
  "type": "object",
  "required": [
    "name",
    "engine",
    "host",
    "execution_mode"
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "Connection name (slug, 1-64 chars). `leases` is reserved — it is a route on this API (`/dyn-db-credentials/leases`), so a connection using it would be unreachable by name. Rejected with 400."
    },
    "engine": {
      "type": "string",
      "enum": [
        "postgres",
        "mysql",
        "mongo"
      ]
    },
    "host": {
      "type": "string"
    },
    "port": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535
    },
    "database_name": {
      "type": "string"
    },
    "admin_username": {
      "type": "string",
      "description": "Required for `direct`, `agent_tunnel`, and `ssh_tunnel` modes."
    },
    "admin_password": {
      "type": "string",
      "description": "Required for `direct`, `agent_tunnel`, and `ssh_tunnel` modes. **Encrypted with the tenant master key at rest and never returned.**"
    },
    "execution_mode": {
      "type": "string",
      "enum": [
        "direct",
        "agent_tunnel",
        "ssh_tunnel",
        "iam"
      ]
    },
    "agent_id": {
      "type": "string",
      "description": "Required when `execution_mode` is `agent_tunnel`. Must name an agent\nregistered to your tenant **in the same environment as the API key\nmaking this call** — a Test key cannot bind a connection to a Live\nagent, and vice versa. An id that does not resolve is rejected with\n`400 validation_error`.\n"
    },
    "default_ttl_seconds": {
      "type": "integer",
      "minimum": 1,
      "default": 3600,
      "description": "Default lease TTL for minted credentials."
    },
    "max_ttl_seconds": {
      "type": "integer",
      "minimum": 1,
      "default": 86400,
      "description": "Upper bound on lease TTLs. Must be >= `default_ttl_seconds`."
    },
    "connect_options": {
      "type": "object",
      "additionalProperties": true,
      "description": "Engine-specific connection options."
    },
    "ssh_host": {
      "type": "string",
      "description": "Required when `execution_mode` is `ssh_tunnel`."
    },
    "ssh_port": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535
    },
    "ssh_username": {
      "type": "string",
      "description": "Required when `execution_mode` is `ssh_tunnel`."
    },
    "ssh_private_key": {
      "type": "string",
      "description": "PEM-encoded SSH private key. Required when `execution_mode` is `ssh_tunnel`. **Encrypted at rest and never returned.**"
    },
    "ssh_passphrase": {
      "type": "string",
      "description": "Passphrase for the SSH key, if any. Encrypted at rest and never returned."
    },
    "ssh_host_fingerprint": {
      "type": "string",
      "description": "Expected bastion host key fingerprint in `SHA256:<base64>` format. Verified on connect when set."
    },
    "iam_region": {
      "type": "string",
      "description": "AWS region. Required when `execution_mode` is `iam` (postgres and mysql on RDS only)."
    },
    "iam_db_user": {
      "type": "string",
      "description": "RDS IAM database user. Required when `execution_mode` is `iam`."
    }
  }
}