{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/looot/json-schema/looot-platform-key-schema.json",
  "title": "PlatformKey",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/looot-platform-keys-api-openapi.yml#/components/schemas/PlatformKey",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "providerId",
    "displayName",
    "hasKey",
    "keyHint",
    "authConfig",
    "platformFeeMicros",
    "approved",
    "updatedAt",
    "endpointCount",
    "runnable"
  ],
  "properties": {
    "providerId": {
      "type": "string"
    },
    "displayName": {
      "type": "string"
    },
    "hasKey": {
      "type": "boolean"
    },
    "keyHint": {
      "type": [
        "string",
        "null"
      ],
      "description": "The secret's last 4 characters only; never the secret itself"
    },
    "authConfig": {
      "oneOf": [
        {
          "$ref": "#/$defs/PlatformAuthConfig"
        },
        {
          "type": "null"
        }
      ],
      "description": "How the credential is injected at run time; null falls back to a header/query default derived from the endpoint's own authPlacement"
    },
    "platformFeeMicros": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "approved": {
      "type": "boolean"
    },
    "updatedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "endpointCount": {
      "type": "integer",
      "minimum": 0
    },
    "runnable": {
      "type": "boolean",
      "description": "True when a run with no customer connection would actually use this key right now: approved, priced, a secret is stored, and the config can be applied to the provider's endpoints"
    }
  },
  "$defs": {
    "PlatformAuthConfig": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "authMethod"
          ],
          "properties": {
            "authMethod": {
              "const": "bearer"
            },
            "headerName": {
              "type": "string"
            },
            "valuePrefix": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "authMethod",
            "headerName"
          ],
          "properties": {
            "authMethod": {
              "const": "header"
            },
            "headerName": {
              "type": "string"
            },
            "valuePrefix": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "authMethod",
            "paramName"
          ],
          "properties": {
            "authMethod": {
              "const": "query"
            },
            "paramName": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "authMethod"
          ],
          "properties": {
            "authMethod": {
              "const": "basic"
            },
            "headerName": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "authMethod",
            "fields"
          ],
          "properties": {
            "authMethod": {
              "const": "multi"
            },
            "fields": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "field",
                  "placement",
                  "name"
                ],
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "placement": {
                    "enum": [
                      "header",
                      "query"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "valuePrefix": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}