Skip to content

Commit 7f9db79

Browse files
docs(callbacks): document callback model
1 parent b1560f2 commit 7f9db79

1 file changed

Lines changed: 144 additions & 0 deletions

File tree

docs/callbacks.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Callbacks In Openapi APIs
2+
3+
This note summarizes how callbacks are used across the Openapi specifications in [`oas/`](/home/francesco/Develop/Openapi/openapi-cli/oas/00-list.txt).
4+
5+
## Base Rule
6+
7+
In the usual callback model, the caller submits a request and also provides a callback URL owned by the caller.
8+
9+
That means:
10+
11+
- the client exposes an HTTP endpoint
12+
- the client passes that endpoint to the API, typically in a field such as `callback`, `callback.url`, or `callback_data.url`
13+
- the Openapi service calls that URL later when the asynchronous result is ready or when the workflow changes state
14+
15+
This is the default mental model to use for almost all callback-producing APIs in this repository.
16+
17+
The main exception is `oauthv2`: it is not the place where the callback URL is supplied for business workflows. Instead, it provides a platform-level view of callback executions through `/callbacks` and `/callbacks/{id}`.
18+
19+
## Main Ideas
20+
21+
Callbacks appear when an API cannot guarantee that the full business result is available in the same HTTP response.
22+
23+
The recurring patterns are:
24+
25+
1. Asynchronous document or report production.
26+
The initial `POST` opens a request, while the final outcome arrives later through a callback or through later polling on `{id}` endpoints.
27+
28+
2. Operational notifications.
29+
The callback is used to notify state transitions such as completion, delivery, activation, signature result, monitoring hits, or evidence availability.
30+
31+
3. Hybrid async model.
32+
Many APIs support both polling and callback. This is important because it means callbacks are not a cosmetic feature: they are the scalable integration path, while polling is usually the fallback.
33+
34+
4. Callback payload customization.
35+
Several APIs expose callback schemas with fields such as URL, method, headers, custom data, retry policy, field wrapping, or extra metadata. The common intent is to let the integrator correlate the async event with its own workflow.
36+
37+
5. Callback observability.
38+
`oauthv2` is a special case: it does not produce domain events itself, but exposes `/callbacks` and `/callbacks/{id}` to inspect callback history. This makes callbacks a platform-level concern, not just a per-API feature.
39+
40+
## APIs That Use Callbacks
41+
42+
### Highest importance
43+
44+
- `invoice`
45+
The callback is central because invoicing flows are stateful and long-running. Configuration changes, receipt handling, and invoice lifecycle events all benefit from push delivery instead of polling.
46+
47+
- `sdi`
48+
Very high importance. SDI is intrinsically event-driven: invoice submission, notifications, signature, legal storage, and simulation flows all produce delayed outcomes where callbacks are operationally critical.
49+
50+
- `company`
51+
High importance for monitoring and enriched asynchronous business intelligence. The `/monitor` flow is explicitly callback-oriented, and some high-value datasets also expose callback-aware async behavior.
52+
53+
- `risk`
54+
High importance because many reports, KYC checks, patrimonial products, and monitoring flows are not instantaneous. Callbacks reduce latency and orchestration complexity in credit/risk pipelines.
55+
56+
- `ufficiopostale`
57+
High importance because postal products, registered mail, telegrams, massive mailings, and court-related shipments evolve over time. Delivery and processing updates are a natural callback use case.
58+
59+
- `visurecamerali`
60+
High importance in practice because registry documents and business-register extractions are classic asynchronous document workflows. Callback support is valuable when requesting large volumes or integrating into back-office automation.
61+
62+
- `docuengine`
63+
High importance for the same reason: request creation and later document availability fit the callback model well, especially for document-heavy integrations.
64+
65+
- `visengine`
66+
High importance. The API is structured around requests, searches, and later document fulfillment, and its `CallbackData` model shows callbacks are part of the intended orchestration pattern.
67+
68+
### Medium importance
69+
70+
- `pec`
71+
Medium to high importance. PEC creation, activation, modification, conservation, transformation, and related workflows benefit from callback-driven updates because mailbox provisioning and lifecycle operations are not always immediate.
72+
73+
- `catasto`
74+
Medium to high importance. Cadastral, mortgage, map extract, and address-related requests often behave like asynchronous retrieval jobs, so callbacks help in document retrieval and workflow continuity.
75+
76+
- `esignature`
77+
Medium to high importance. Signature and certificate issuance workflows frequently need post-submission updates, especially when human actions or external providers are involved.
78+
79+
- `firmadigitale`
80+
Medium to high importance. Similar to `esignature`, with request lifecycle and delayed completion as the main reason callbacks matter.
81+
82+
- `bollettini`
83+
Medium importance. Payment-related flows can require post-request confirmation or downstream outcome notification.
84+
85+
- `gatewaysms`
86+
Medium importance. Messaging platforms commonly use callbacks for delivery reports or message-state updates, even if the visible path structure in the spec is narrower than in document APIs.
87+
88+
- `trust`
89+
Medium importance. Identity, mobile, email, IP, URL, and IDV checks can produce asynchronous outcomes, especially when deeper verification or expert review is involved.
90+
91+
### Platform and observability importance
92+
93+
- `oauthv2`
94+
Strategic importance rather than domain importance. It is the callback observability surface of the platform, via `/callbacks` and `/callbacks/{id}`. This is important because it lets integrators audit, troubleshoot, and inspect the callback layer itself.
95+
96+
## Practical Reading
97+
98+
If an API exposes:
99+
100+
- a `POST` that creates a request,
101+
- a `GET /{id}` to inspect status,
102+
- and callback-related schema fields such as `callback`, `callback_data`, or `callbacks`,
103+
104+
then that API should be treated as async-first.
105+
106+
In operational terms, the most callback-dependent families in this repository are:
107+
108+
- invoicing and SDI
109+
- company monitoring and risk monitoring
110+
- document retrieval and official certificates
111+
- postal and delivery workflows
112+
- signature and identity verification workflows
113+
114+
## Paths With Explicit Callback Presence
115+
116+
The OAS files with explicit callback presence in paths or operation definitions are:
117+
118+
- `bollettini`
119+
- `catasto`
120+
- `company`
121+
- `docuengine`
122+
- `esignature`
123+
- `firmadigitale`
124+
- `gatewaysms`
125+
- `invoice`
126+
- `oauthv2`
127+
- `pec`
128+
- `risk`
129+
- `sdi`
130+
- `trust`
131+
- `ufficiopostale`
132+
- `visengine`
133+
- `visurecamerali`
134+
135+
## Conclusion
136+
137+
Across this repository, callbacks are not an edge feature. They are one of the main architectural patterns used by Openapi whenever the business result is delayed, multi-step, externally dependent, or operationally monitored.
138+
139+
The most important takeaway is this:
140+
141+
- polling tells you the current state
142+
- callbacks let the platform tell you when the state matters
143+
144+
For high-volume or production-grade integrations, the callback path should generally be considered the primary integration model.

0 commit comments

Comments
 (0)