{
  "openapi": "3.1.0",
  "info": {
    "title": "Korzen Bot Protection API",
    "description": "Call POST /v1/decide from your server before a sign-up, a sign-in or a checkout, and apply the answer's action. Any status other than 200, a timeout or a network error means: let the visitor through (fail open). Every error is an RFC 9457 problem (application/problem+json) whose `code` says what went wrong. Every answer carries Korzen-Request-Id; decide, events, feedback and give-back carry the RateLimit headers of draft-ietf-httpapi-ratelimit-headers-11 for the tenant's decisions. Docs: https://korzen.dev/bot-protection/docs",
    "termsOfService": "https://korzen.dev/legal/terms",
    "contact": {
      "url": "https://korzen.dev/contact",
      "email": "contact@korzen.dev"
    },
    "license": {
      "name": "LicenseRef-Proprietary",
      "identifier": "LicenseRef-Proprietary"
    },
    "version": "1"
  },
  "servers": [
    {
      "url": "https://korzen.dev"
    }
  ],
  "paths": {
    "/v1/decide": {
      "post": {
        "tags": [],
        "summary": "Decide whether a visitor is a person or a bot",
        "description": "Answers within half your Korzen-Deadline-Ms (10 to 1000 ms; 200 without it). The body is read up to at most 256 KiB, which a call within the fields' bounds always fits; past that, each string is cut to 4 KiB as it arrives and the members that arrive whole are judged, never refused for the size, and a cut that loses protected_action (or its former name require_token) takes the action as protected. A member Korzen does not know, or another value of ip_from or scheme, is read as none and shown on the Set-up page; a member of the wrong JSON type is a 400.",
        "operationId": "decide",
        "parameters": [
          {
            "name": "Korzen-Deadline-Ms",
            "in": "header",
            "description": "How long your SDK waits for the answer in all, in milliseconds: the decision takes half.",
            "required": false,
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "format": "int64",
              "minimum": 0
            }
          },
          {
            "name": "Korzen-Sdk",
            "in": "header",
            "description": "The integration calling, as name/version (node/0.5.0), as the SDKs send it. Without it, or with one that is no name/version, the call is still decided, on less.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DecideRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The decision.",
            "headers": {
              "Korzen-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "The call's id."
              },
              "RateLimit": {
                "schema": {
                  "type": "string"
                },
                "description": "`\"month\";r=<left>;t=<seconds to the reset>`."
              },
              "RateLimit-Policy": {
                "schema": {
                  "type": "string"
                },
                "description": "`\"month\";q=<decisions>`, or `\"trial\";q=<decisions>` on the free trial."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecideAnswer"
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid: allow the visitor.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "No API key, or one Korzen does not know.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "402": {
            "description": "Over the plan's limit: allow the visitor.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Korzen failed: allow the visitor.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Over capacity, no decision within the deadline, or a backing service unavailable: allow the visitor.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/events": {
      "post": {
        "tags": [],
        "summary": "Report requests your server saw, after the fact",
        "description": "1 to 1000 events, at most 4 MiB. Each is accepted, a duplicate of an event_id seen within the idle window, or rejected with its index and code. Recorded past the plan's limit and while the protection is paused: neither is a decision.",
        "operationId": "events",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "1 to 255 visible ASCII characters, kept an hour: a retry with the same body gets the same answer, with Idempotent-Replayed: true.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventsBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What was accepted.",
            "headers": {
              "Idempotent-Replayed": {
                "schema": {
                  "type": "string"
                },
                "description": "`true` on an answer given again for an Idempotency-Key."
              },
              "Korzen-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "The call's id."
              },
              "RateLimit": {
                "schema": {
                  "type": "string"
                },
                "description": "What is left of it."
              },
              "RateLimit-Policy": {
                "schema": {
                  "type": "string"
                },
                "description": "The tenant's decisions' quota."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchAnswer"
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "No API key, or one Korzen does not know.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "The first call with this Idempotency-Key is still running.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is past 4 MiB.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "The API key's Idempotency-Key records of the hour are at their bound: nothing ran; send it again after Retry-After, or without the header.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Over capacity, or a backing service unavailable with nothing of the batch recorded: send it again whole.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/feedback": {
      "post": {
        "tags": [],
        "summary": "Tell Korzen what you learned later about sessions",
        "description": "1 to 1000 items, at most 4 MiB, each naming a session by the request_id of one of its decisions or by its token, exactly one of them. Recorded past the plan's limit and while the protection is paused: neither is a decision.",
        "operationId": "feedback",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "1 to 255 visible ASCII characters, kept an hour.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What was accepted.",
            "headers": {
              "Idempotent-Replayed": {
                "schema": {
                  "type": "string"
                },
                "description": "`true` on an answer given again for an Idempotency-Key."
              },
              "Korzen-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "The call's id."
              },
              "RateLimit": {
                "schema": {
                  "type": "string"
                },
                "description": "What is left of it."
              },
              "RateLimit-Policy": {
                "schema": {
                  "type": "string"
                },
                "description": "The tenant's decisions' quota."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchAnswer"
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "No API key, or one Korzen does not know.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "The first call with this Idempotency-Key is still running.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is past 4 MiB.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "The API key's Idempotency-Key records of the hour are at their bound: nothing ran; send it again after Retry-After, or without the header.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Over capacity, or a backing service unavailable with nothing of the batch recorded: send it again whole.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/give-back": {
      "post": {
        "tags": [],
        "summary": "Give back what a protected action's decision took",
        "description": "Your app did not take a protected action Korzen let through, for a reason of its own (a weak password, a name already taken, a declined card): the token's use the decision spent, and the identity's place it took, are given back, so the person's next try is a first use, not a spent token's. Send the decision's request_id within the hour; a second give-back of one decision, another tenant's decision, or one Korzen refused (it gives that back itself) gives nothing back. Recorded past the plan's limit and while the protection is paused: it is no decision.",
        "operationId": "give_back",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "1 to 255 visible ASCII characters, kept an hour.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GiveBackBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Whether anything was given back.",
            "headers": {
              "Idempotent-Replayed": {
                "schema": {
                  "type": "string"
                },
                "description": "`true` on an answer given again for an Idempotency-Key."
              },
              "Korzen-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "The call's id."
              },
              "RateLimit": {
                "schema": {
                  "type": "string"
                },
                "description": "What is left of it."
              },
              "RateLimit-Policy": {
                "schema": {
                  "type": "string"
                },
                "description": "The tenant's decisions' quota."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GiveBackAnswer"
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "No API key, or one Korzen does not know.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "The first call with this Idempotency-Key is still running.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is past 4 MiB.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "The API key's Idempotency-Key records of the hour are at their bound: nothing ran; send it again after Retry-After, or without the header.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Over capacity, or a backing service unavailable: nothing was given back, send it again.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/export": {
      "get": {
        "tags": [],
        "summary": "Download your company's data",
        "description": "The company's data as one JSON file, the same as the Usage page's export (format korzen-export/1): the company, the settings its people set, its team, its keys by their hints, its contact links and every decision its plan keeps, newest first. No key, key hash, password or second factor is in it. Only an API key of the export scope, made by an account that owns the company now, exports it: the decide key on your servers and the one sign-up shows export nothing. One export of a company downloads at a time. The file is written as it downloads: a download that ends early was cut, and is not whole.",
        "operationId": "export",
        "responses": {
          "200": {
            "description": "The company's data.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "attachment; filename=\"korzen-export-YYYYMMDD-HHMMSS.json\""
              },
              "Korzen-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "The call's id."
              }
            },
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No API key, or one Korzen does not know.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The key is a decide key, or was not made by an owner of the company (code unauthorized).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Another export of the company is downloading.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "The company's data could not be read.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "format": "int32",
                  "minimum": 0
                },
                "description": "Seconds."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Action": {
        "type": "string",
        "description": "What to do with the visitor.",
        "enum": [
          "allow",
          "challenge",
          "block"
        ]
      },
      "BatchAnswer": {
        "type": "object",
        "description": "POST /v1/events' and /v1/feedback's answer.",
        "required": [
          "accepted",
          "duplicates",
          "rejected",
          "errors"
        ],
        "properties": {
          "accepted": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "duplicates": {
            "type": "integer",
            "format": "int64",
            "description": "Events whose event_id was seen already, dropped; always 0 for feedback.",
            "minimum": 0
          },
          "rejected": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemError"
            },
            "description": "Why each rejected one was."
          },
          "truncated": {
            "type": "boolean",
            "description": "Present, and true, only on an `Idempotency-Key`'s replay of an answer past 8 KiB:\nthe counts are whole, and `errors` holds only the first items rejected."
          }
        },
        "additionalProperties": false
      },
      "Challenge": {
        "type": "object",
        "description": "The challenge of a decision whose intended action is challenge.",
        "required": [
          "url",
          "passed"
        ],
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The challenge page for this visitor, when action is challenge; send them there\nwith `r=` the page to come back to."
          },
          "passed": {
            "type": "boolean",
            "description": "The session solved a challenge within the last half hour: its challenge is allow. A\nsession that waited one out without JavaScript is allowed too, with passed false."
          }
        },
        "additionalProperties": false
      },
      "ClaimsRequest": {
        "type": "object",
        "description": "What the customer's server knows about the account behind the request; `null` is none,\nfalse for a yes or no.",
        "properties": {
          "account_age_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Days since the account was made; none or 0 when not known.",
            "minimum": 0
          },
          "known_instrument": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "A payment instrument this account used before without dispute."
          },
          "device_attested": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "The device passed a platform attestation."
          },
          "contact_verified": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "The email or phone was verified."
          }
        }
      },
      "Class": {
        "type": "string",
        "description": "A decision's class.",
        "enum": [
          "human_high",
          "human",
          "unknown",
          "bot",
          "bot_high"
        ]
      },
      "Code": {
        "type": "string",
        "description": "What went wrong, one value per kind of problem.",
        "enum": [
          "invalid_json",
          "invalid_field",
          "unknown_field",
          "body_too_large",
          "unauthorized",
          "over_limit",
          "domain_refused",
          "not_found",
          "method_not_allowed",
          "conflict",
          "rate_limited",
          "over_capacity",
          "deadline",
          "idempotency_key_reused",
          "idempotency_key_in_use",
          "unavailable",
          "internal"
        ]
      },
      "ContextRequest": {
        "type": "object",
        "description": "What your server knows of the person behind the request, each field optional, `null` or\nabsent when not known. Hash with Korzen's SDK, or as the docs say: `hex(SHA-256(\"kz1:\" ‖\nkind ‖ \":\" ‖ the normalised value))`, lower case. A string in the wrong format is left\nout, never refused; a member Korzen does not know is read as none.",
        "properties": {
          "email_domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email address's domain: an A-label (IDNA), lower case, no trailing dot, 1 to 253\nbytes; `googlemail.com` is `gmail.com`.",
            "example": "gmail.com",
            "maxLength": 253
          },
          "email_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "64 lower-case hex: SHA-256 of `kz1:email:` and the normalised address.",
            "maxLength": 64,
            "minLength": 64
          },
          "phone_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "64 lower-case hex: SHA-256 of `kz1:phone:` and the number in E.164.",
            "maxLength": 64,
            "minLength": 64
          },
          "phone_country": {
            "type": [
              "string",
              "null"
            ],
            "description": "The phone number's region, ISO 3166-1 alpha-2, upper case, from your phone library.",
            "example": "NL",
            "maxLength": 2,
            "minLength": 2
          },
          "phone_type": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PhoneTypeName",
                "description": "The phone number's type, from libphonenumber or your carrier lookup."
              },
              {
                "type": "null"
              }
            ]
          },
          "card_bin": {
            "type": [
              "string",
              "null"
            ],
            "description": "The card's first six digits, exactly six: never the card number.",
            "example": "424242",
            "maxLength": 6,
            "minLength": 6
          },
          "card_fingerprint_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "64 lower-case hex: SHA-256 of `kz1:card:` and your payment provider's fingerprint of\nthe card (Stripe's `card.fingerprint`), never the card number.",
            "maxLength": 64,
            "minLength": 64
          },
          "account_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "64 lower-case hex: SHA-256 of `kz1:account:` and your own id of the account. Send it\nonly once the visitor holds the account: after a successful sign-in, or for the\naccount a sign-up just made. Never on a failed sign-in, where it names whatever\naccount the visitor typed.",
            "maxLength": 64,
            "minLength": 64
          },
          "resource_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "64 lower-case hex: SHA-256 of `kz1:resource:` and the id of what the action is on (an\norder, a listing, an event, a queue).",
            "maxLength": 64,
            "minLength": 64
          },
          "identity_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "64 lower-case hex: SHA-256 of `kz1:identity:` and what you limit places by on a\nrequired action (an account, a verified email, a fan id). With `places_per_identity`,\nit caps the places one identity holds on a path in an hour.",
            "maxLength": 64,
            "minLength": 64
          }
        }
      },
      "DecideAnswer": {
        "type": "object",
        "description": "POST /v1/decide's answer: every member always present, null or false when it does not\napply.",
        "required": [
          "request_id",
          "class",
          "bot_score",
          "action",
          "mode",
          "challenge",
          "token_required",
          "decoy"
        ],
        "properties": {
          "request_id": {
            "type": "string",
            "description": "The decision's id, at most 96 characters: keep it with an order to send feedback by\nit weeks later.",
            "maxLength": 96
          },
          "class": {
            "$ref": "#/components/schemas/Class"
          },
          "bot_score": {
            "type": "integer",
            "format": "int32",
            "maximum": 100,
            "minimum": 0
          },
          "action": {
            "$ref": "#/components/schemas/Action",
            "description": "What to do with the visitor: in monitor mode always allow."
          },
          "mode": {
            "$ref": "#/components/schemas/Mode"
          },
          "challenge": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Challenge",
                "description": "The challenge, when block mode would challenge the visitor; null otherwise."
              },
              {
                "type": "null"
              }
            ]
          },
          "token_required": {
            "type": "boolean",
            "description": "The decision asked for a token and the request carried none valid for the action,\nor one spent on it already."
          },
          "decoy": {
            "type": "boolean",
            "description": "Answer this refusal with a decoy, not a refusal the visitor can see: true\nonly when you chose the decoy for the decision's class (`bot` or `bot_high`) and\n`action` is not allow. `action` stays as it is, so a server that does not read\n`decoy` still refuses.\nWith no decoy handler of yours, the SDKs answer an action (POST, PUT, PATCH, DELETE) `202`\nwith `{}` and refuse a page load (GET, HEAD) as any other."
          }
        },
        "additionalProperties": false
      },
      "DecideRequest": {
        "type": "object",
        "description": "POST /v1/decide's body: the visitor's request as the customer's server received it.\nEvery member is optional; send what you have. A value past its bound is cut on a\ncharacter, never refused. A member or a value of an enum Korzen does not know is read\nas none, never refused, and Set-up shows it.",
        "properties": {
          "ip": {
            "type": [
              "string",
              "null"
            ],
            "description": "The visitor's IP address, IPv4 or IPv6, with the port and brackets of a socket\naddress stripped (`203.0.113.7:51234`, `[2001:db8::1]:443`); one with a zone\n(`fe80::1%eth0`), or one that does not parse, is none, and Set-up shows it.",
            "example": "203.0.113.7"
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "At most 512 bytes kept."
          },
          "headers": {
            "type": [
              "object",
              "null"
            ],
            "description": "The request's headers by name, each a string; at most 32 with a value are kept, each\nvalue at most 512 bytes: first those Korzen reads (the ones the SDKs forward, and a\nWeb Bot Auth signature's), then the others by name. A `null` value is an absent\nheader. A header your custom rules name is compared with the rule's hashed secret\nand never reaches scoring.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "header_order": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The names of the request's headers in the order received, lower-cased. A hint: a\nvalue that is not a list of header names is read as none, never refused."
          },
          "token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `_kz` cookie the tag set.",
            "maxLength": 256
          },
          "path": {
            "type": [
              "string",
              "null"
            ],
            "description": "The protected action's path. Korzen keeps it without its query or fragment: what\nfollows `?` or `#` is dropped before anything is stored.",
            "example": "/signup",
            "maxLength": 512
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "example": "POST",
            "maxLength": 16
          },
          "action": {
            "type": [
              "string",
              "null"
            ],
            "description": "The protected action's name, as your custom rules name it, for a path that serves\nseveral actions (a GraphQL or RPC endpoint). Read only by your custom rules, never\nkept.",
            "example": "signup",
            "maxLength": 256
          },
          "scheme": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Scheme",
                "description": "The scheme your server received the request on, from its own view (`req.protocol`,\n`r.TLS`), or from `X-Forwarded-Proto` only behind a proxy you trust. Over `http` a\nbrowser sends no Client Hints and no Fetch Metadata, and their absence is not read;\nabsent, they are read as before. Another value is none."
              },
              {
                "type": "null"
              }
            ]
          },
          "ja4": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "http_protocol": {
            "type": [
              "string",
              "null"
            ],
            "example": "h2",
            "maxLength": 16
          },
          "tls_group": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "description": "The visitor's country, ISO 3166-1 alpha-2, as your edge reports it; a longer value is\nnone, never cut.",
            "example": "DE",
            "maxLength": 2
          },
          "asn": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The visitor's network's ASN, as your edge reports it.",
            "minimum": 0
          },
          "client_tcp_rtt_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The smoothed TCP round trip between the visitor and your edge, in whole\nmilliseconds, as the edge measured it (Cloudflare's `request.cf.clientTcpRtt`, on\nevery plan, over HTTP/1 and HTTP/2; none over HTTP/3). 0, a negative number or one\npast 60 000 is none.",
            "example": 22
          },
          "cloudflare_detection_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "The ids of the heuristic detections Cloudflare Bot Management made on the request\n(`request.cf.botManagement.detectionIds`, Enterprise Bot Management only); the first\n16 are kept.",
            "example": [
              50331651
            ]
          },
          "claims": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ClaimsRequest",
                "description": "What your server knows about the account."
              },
              {
                "type": "null"
              }
            ]
          },
          "context": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ContextRequest",
                "description": "What your server knows of the person behind the request: hashed by\nthe SDK, re-keyed on receipt, never stored as sent."
              },
              {
                "type": "null"
              }
            ]
          },
          "protected_action": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "A protected action: only a browser that went through your page, where the tag ran,\ntakes it, once. The decision spends the token the tag earned there; a retry within\n2 minutes is the same try, and past them the token is spent for an hour. When your\napp then refuses the action for its own reasons (a weak password, a name taken),\ngive the use back (`POST /v1/give-back`), so the person's next try is a first one.\n`null` is false."
          },
          "require_token": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "The former name of `protected_action`, deprecated: still read, the same. The action\nis protected when either is true.",
            "deprecated": true
          },
          "places_per_identity": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "How many places one `context.identity_hash` may hold on this path within an hour,\nfrom 1 to 10, 1 when absent; a whole number past them is cut to them. Counted only\nin a protected action.",
            "example": 2,
            "maximum": 10,
            "minimum": 1
          },
          "ip_from": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/IpFrom",
                "description": "Where your integration read `ip` from: `peer` (the connection), `cloudflare`\n(`CF-Connecting-IP`), `last_forwarded` (the last `X-Forwarded-For` entry, your own\nproxy's), `first_forwarded` (the first one) or `custom` (a resolver of your own).\nOnly `peer` may make the decision your own server's (`own_server`): a visitor can\nwrite a header whenever your origin also answers traffic sent to it directly. None\nsent, or another value, is `custom`'s."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "EventFields": {
        "type": "object",
        "description": "One event: a request the customer's server saw, after the fact.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/EventKind"
          },
          "ts_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "When the request came, in Unix milliseconds; none is now.",
            "minimum": 0
          },
          "status": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The status the customer's server answered.",
            "maximum": 599,
            "minimum": 100
          },
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The request_id of the decision this event answers: it then only reports the status\nthe customer gave it.",
            "maxLength": 96
          },
          "event_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's id for the event: sent again within the idle window, it changes\nnothing.",
            "maxLength": 64
          },
          "ip": {
            "type": [
              "string",
              "null"
            ]
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ]
          },
          "headers": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "header_order": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "token": {
            "type": [
              "string",
              "null"
            ]
          },
          "path": {
            "type": [
              "string",
              "null"
            ],
            "description": "The path, kept without its query or fragment."
          },
          "method": {
            "type": [
              "string",
              "null"
            ]
          },
          "scheme": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Scheme",
                "description": "The scheme the customer's server received the request on."
              },
              {
                "type": "null"
              }
            ]
          },
          "ja4": {
            "type": [
              "string",
              "null"
            ]
          },
          "http_protocol": {
            "type": [
              "string",
              "null"
            ]
          },
          "tls_group": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "asn": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "EventKind": {
        "type": "string",
        "description": "What an event was: a page a person loads, or a call a script makes.",
        "enum": [
          "page",
          "api"
        ]
      },
      "EventsBody": {
        "type": "object",
        "description": "POST /v1/events' body.",
        "required": [
          "events"
        ],
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventFields"
            },
            "description": "1 to 1000 events.",
            "maxItems": 1000,
            "minItems": 1
          }
        },
        "additionalProperties": false
      },
      "FeedbackBody": {
        "type": "object",
        "description": "POST /v1/feedback's body.",
        "required": [
          "feedback"
        ],
        "properties": {
          "feedback": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeedbackFields"
            },
            "description": "1 to 1000 pieces of feedback.",
            "maxItems": 1000,
            "minItems": 1
          }
        },
        "additionalProperties": false
      },
      "FeedbackFields": {
        "type": "object",
        "description": "One piece of feedback: a session named by the request_id of one of its decisions, or by\nits token, exactly one of them.",
        "required": [
          "outcome"
        ],
        "properties": {
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 96
          },
          "token": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 256
          },
          "outcome": {
            "$ref": "#/components/schemas/Outcome"
          }
        },
        "additionalProperties": false
      },
      "GiveBackAnswer": {
        "type": "object",
        "description": "POST /v1/give-back's answer.",
        "required": [
          "given_back"
        ],
        "properties": {
          "given_back": {
            "type": "boolean",
            "description": "Whether the decision's use of the token, or the identity's place it took, was given\nback. False for a decision that was no protected action, took nothing, was refused\n(Korzen gave it back then), is past its hour, was given back already, or is no\ndecision of yours: in each, the person's next try is what it would be anyway."
          }
        }
      },
      "GiveBackBody": {
        "type": "object",
        "description": "POST /v1/give-back's body.",
        "required": [
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string",
            "description": "The `request_id` of the protected action's decision, as /v1/decide answered it.",
            "maxLength": 96,
            "minLength": 1
          }
        },
        "additionalProperties": false
      },
      "IpFrom": {
        "type": "string",
        "description": "Where the integration read the visitor's `ip` from: the connection's\naddress, or a header. Only an address a visitor cannot write may be the customer's own\nserver's.",
        "enum": [
          "peer",
          "cloudflare",
          "last_forwarded",
          "first_forwarded",
          "custom"
        ]
      },
      "ItemCode": {
        "type": "string",
        "description": "Why one item of a batch was rejected.",
        "enum": [
          "too_old",
          "too_far_ahead",
          "seconds_not_ms",
          "forged",
          "no_session",
          "deadline",
          "unavailable",
          "internal",
          "unknown"
        ]
      },
      "ItemError": {
        "type": "object",
        "description": "One item of a batch rejected.",
        "required": [
          "index",
          "code",
          "detail"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "description": "The item's place in the batch, from 0.",
            "minimum": 0
          },
          "code": {
            "$ref": "#/components/schemas/ItemCode"
          },
          "detail": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Mode": {
        "type": "string",
        "description": "The tenant's mode at the decision: monitor answers allow and says what block would.",
        "enum": [
          "monitor",
          "block",
          "paused"
        ]
      },
      "Outcome": {
        "type": "string",
        "description": "What the customer learned later about a session.",
        "enum": [
          "verified_human",
          "good_customer",
          "chargeback",
          "fraud"
        ]
      },
      "PhoneTypeName": {
        "type": "string",
        "description": "A phone number's type, as libphonenumber's `PhoneNumberType` names it, lower case. A\ncarrier lookup's types map onto it: Twilio's `nonFixedVoip` is `voip`, its `fixedVoip`\nand `landline` are `fixed_line`. The API's spelling of\n[`kz_bp_engine::PhoneType`], for the document: the field itself is read as a string, so\na name Korzen does not know is left out, never a 400.",
        "enum": [
          "mobile",
          "fixed_line",
          "fixed_line_or_mobile",
          "voip",
          "toll_free",
          "premium_rate",
          "shared_cost",
          "personal_number",
          "pager",
          "uan",
          "voicemail",
          "unknown"
        ]
      },
      "Problem": {
        "type": "object",
        "description": "An error answer (RFC 9457): every member is present; `request_id` is null only for an\nanswer made outside a call (a test's).",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "detail",
          "request_id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "`https://korzen.dev/bot-protection/docs/server-call#<code>`: the code's row in the\nserver call's errors.",
            "example": "https://korzen.dev/bot-protection/docs/server-call#unknown_field"
          },
          "title": {
            "type": "string",
            "description": "The code's title, the same every time."
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "description": "The HTTP status.",
            "example": 400,
            "minimum": 0
          },
          "code": {
            "$ref": "#/components/schemas/Code"
          },
          "detail": {
            "type": "string",
            "description": "What happened this time, for a person.",
            "example": "unknown field `requireToken`, expected one of …"
          },
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The call's `Korzen-Request-Id`."
          }
        },
        "additionalProperties": false
      },
      "Scheme": {
        "type": "string",
        "description": "The scheme the customer's server received the visitor's request on. A browser sends\nits Client Hints and its Fetch Metadata only to a secure origin, so over `http` their\nabsence is not read; none said is read as before.",
        "enum": [
          "http",
          "https"
        ]
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "kz_ak_…",
        "description": "Your API key, from Set-up: kz_ak_ and 36 characters."
      }
    }
  },
  "security": [
    {
      "apiKey": []
    }
  ]
}
