Drawing 1 · Interactive
Will a code generator accept this spec?
Minifying strips the whitespace people need and machines don’t, so every request is smaller.
Pretty-printed JSON.
- Bytes before
- 700
- Bytes after
- 353
- Saved
- 50%
- 700 → 353 bytes: 50% smaller.
- Only whitespace between tokens was removed — spaces inside strings are data and stay.
- Minify what goes over the wire; keep the pretty version for people.
What is the OpenAPI Specification?
The OpenAPI Specification (OAS) is an open standard for describing HTTP APIs in a machine-readable document, maintained by the OpenAPI Initiative under the Linux Foundation. A single YAML or JSON file covers the whole API: its servers, every path and HTTP method, the parameters and request bodies each one accepts, the response schemas and status codes it returns, and the security schemes it needs. It grew out of the Swagger specification. Version 2.0 is still often called Swagger, while current documents use OpenAPI 3.0 or 3.1.
Because the description is structured, tools can do the repetitive work. They can render interactive reference documentation and generate client libraries and server stubs in dozens of languages. They can spin up mock servers that return example responses, validate requests and responses in tests, and import a whole API into tools such as Postman. In OAS 3.1, schemas are full JSON Schema, so the definition that documents a message object can also validate one.
For WhatsApp, Meta publishes an OpenAPI file for the Business Messaging (WhatsApp) API in its public facebook/openapi repository on GitHub, which its README says is designed for generating SDKs. The file uses OpenAPI 3.1, with https://graph.facebook.com as its server, a bearer-token security scheme and paths templated as /{Version}/{Phone-Number-ID}/messages. It is named after the Graph API version it describes: as of October 2026 that is business-messaging-api_v23.0.yaml, three versions behind the current v26.0. Check which endpoints and fields it covers before you generate code from it.
An OpenAPI document is a contract, not an implementation. An SDK is code generated from that contract or written against it, and a Postman collection is a set of runnable requests. The spec underneath is what keeps all of them consistent with each other and with the REST API they describe.
Key takeaways
- The OpenAPI Specification is a vendor-neutral format for describing an HTTP API in YAML or JSON, so that machines can read it.
- Meta publishes an OpenAPI 3.1 file for the WhatsApp Business Platform in its facebook/openapi repository on GitHub.
- One spec file can generate reference docs, typed clients, mock servers, request validators and contract tests.
- An OpenAPI file is the contract and an SDK is code built on it. The spec itself never sends a request.
- As of October 2026, Meta's file describes Graph API v23.0, three versions behind v26.0, so check newer fields against the reference docs.
Implementation
The OpenAPI Specification in code
openapi: 3.1.0info:title: WhatsApp Cloud API (excerpt)version: v26.0servers:- url: https://graph.facebook.comcomponents:securitySchemes:bearerAuth:type: httpscheme: bearerdescription: System user access tokenpaths:/{Version}/{Phone-Number-ID}/messages:post:operationId: sendMessagesecurity:- bearerAuth: []parameters:- name: Versionin: pathrequired: trueschema: { type: string, pattern: '^v[0-9]+\.[0-9]+$' }example: v26.0- name: Phone-Number-IDin: pathrequired: trueschema: { type: string, pattern: '^[0-9]+$' }requestBody:required: truecontent:application/json:schema:type: objectrequired: [messaging_product, to, type]properties:messaging_product: { const: whatsapp }to: { type: string, description: Recipient phone number or WhatsApp ID }type: { enum: [text, template, image, document, interactive] }responses:"200":description: Accepted. The body carries the message ID (wamid).
Simplified for illustration, using the path style of Meta's file. The real v23.0 file runs to more than 30,000 lines of YAML.
Operating sequence
How does the OpenAPI Specification work?
Describe or fetch the contract
Write an
openapi.yamlfor your own API, or download a published one such as Meta's Business Messaging file from facebook/openapi. Note theopenapiversion (3.0 or 3.1) and the API version ininfo.version.Lint and validate it
Run a linter or validator so that broken
$refs, missing schemas and invalid YAML fail fast. A spec that does not parse cannot generate anything.Generate what you need
Feed the file to a generator for a typed client in TypeScript, Python, Java or Go, to a renderer for reference pages, or to a mock server so front-end work can start before the backend is ready.
Test against the contract
Validate real requests and responses against the schemas in CI. When a field is renamed or a required property goes missing, the contract test fails before customers notice.
Version it with the API
Keep one spec for each API version, and diff the old and new files when you upgrade. For WhatsApp, compare the version in the spec with the Graph API version your code actually calls.
Design intent
Why does the OpenAPI Specification matter?
A WhatsApp integration touches dozens of endpoints: messages, media, templates, phone numbers and business profiles. Each has nested JSON that can change between Graph API versions. With a machine-readable contract, a team can generate a typed client instead of hand-writing request shapes, and catch a misspelt field in CI instead of in production. It can also diff two versions of the spec to see exactly what an upgrade changes. For a platform team supporting many developers, the spec is the single source for docs and examples as well.
Specifications
The OpenAPI Specification: key facts and limits
- Current versions
- OpenAPI 3.0 and 3.1 (2.0 is "Swagger")
- Formats
- YAML or JSON
- Maintainer
- OpenAPI Initiative (Linux Foundation)
- Schema language (3.1)
- JSON Schema 2020-12
- Meta's WhatsApp file
- facebook/openapi on GitHub, OpenAPI 3.1
- Version described (Oct 2026)
- business-messaging-api_v23.0.yaml; current Graph API is v26.0
- Typical outputs
- Docs, clients, server stubs, mocks, contract tests
Failure modes
Common mistakes with the OpenAPI Specification
Treating the spec as always current
A published file describes one API version at one moment. Meta's file is named after the Graph API version it covers (v23.0 as of October 2026), while code samples today call v26.0. Compare the two, and check the reference docs for any field or endpoint added since.
Generating a client for the whole surface
A generator run over a very large spec produces thousands of lines you will never call, and slows builds. Generate only the tags or paths you use, or wrap the generated code behind a small interface of your own.
Hand-editing generated code
The next regeneration overwrites your edits. Put customisations such as retries, logging and token refresh in a wrapper or in the generator's templates, never in the generated files.
Confusing validation with behaviour
A request can match the schema and still fail. The 24-hour window, template approval, rate limits and permissions are business rules a spec cannot express. Keep handling API error codes, even with a perfect client.
Example: One typed client for six services in Pune
A Pune fintech's platform team wants a single internal WhatsApp client for six services. They pull Meta's Business Messaging OpenAPI file, keep only the messages, media and template paths they use, and generate a TypeScript client in CI. When a developer passes template.language as a plain string instead of an object with a code, the compiler flags it before review. On each Graph API upgrade, they diff the new spec against the old one and review only the operations that changed.
Recommended practice
Best practices for the OpenAPI Specification
- Pin the spec file in your repo and update it deliberately, with the diff visible in the pull request.
- Use the spec's examples to seed a mock server for front-end and QA work.
- Run a contract test in CI that validates a recorded real response against the schema.
- Import the spec into Postman when you want runnable requests alongside the docs.