---
source: https://iinventedlight.com/library/notes/openapi-callbacks.md
title: "Document an OpenAPI callback that your API initiates"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (OpenAPI Initiative); MIT (FastAPI); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: OpenAPI Initiative, OpenAPI Specification; FastAPI, OpenAPI Callbacks. Apache-2.0; MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: OpenAPI callbacks and FastAPI"
tags: [openapi, callbacks, fastapi, http]
client: Librarian
sources:
  - id: S1
    title: "OpenAPI Specification"
    publisher: OpenAPI Initiative
    url: https://spec.openapis.org/oas/latest.html
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "OpenAPI Callbacks"
    publisher: FastAPI
    url: https://fastapi.tiangolo.com/advanced/openapi-callbacks/
    accessed: 2026-11-19
    license: "MIT"
---
# Document an OpenAPI callback that your API initiates
**Answer:** An OpenAPI callback documents a request that the API provider may initiate, related to a parent operation. FastAPI names a call to an external API a "callback". A query parameter can contain the URL for the callback.

## Callback Objects

Callbacks live in a map related to the parent operation. The key uniquely identifies each Callback Object. Each value describes a request that may be initiated by the API provider.

## Documenting a callback in FastAPI

The example app has a path operation and a query parameter `callback_url` that will contain the URL for the callback. An `APIRouter` shows the callback path, such as `{$callback_url}/invoices/{$request.body.id}`.

| OpenAPI | FastAPI |
|---|---|
| Callback Object | Request the API provider may initiate |
| parent operation | Operation the callbacks map is related to |
| callback_url | Query parameter that contains the callback URL |
| APIRouter | Used to declare the callback path |

## See also

- [fastapi-request-body](https://iinventedlight.com/library/notes/fastapi-request-body/)
- [fastapi-response-model](https://iinventedlight.com/library/notes/fastapi-response-model/)
- [http-status-codes](https://iinventedlight.com/library/notes/http-status-codes/)

## Claims

- id: C1
  claim: An OpenAPI callback describes a request the API provider may initiate after the parent operation.
  source: S1
  evidence: "A map of possible out-of band callbacks related to the parent operation."

- id: C2
  claim: Each Callback Object describes that request and the expected responses.
  source: S1
  evidence: "describes a request that may be initiated by the API provider"

- id: C3
  claim: FastAPI treats a call to an external API as a callback and can document the callback URL.
  source: S2
  evidence: "query parameter callback_url that will contain the URL for the callback"

## Sources

- [S1] OpenAPI Specification. OpenAPI Initiative. https://spec.openapis.org/oas/latest.html . License: Apache-2.0. Accessed 2026-11-19.

- [S2] OpenAPI Callbacks. FastAPI. https://fastapi.tiangolo.com/advanced/openapi-callbacks/ . License: MIT. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: OpenAPI Initiative, OpenAPI Specification; FastAPI, OpenAPI Callbacks. Apache-2.0; MIT. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
