On this page
A webhook definition can look complete while its destination example still contains a deployment placeholder, a staging hostname, or a secret. To test OpenAPI webhook callback URLs before a release, review both how destinations are selected and what the documented example values contain—without sending requests to customer endpoints.
This tutorial uses OpenAPI 3.1.0 syntax. The current specification could not be consulted in this run, and the examples were not executed. Check the specification and your tooling before relying on the examples for conformance.
Key Takeaways
- An OpenAPI callback can derive its destination from a runtime expression; inspect both the expression and the value it resolves to.
- A top-level webhook describes an incoming request but does not necessarily specify where it will be sent.
- Review example URLs offline for placeholders, non-production hosts, unexpected schemes, and sensitive values.
- Parsing a URL does not establish ownership, authorization, successful delivery, or receiver behavior.
Distinguish callbacks from top-level webhooks
A callback is associated with an API operation. Its URL can be selected using a runtime expression that reads data from the initiating request or response. For example, {$request.body#/callbackUrl} refers to the callbackUrl property in the request body.
A top-level webhooks entry describes a request the API provider may initiate independently of a particular API operation. Its name identifies the documented webhook; it is not automatically a destination URL. The actual destination might be configured through a subscription API or another arrangement, so review that configuration separately.
Advertisement
Review an OpenAPI callback expression
The following abbreviated OpenAPI 3.1.0 document shows both forms. The callback example is a fictional documentation URL; do not send requests to it.
openapi: 3.1.0
info:
title: Subscription API
version: '1.0'
paths:
/subscriptions:
post:
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [callbackUrl]
properties:
callbackUrl:
type: string
format: uri
example: https://hooks.example.com/events
responses:
'202':
description: Subscription accepted
callbacks:
subscriptionEvent:
'{$request.body#/callbackUrl}':
post:
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
event:
type: string
responses:
'200':
description: Event received
webhooks:
subscriptionChanged:
post:
responses:
'200':
description: Event received
The expression is intentional OpenAPI syntax, not an unresolved deployment placeholder. Review it separately from the URL value:
- Trace the expression to the documented request body property. Confirm that the property exists in the relevant media type and is required if the callback depends on it.
- Inspect every published example or default for that property. In this example, the value to review is
https://hooks.example.com/events, not the expression itself. - Check other operations and example request bodies for alternate values. An operation may use a different expression or obtain its destination from a response instead.
- For
subscriptionChanged, identify the separate documentation or configuration that explains how a receiver destination is registered. The webhook name alone does not supply one.
Also review how your implementation handles missing, malformed, or disallowed destinations. A schema declaration alone does not demonstrate that the server enforces your destination policy.
Inspect example URLs offline
The following local Node.js script checks a small set of fictional example values. It parses strings only: it makes no DNS lookup or HTTP request. Save it as review-urls.js and run node review-urls.js in an environment with Node.js installed.
const examples = [
{ label: 'documented callback', value: 'https://hooks.example.com/events' },
{ label: 'unresolved variable', value: '${CALLBACK_URL}' },
{ label: 'staging host', value: 'https://staging.example.com/events' },
{ label: 'unexpected scheme', value: 'http://hooks.example.com/events' },
{ label: 'sensitive parameter', value: 'https://hooks.example.com/events?token=REDACTED' }
];
function review(value) {
const findings = [];
// These patterns are examples, not a complete placeholder detector.
if (/\$\{|\{[^}]*\}|<[^>]*>|%7b|%7d/i.test(value)) {
findings.push('possible unresolved placeholder');
}
let url;
try {
url = new URL(value);
} catch {
findings.push('not an absolute parseable URL');
return findings;
}
if (url.protocol !== 'https:') {
findings.push('scheme is not HTTPS');
}
// Replace this convention with your organization's actual host policy.
const host = url.hostname.toLowerCase();
if (/(^|[.-])(staging|stage|dev|test)([.-]|$)/.test(host)) {
findings.push('possible non-production hostname');
}
if (url.username || url.password) {
findings.push('URL contains user information');
}
if (url.hash) {
findings.push('fragment requires review');
}
for (const key of url.searchParams.keys()) {
if (/^(token|access_token|api_key|apikey|secret|password)$/i.test(key)) {
findings.push('potentially sensitive query parameter');
break;
}
}
return findings;
}
for (const example of examples) {
const findings = review(example.value);
// Print labels and findings, not URLs that might contain secrets.
console.log(`${example.label}: ${findings.length ? findings.join('; ') : 'no issues detected by these checks'}`);
}
The script should flag the deliberately problematic examples; it does not prove that the remaining URL is safe or reachable. The hostname and parameter checks are heuristics: staging hosts can have other names, and secrets can appear in paths, parameter values, or parameters with different names. Review against your own inventory and secret-handling policy. Use synthetic values rather than copying customer URLs or credentials into the script or its logs.
Advertisement
Decide what still needs verification
Offline inspection is a release-review step, not an end-to-end webhook test. Before release, decide how to verify the following in an authorized test environment:
- Ownership and authorization: Confirm that your registration process allows the intended party to register the destination. Parsing does not establish who controls a host.
- Delivery and receiver behavior: Use a receiver you control to check the outgoing request, authentication or signature verification, response handling, and retry behavior. Do not use a real customer endpoint without explicit authorization.
- Destination safety: If your service fetches or sends to user-supplied URLs, apply server-side controls for allowed schemes and destinations. Consider DNS resolution and rebinding, redirects and revalidation, prohibited IP ranges, network egress restrictions, timeouts, and response-size limits. A hostname check or parser alone is not an SSRF defense.
- Documentation consistency: Confirm that subscription instructions, example payloads, and the implementation agree about how a destination is supplied and changed.
Common Mistakes
- Treating
{$request.body#/callbackUrl}as a literal destination, or flagging it as a deployment placeholder without evaluating its role. - Assuming a top-level webhook name is a URL.
- Publishing a staging hostname or a credential-bearing example because the URL parses successfully.
- Logging full URLs while reviewing them; query strings and paths can contain sensitive information.
- Sending a test request to a customer endpoint merely to check whether an example works.
Best Practices
Maintain a small inventory mapping each callback expression or webhook registration mechanism to its documented example values. Review those values during release preparation, use fictional examples, and apply checks suited to your organization's naming and security policies. Run separate delivery tests only against explicitly authorized receivers.
Conclusion
Trace each callback expression to its source value, inspect examples offline, and treat top-level webhook destinations as a separate configuration question. Then use an authorized receiver and server-side security controls for the checks that URL parsing cannot perform.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.