{
  "openapi": "3.1.0",
  "info": {
    "title": "VerifNer API",
    "version": "1.0.0",
    "description": "Identity verification for Nigerien passports and national identity cards. One call, a reasoned verdict: five checks with evidence, a score, VERIFIED at 0.90 and above, REVIEW from 0.60, REJECTED below."
  },
  "servers": [
    {
      "url": "https://api.verifner.com"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Verify",
      "description": "Server-to-server verification with the secret key."
    },
    {
      "name": "Sessions",
      "description": "Browser flows: your server opens a session, the web SDK uploads with a client token."
    },
    {
      "name": "Webhooks",
      "description": "verification.completed, signed with HMAC-SHA256, retried with backoff."
    }
  ],
  "paths": {
    "/v1/verify": {
      "post": {
        "tags": [
          "Verify"
        ],
        "summary": "Verify a document, and optionally a selfie, synchronously",
        "description": "Send an `Idempotency-Key` header to make retries safe: the same key returns the original result with `Idempotent-Replayed: true`. Test keys (`vn_test_`) run the full pipeline and never store images.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "front"
                ],
                "properties": {
                  "front": {
                    "type": "string",
                    "format": "binary",
                    "description": "Document front (passport data page). JPEG, PNG or WebP, up to 12 MB."
                  },
                  "back": {
                    "type": "string",
                    "format": "binary",
                    "description": "CNI back. Omit for a passport."
                  },
                  "selfie": {
                    "type": "string",
                    "format": "binary",
                    "description": "Live photo of the holder. Omit to skip the face check."
                  },
                  "chip": {
                    "type": "string",
                    "description": "Optional. The chip object of the JSON body, as a JSON string."
                  },
                  "liveness": {
                    "type": "string",
                    "description": "Optional. The liveness object of the JSON body, as a JSON string."
                  },
                  "metadata": {
                    "type": "string",
                    "description": "Optional. The metadata object of the JSON body, as a JSON string. Ignored on a session upload: the session’s own applies."
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "front"
                ],
                "properties": {
                  "front": {
                    "type": "string",
                    "description": "base64"
                  },
                  "back": {
                    "type": "string"
                  },
                  "selfie": {
                    "type": "string"
                  },
                  "chip": {
                    "type": "object",
                    "description": "Files read from the document chip over NFC (ICAO 9303), base64, as read. Adds the chip_authenticity check.",
                    "required": [
                      "sod",
                      "dg1"
                    ],
                    "properties": {
                      "sod": {
                        "type": "string",
                        "description": "EF.SOD, base64"
                      },
                      "dg1": {
                        "type": "string",
                        "description": "EF.DG1 (MRZ), base64"
                      },
                      "dg2": {
                        "type": "string",
                        "description": "EF.DG2 (portrait), base64. Used for the face check when present."
                      }
                    }
                  },
                  "liveness": {
                    "type": "object",
                    "description": "Active liveness, collected by the SDKs: the head-turn challenge shown to the person (directions in a random order, their own left and right) and the small frames taken while they followed it (320 px JPEG, 3 to 12). Needs a selfie. The server reads the head pose on each frame against the selfie and adds the liveness check; the frames are analysed and discarded, never stored.",
                    "required": [
                      "challenge",
                      "frames"
                    ],
                    "properties": {
                      "challenge": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 3,
                        "items": {
                          "type": "string",
                          "enum": [
                            "left",
                            "right",
                            "up"
                          ]
                        }
                      },
                      "frames": {
                        "type": "array",
                        "minItems": 3,
                        "maxItems": 12,
                        "items": {
                          "type": "string",
                          "description": "base64 JPEG, up to 200 KB"
                        }
                      }
                    }
                  },
                  "metadata": {
                    "type": "object",
                    "description": "Your own data for this session (an internal id, an amount, a product code), copied onto the verification and its events. At most 20 keys (a-z, 0-9, _), each a string (≤ 200 characters), a number or a boolean, 2 KB in all. Never personal data.",
                    "maxProperties": 20,
                    "propertyNames": {
                      "pattern": "^[a-z][a-z0-9_]{0,39}$"
                    },
                    "additionalProperties": {
                      "oneOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replayed from the idempotency key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "201": {
            "description": "Verdict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`insufficient_balance`: live key, and the prepaid wallet cannot pay for this verification. Nothing was run or billed; top up in the console.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`unreadable` (blurred front), `not_an_image`, or `extraction_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: 120 requests per minute per key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`service_busy`: too many verifications at once; nothing was recorded or billed. Retry after the Retry-After header (5 s).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/verifications/{id}": {
      "get": {
        "tags": [
          "Verify"
        ],
        "summary": "Read a verification",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^vrf_"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The result, plus `final_verdict` once a human reviewed it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "404": {
            "description": "Not found in your organisation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/verifications/{id}/images/{kind}": {
      "get": {
        "tags": [
          "Verify"
        ],
        "summary": "Get a short-lived URL to a stored image",
        "description": "Live keys only; the URL is valid 5 minutes and every issue and view is an audit event. `portrait` is the person's photo as VerifNer cut it: the chip's own portrait when an NFC chip was read and trusted, else the face found on the front. 410 when the image was never stored or has been purged after the retention window.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "front",
                "back",
                "selfie",
                "portrait"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "Image gone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Open a session for the web SDK",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reference": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Your identifier for this user or flow; echoed back, never interpreted."
                  },
                  "document_type": {
                    "type": "string",
                    "enum": [
                      "cni",
                      "passport"
                    ],
                    "description": "Ask for this document only; omitted, the person chooses."
                  },
                  "ttl_seconds": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 3600,
                    "default": 900
                  },
                  "metadata": {
                    "type": "object",
                    "description": "Your own data for this session (an internal id, an amount, a product code), copied onto the verification and its events. At most 20 keys (a-z, 0-9, _), each a string (≤ 200 characters), a number or a boolean, 2 KB in all. Never personal data.",
                    "maxProperties": 20,
                    "propertyNames": {
                      "pattern": "^[a-z][a-z0-9_]{0,39}$"
                    },
                    "additionalProperties": {
                      "oneOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session with its single-use client token",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Session"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "client_token": {
                          "type": "string",
                          "description": "Give this to the browser. Shown once."
                        },
                        "url": {
                          "type": "string",
                          "description": "Hosted capture page for this session (https://verify.verifner.com/#…). Send it to the person to verify instead of embedding the SDK; the token is in the fragment. Single use, expires with the session."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Bad key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions/{id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Read a session and its outcome",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^ses_"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Session"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "result": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "verdict": {
                              "$ref": "#/components/schemas/Verdict"
                            },
                            "final_verdict": {
                              "$ref": "#/components/schemas/Verdict",
                              "nullable": true
                            },
                            "score": {
                              "type": "number"
                            },
                            "document_type": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions/{id}/verify": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Upload from the browser with the client token",
        "description": "Authenticate with `Authorization: Bearer <client_token>`. CORS is open. A 402 or a 422 leaves the session usable; a 201 completes it.",
        "security": [
          {
            "clientToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "front"
                ],
                "properties": {
                  "front": {
                    "type": "string",
                    "format": "binary",
                    "description": "Document front (passport data page). JPEG, PNG or WebP, up to 12 MB."
                  },
                  "back": {
                    "type": "string",
                    "format": "binary",
                    "description": "CNI back. Omit for a passport."
                  },
                  "selfie": {
                    "type": "string",
                    "format": "binary",
                    "description": "Live photo of the holder. Omit to skip the face check."
                  },
                  "chip": {
                    "type": "string",
                    "description": "Optional. The chip object of the JSON body, as a JSON string."
                  },
                  "liveness": {
                    "type": "string",
                    "description": "Optional. The liveness object of the JSON body, as a JSON string."
                  },
                  "metadata": {
                    "type": "string",
                    "description": "Optional. The metadata object of the JSON body, as a JSON string. Ignored on a session upload: the session’s own applies."
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "front"
                ],
                "properties": {
                  "front": {
                    "type": "string",
                    "description": "base64"
                  },
                  "back": {
                    "type": "string"
                  },
                  "selfie": {
                    "type": "string"
                  },
                  "chip": {
                    "type": "object",
                    "description": "Files read from the document chip over NFC (ICAO 9303), base64, as read. Adds the chip_authenticity check.",
                    "required": [
                      "sod",
                      "dg1"
                    ],
                    "properties": {
                      "sod": {
                        "type": "string",
                        "description": "EF.SOD, base64"
                      },
                      "dg1": {
                        "type": "string",
                        "description": "EF.DG1 (MRZ), base64"
                      },
                      "dg2": {
                        "type": "string",
                        "description": "EF.DG2 (portrait), base64. Used for the face check when present."
                      }
                    }
                  },
                  "liveness": {
                    "type": "object",
                    "description": "Active liveness, collected by the SDKs: the head-turn challenge shown to the person (directions in a random order, their own left and right) and the small frames taken while they followed it (320 px JPEG, 3 to 12). Needs a selfie. The server reads the head pose on each frame against the selfie and adds the liveness check; the frames are analysed and discarded, never stored.",
                    "required": [
                      "challenge",
                      "frames"
                    ],
                    "properties": {
                      "challenge": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 3,
                        "items": {
                          "type": "string",
                          "enum": [
                            "left",
                            "right",
                            "up"
                          ]
                        }
                      },
                      "frames": {
                        "type": "array",
                        "minItems": 3,
                        "maxItems": 12,
                        "items": {
                          "type": "string",
                          "description": "base64 JPEG, up to 200 KB"
                        }
                      }
                    }
                  },
                  "metadata": {
                    "type": "object",
                    "description": "Your own data for this session (an internal id, an amount, a product code), copied onto the verification and its events. At most 20 keys (a-z, 0-9, _), each a string (≤ 200 characters), a number or a boolean, 2 KB in all. Never personal data.",
                    "maxProperties": 20,
                    "propertyNames": {
                      "pattern": "^[a-z][a-z0-9_]{0,39}$"
                    },
                    "additionalProperties": {
                      "oneOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Verdict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerificationResult"
                }
              }
            }
          },
          "401": {
            "description": "Bad token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`insufficient_balance`: the org’s wallet cannot pay; the session stays usable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`session_completed` or `session_expired`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Unreadable capture",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`service_busy`: retry after Retry-After; the session stays usable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions/{id}/mrz": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Read the chip access key from a document photo",
        "description": "For an app about to read the document chip over NFC. Authenticate with `Authorization: Bearer <client_token>`; multipart with one `image`, the photo that shows the MRZ (the passport data page, the back of a card). Answers the three values that open the chip, dates as printed (YYMMDD), only when every MRZ check digit holds; otherwise `{\"key\": null}` and the app asks the person. Nothing is stored or billed. 20 calls a minute per session.",
        "security": [
          {
            "clientToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "image"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The key, or null",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "document_number": {
                          "type": "string"
                        },
                        "date_of_birth": {
                          "type": "string"
                        },
                        "date_of_expiry": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bad token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions/{id}/precheck": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Check a document photo before it is confirmed",
        "description": "What the web SDK calls on its review screen. Authenticate with `Authorization: Bearer <client_token>`; multipart with one `image`. A vision model says what to fix, the most basic first: `not_a_document`, `wrong_side`, `cut_off`, `obstructed`, `glare`, `illegible`, or null. Advice only: nothing is stored or billed, and on any error or timeout the answer is `{\"issue\": null, \"checked\": false}`. 20 calls a minute per session.",
        "security": [
          {
            "clientToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "document",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "cni",
                "cni_old",
                "passport"
              ],
              "default": "cni"
            }
          },
          {
            "name": "side",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "front",
                "back"
              ],
              "default": "front"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "image"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "issue": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "not_a_document",
                        "wrong_side",
                        "cut_off",
                        "obstructed",
                        "glare",
                        "illegible",
                        null
                      ]
                    },
                    "checked": {
                      "type": "boolean"
                    },
                    "latency_ms": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No image, or a bad query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Bad token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Register an endpoint",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "https to a public host; localhost and private addresses are refused"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Endpoint with its signing secret, shown once",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "secret": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List endpoints",
        "responses": {
          "200": {
            "description": "Endpoints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/{id}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Remove an endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/{id}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Last 50 deliveries with their state and attempts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deliveries"
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Live event stream (server-sent events)",
        "description": "What `verifner listen` reads: each `verification.completed` of the key’s organisation, application and mode, as `event:`/`data:` frames with the same JSON as the webhook; a `: ping` comment every 15 s. For development; production integrations use webhooks.",
        "responses": {
          "200": {
            "description": "text/event-stream"
          },
          "401": {
            "description": "Missing or unknown key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/logs": {
      "get": {
        "tags": [
          "Logs"
        ],
        "summary": "Recent API calls, newest first",
        "description": "Calls to the API by the organisation’s keys and SDK sessions in the key’s mode: route, status, error code, duration, resource. Metadata only, never a body. What `verifner logs` shows.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calls"
          },
          "401": {
            "description": "Missing or unknown key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "verification.completed": {
      "post": {
        "summary": "Sent after every verdict, and again after a human review with `final_verdict` set",
        "description": "Headers: `VerifNer-Signature: t=<unix>,v1=<hex HMAC-SHA256(secret, \"<t>.<raw body>\")>`, `VerifNer-Event`, `VerifNer-Delivery`. Reject timestamps older than 5 minutes. Retried 8 times over about four hours until a 2xx.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx acknowledges"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "`vn_live_…` or `vn_test_…`, from the console."
      },
      "clientToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "`vn_ct_…` from POST /v1/sessions."
      }
    },
    "schemas": {
      "Verdict": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "string",
        "enum": [
          "verified",
          "review",
          "rejected"
        ]
      },
      "Check": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "enum": [
              "mrz_checksum",
              "expiry",
              "viz_mrz_consistency",
              "tamper",
              "face_match",
              "chip_authenticity",
              "liveness"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pass",
              "warn",
              "fail",
              "skipped"
            ]
          },
          "score": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "evidence": {
            "type": "object",
            "properties": {
              "fr": {
                "type": "string"
              },
              "en": {
                "type": "string"
              }
            },
            "required": [
              "fr",
              "en"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "name",
          "status",
          "score",
          "evidence"
        ],
        "additionalProperties": false
      },
      "VerificationResult": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^vrf_[a-z0-9]{6,}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "VERIFIED",
              "REVIEW",
              "REJECTED"
            ]
          },
          "verdict": {
            "type": "string",
            "enum": [
              "verified",
              "review",
              "rejected"
            ],
            "description": "The published verdict: the workflow’s when one ran (it can only be stricter than the checks’), else the checks’."
          },
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "document_type": {
            "type": "string",
            "enum": [
              "passport",
              "cni",
              "unknown"
            ]
          },
          "document": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "passport",
                  "cni",
                  "unknown"
                ]
              },
              "country": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "fields": {
                "anyOf": [
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "mrz": {
                "type": "object",
                "properties": {
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "valid": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "lines",
                  "valid"
                ],
                "additionalProperties": false
              },
              "legibility": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          "fields": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          },
          "face_match": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "similarity": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "matched": {
                    "type": "boolean"
                  },
                  "faces_in_document": {
                    "type": "number"
                  },
                  "faces_in_selfie": {
                    "type": "number"
                  }
                },
                "required": [
                  "similarity",
                  "matched"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "enum": [
                    "mrz_checksum",
                    "expiry",
                    "viz_mrz_consistency",
                    "tamper",
                    "face_match",
                    "chip_authenticity",
                    "liveness"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "warn",
                    "fail",
                    "skipped"
                  ]
                },
                "score": {
                  "anyOf": [
                    {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "evidence": {
                  "type": "object",
                  "properties": {
                    "fr": {
                      "type": "string"
                    },
                    "en": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "fr",
                    "en"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "name",
                "status",
                "score",
                "evidence"
              ],
              "additionalProperties": false
            }
          },
          "rules_verdict": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "verified",
                  "review",
                  "rejected"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "The checks’ verdict, only when a workflow made `verdict` stricter; null otherwise."
          },
          "workflow": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "version": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "draft": {
                    "type": "boolean"
                  },
                  "run_id": {
                    "type": "string"
                  },
                  "decided": {
                    "type": "boolean"
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "team": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "completed",
                      "running",
                      "error"
                    ]
                  }
                },
                "required": [
                  "version",
                  "draft",
                  "run_id",
                  "decided",
                  "reason",
                  "team",
                  "status"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ],
            "description": "The application’s workflow that ran on this verification (Grands comptes plan): `version` (null for the test draft), `run_id`, `decided` (it changed the verdict), `reason`, `team`, `status` (`running` while sends are queued, `completed`, or `error`: the checks’ verdict stands). Null when none ran."
          },
          "metadata": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                },
                "additionalProperties": {
                  "anyOf": [
                    {
                      "type": "string",
                      "maxLength": 200
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "What you attached to the session or the request; null when nothing."
          },
          "timings": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "number"
            }
          },
          "latency_ms": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          }
        },
        "required": [
          "id",
          "verdict",
          "score",
          "document_type",
          "checks",
          "latency_ms",
          "created_at"
        ],
        "additionalProperties": false,
        "description": "Five checks, each with bilingual evidence. `final_verdict` appears on reads once a reviewer decided."
      },
      "Session": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "expired"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "document_type": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "cni",
                  "passport"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "The one document asked for; null lets the person choose."
          },
          "metadata": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": [
                    "string",
                    "number",
                    "boolean"
                  ]
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "What you attached when opening the session."
          },
          "verification_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          }
        },
        "required": [
          "id",
          "mode",
          "status",
          "reference",
          "document_type",
          "metadata",
          "verification_id",
          "expires_at",
          "created_at"
        ],
        "additionalProperties": false
      },
      "WebhookEndpoint": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          }
        },
        "required": [
          "id",
          "url",
          "description",
          "created_at"
        ],
        "additionalProperties": false
      },
      "WorkflowNotification": {
        "type": "object",
        "description": "Sent by a workflow’s Webhook block to the one endpoint it names, and by its HTTP block. Same envelope, headers and signature as every event.",
        "properties": {
          "id": {
            "type": "string",
            "description": "evt_…"
          },
          "type": {
            "type": "string",
            "enum": [
              "workflow.notification"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "description": "The block’s label (the host name for an HTTP block)"
              },
              "run_id": {
                "type": "string",
                "description": "wfr_…"
              },
              "step_id": {
                "type": "string",
                "description": "wfs_…, also sent as Idempotency-Key by the HTTP block"
              },
              "version": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "The published version; null for the test draft"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              "fields": {
                "type": "object",
                "additionalProperties": true,
                "description": "Only the fields chosen in the block, keyed by name (`verification_id`, `metadata.amount_xof`, `document.surname`…)"
              }
            }
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "evt_…, the same for every delivery of one event"
          },
          "type": {
            "type": "string",
            "enum": [
              "verification.completed"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/VerificationResult"
              },
              {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "live",
                      "test"
                    ]
                  },
                  "final_verdict": {
                    "$ref": "#/components/schemas/Verdict",
                    "nullable": true
                  }
                }
              }
            ]
          }
        }
      },
      "Error": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      }
    }
  }
}
