{
  "openapi": "3.1.0",
  "info": {
    "title": "OKYC API",
    "version": "2026-10-01",
    "description": "KYC/KYB verification API. India first."
  },
  "servers": [
    {
      "url": "https://api.okyc.stream/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Secret API key: sk_test_… or sk_live_…"
      }
    },
    "schemas": {
      "CreatedSession": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "started",
              "in_progress",
              "processing",
              "approved",
              "declined",
              "review",
              "resubmission_requested",
              "expired",
              "cancelled"
            ]
          },
          "url": {
            "type": "string"
          },
          "client_token": {
            "type": "string"
          },
          "expires_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "url",
          "client_token",
          "expires_at"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": "string"
              },
              "details": {},
              "request_id": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "CreateSession": {
        "type": "object",
        "properties": {
          "workflow_id": {
            "type": "string"
          },
          "reference_id": {
            "type": "string",
            "maxLength": 128,
            "description": "Your user's id"
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "description": "Applicant's country; defaults to the workflow's"
          },
          "prefill": {
            "type": "object",
            "properties": {
              "phone": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "full_name": {
                "type": "string"
              }
            }
          },
          "locale": {
            "type": "string"
          },
          "redirect_url": {
            "type": "string",
            "format": "uri"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 500
            }
          },
          "expires_in": {
            "type": "integer",
            "minimum": 300,
            "maximum": 2592000,
            "description": "Seconds"
          }
        },
        "required": [
          "workflow_id"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "session"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "kyc",
              "kyb"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "created",
              "started",
              "in_progress",
              "processing",
              "approved",
              "declined",
              "review",
              "resubmission_requested",
              "expired",
              "cancelled"
            ]
          },
          "country": {
            "type": "string"
          },
          "workflow_id": {
            "type": "string"
          },
          "reference_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "parent_session_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "decision": {
            "type": [
              "string",
              "null"
            ]
          },
          "decision_source": {
            "type": [
              "string",
              "null"
            ]
          },
          "steps": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "method": {
                  "type": "string"
                },
                "attempts": {
                  "type": "number"
                }
              },
              "required": [
                "status",
                "attempts"
              ]
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "expires_at": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            }
          },
          "applicant": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "business": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "related_sessions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "role": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "status": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "role",
                "status"
              ]
            }
          },
          "duplicates": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "session_id": {
                  "type": "string"
                },
                "signals": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "session_id",
                "signals"
              ]
            },
            "description": "Earlier sessions in this project that look like the same person or business"
          }
        },
        "required": [
          "id",
          "object",
          "mode",
          "type",
          "status",
          "country",
          "workflow_id",
          "reference_id",
          "parent_session_id",
          "decision",
          "decision_source",
          "steps",
          "metadata",
          "expires_at",
          "created_at",
          "completed_at",
          "duplicates"
        ]
      },
      "Check": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "step": {
            "type": [
              "string",
              "null"
            ]
          },
          "capability": {
            "type": [
              "string",
              "null"
            ]
          },
          "generic_key": {
            "type": "string"
          },
          "check_key": {
            "type": "string"
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "verified_by": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "source",
              "reviewer",
              null
            ],
            "description": "`source`: the issuing registry or a cryptographic check answered. `reviewer`: provider `manual` — a reviewer compared the uploaded document (no registry call). `null`: not decided yet."
          },
          "score": {
            "type": [
              "number",
              "null"
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "from_cache": {
            "type": "boolean"
          },
          "result": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {}
          },
          "created_at": {
            "type": "string"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "step",
          "capability",
          "generic_key",
          "check_key",
          "provider",
          "status",
          "verified_by",
          "score",
          "error_code",
          "from_cache",
          "created_at",
          "finished_at"
        ]
      },
      "Decision": {
        "type": "object",
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "approved",
              "declined",
              "resubmission_requested"
            ]
          },
          "reason_code": {
            "type": "string",
            "maxLength": 64
          },
          "note": {
            "type": "string",
            "maxLength": 2000
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "For resubmission: steps the applicant must redo"
          }
        },
        "required": [
          "outcome",
          "reason_code"
        ]
      },
      "DirectCheckInput": {
        "type": "object",
        "properties": {
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2
          }
        },
        "additionalProperties": {}
      },
      "WebhookEndpointCreate": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "default": [
              "*"
            ]
          }
        },
        "required": [
          "url"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/sessions": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Create a verification session",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSession"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedSession"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List sessions",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "starting_after",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "created",
                "started",
                "in_progress",
                "processing",
                "approved",
                "declined",
                "review",
                "resubmission_requested",
                "expired",
                "cancelled"
              ]
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "reference_id",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": [
                        "list"
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Session"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Retrieve a session",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "example": "checks,applicant"
            },
            "required": false,
            "name": "expand",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/decision": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Decide a session in review (or override a final decision)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Decision"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "outcome": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "status",
                    "outcome"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/cancel": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Cancel an active session",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "status"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/client_token": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Issue a fresh client token (resume in the frontend)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "client_token": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "client_token",
                    "url"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/evidence/{evidence_id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Short-lived URL for an evidence file",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "name": "evidence_id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "expires_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url",
                    "expires_at"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sessions/{id}/pii": {
      "delete": {
        "tags": [
          "Sessions"
        ],
        "summary": "Erase personal data (DPDP erasure)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "erased": {
                      "type": "boolean"
                    },
                    "files_deleted": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "erased",
                    "files_deleted"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/checks/{key}": {
      "post": {
        "tags": [
          "Checks"
        ],
        "summary": "Run a check without a hosted session",
        "description": "Country key (`in.pan.verify`) or generic key with `country` (`tax_id.verify` + `IN`). `?async=true` returns 202 and sends `check.completed`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "in.pan.verify"
            },
            "required": true,
            "name": "key",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            },
            "required": false,
            "name": "async",
            "in": "query"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DirectCheckInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Completed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          },
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/checks/{id}": {
      "get": {
        "tags": [
          "Checks"
        ],
        "summary": "Retrieve a check",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/capabilities": {
      "get": {
        "tags": [
          "Reference"
        ],
        "summary": "What a country supports",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            },
            "required": false,
            "name": "country",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        }
      }
    },
    "/document-types": {
      "get": {
        "tags": [
          "Reference"
        ],
        "summary": "Document types and their extractable fields",
        "description": "Catalog used by the `documents` workflow step. Each field is fully described (label, description, type, hints) — reference it by key, override it, or define custom fields.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            },
            "required": false,
            "name": "country",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        }
      }
    },
    "/workflows": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "List workflows",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        }
      }
    },
    "/workflows/{id}": {
      "get": {
        "tags": [
          "Workflows"
        ],
        "summary": "Retrieve a workflow",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook_endpoints": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create a webhook endpoint (the signing secret is returned once)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook endpoints",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        }
      }
    },
    "/webhook_endpoints/{id}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook endpoint",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "example": "ses_in_01j…"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List events (for reconciliation)",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "type",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {}
}
