Using the OpenAPI spec
The whole public API is described in one OpenAPI 3.1 file. The API reference on this site is generated from it, and our build checks it against the running code on every change, so it always matches what the API does.
Download: openapi.yaml
curl -O https://docs.opencontext.com/openapi.yamlGenerate a typed client
Section titled “Generate a typed client”Any OpenAPI 3.1 generator works. A few we have tried:
TypeScript, types only, with openapi-typescript and its small openapi-fetch client:
npx openapi-typescript openapi.yaml -o src/api.d.tsnpm install openapi-fetchimport createClient from "openapi-fetch";import type { paths } from "./api";
const api = createClient<paths>({ baseUrl: "https://api.opencontext.com", headers: { Authorization: `Bearer ${process.env.SECRET_KEY}` },});
const { data, error } = await api.POST("/v1/decision", { body: { event_type: "login", account_id: "cust_1842", request_id },});if (data?.recommendation === "deny") { /* … */ }Go, with oapi-codegen:
go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest \ -generate types,client -package fraudapi openapi.yaml > fraudapi/client.goPython, with openapi-python-client:
pipx run openapi-python-client generate --path openapi.yamlAnything else (Java, C#, Ruby, PHP, Kotlin, Swift) with OpenAPI Generator:
npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g java -o client-javaImport into an API tool
Section titled “Import into an API tool”Postman, Insomnia, Bruno, and Hoppscotch all import OpenAPI files: choose Import, pick openapi.yaml, and set the bearer token to a sandbox secret key. The spec’s examples come along as saved requests.
Use it with an AI coding agent
Section titled “Use it with an AI coding agent”Point your coding agent at the spec when it writes your integration; it describes every field, enum, and error code. Pair it with the MCP server so the agent can check real sandbox decisions while it works.
How the spec evolves
Section titled “How the spec evolves”- The API version is a date (
info.version, andversions.apion every decision). - New fields, new enum values, and new endpoints are additive. Write clients that ignore unknown fields and treat unknown enum values gracefully. Generated clients with strict enums may need
additionalPropertiesor a fallback case. - A breaking change gets a new version, announced ahead of time, with the old one kept running through a migration window.