This prompt is designed for API designers and platform engineers who already have a catalog of webhook events—including their names, trigger conditions, payload structures, and delivery channel information—and need to convert that knowledge into a machine-readable AsyncAPI 2.x specification. The job-to-be-done is structuring existing event knowledge into a standards-compliant contract that downstream tools like AsyncAPI Generator, EventCatalog, or Bump.sh can consume directly. You should use this prompt when you have defined event types and payload schemas but need them formatted as a valid AsyncAPI document with proper channels, message definitions, security schemes, and server bindings. The prompt assumes you bring the domain knowledge; it does not invent event schemas or design your event architecture from scratch.
Prompt
Webhook AsyncAPI Specification Drafting Prompt

When to Use This Prompt
Understand the job-to-be-done, required inputs, and when this prompt is the wrong tool.
Do not use this prompt for generating OpenAPI or Swagger REST endpoint documentation—AsyncAPI and OpenAPI serve different architectural patterns and the prompt is optimized for event-driven contracts only. Do not use it when you have not yet specified your event payloads or when you need prose-heavy integration guides or tutorials for consumers. The output is a YAML or JSON specification file, not a narrative document. If you are still designing your event schema, use the Webhook Payload Schema Generation Prompt first to define your payloads, then return to this prompt to assemble the full AsyncAPI specification. For consumer-facing documentation like quickstart guides or troubleshooting references, use the dedicated webhook documentation prompts in this pillar instead.
Before running this prompt, gather your event catalog with at minimum: event type names, descriptions, trigger conditions, JSON Schema definitions for each payload, the channel or topic each event publishes to, your server or broker connection details, and any security requirements like API keys or OAuth2 flows. The prompt works best when you provide structured input—a table or structured object of events—rather than freeform notes. After generating the specification, validate it against the AsyncAPI 2.x JSON Schema to catch structural errors, then test it with your target toolchain to confirm compatibility. For high-stakes specifications that govern production contracts, always include a human review step to verify that the generated channels, message schemas, and security schemes match your actual infrastructure before publishing.
Use Case Fit
Where the AsyncAPI drafting prompt delivers reliable, machine-readable contracts and where it needs additional engineering support.
Good Fit: Structured Event Catalogs
Use when: you have a defined event catalog with names, descriptions, trigger conditions, and payload schemas. The prompt excels at translating structured event inventories into compliant AsyncAPI documents with channels, messages, and security schemes. Guardrail: validate the output against AsyncAPI toolchain parsers before committing to version control.
Bad Fit: Undefined or Evolving Contracts
Avoid when: event types, payload shapes, or delivery semantics are still under active design. The prompt will hallucinate plausible but incorrect schemas when inputs are vague. Guardrail: use the Event Type Catalog Drafting Prompt first to stabilize event definitions, then feed the structured output into this prompt.
Required Inputs
What you must provide: event type names, trigger conditions, payload field definitions with types, required vs optional fields, example values, security scheme details, and channel binding preferences. Guardrail: create an input checklist template that gates prompt execution. Missing inputs produce incomplete specs that fail downstream code generation.
Operational Risk: Toolchain Compatibility
What to watch: generated AsyncAPI documents may use valid syntax but fail in specific code generators, validators, or documentation renderers due to version mismatches or unsupported binding features. Guardrail: run the output through at least two AsyncAPI tools (validator + generator) and document which toolchain versions are supported.
Operational Risk: Schema Drift Over Time
What to watch: the prompt generates a point-in-time specification. As your webhook implementation evolves, the AsyncAPI doc will drift unless regeneration is automated. Guardrail: integrate prompt execution into CI/CD pipelines triggered by event schema changes, with diff reviews before merge.
Boundary: Security Scheme Complexity
What to watch: the prompt handles common security schemes (bearer tokens, API keys, OAuth2 flows) but may oversimplify custom or multi-step authentication. Guardrail: for non-standard auth, draft the security scheme separately using the Signature Verification Documentation Prompt and inject it as a pre-validated input block.
Copy-Ready Prompt Template
A copy-ready prompt that instructs the model to generate a valid AsyncAPI specification from your event catalog data.
The prompt below is designed to be pasted directly into your AI system. It forces the model to act as an API specification generator, consuming a structured event catalog and producing a standards-compliant AsyncAPI document. All configuration points are exposed as square-bracket placeholders, which you must replace with your actual data before execution. The prompt explicitly instructs the model to output only the YAML specification with no surrounding commentary, making the output safe for direct piping into validation tools or code generators.
yamlYou are an API specification generator. Your only task is to produce a valid AsyncAPI 2.6.0 YAML document from the provided event catalog. # INPUTS - Event Catalog: [EVENT_CATALOG_JSON] - API Title: [API_TITLE] - API Version: [API_VERSION] - Server Description: [SERVER_DESCRIPTION] - Server URL: [SERVER_URL] - Server Protocol: [SERVER_PROTOCOL] # CONSTRAINTS - Output ONLY the raw AsyncAPI YAML. Do not include any markdown fences, introductory text, or explanatory notes. - Every event in the catalog must map to a channel with a publish operation. - Use the event name as the channel address, prefixed with a forward slash (e.g., `/user.created`). - Generate a JSON Schema for each event's payload from the provided [EVENT_CATALOG_JSON]. Include at least one example in each schema. - Include a `securitySchemes` section if [SECURITY_SCHEME_TYPE] is provided. Supported types: `userPassword`, `apiKey`, `bearer`, `oauth2`. - Bind the server to the [SERVER_PROTOCOL] and include a `ws` binding if the protocol is `ws`. - The `info` object must include the title, version, and a description that mentions the number of documented events. - Use `asyncapi: 2.6.0`. # OUTPUT FORMAT asyncapi: 2.6.0 info: title: [API_TITLE] version: [API_VERSION] description: "..." servers: production: url: [SERVER_URL] protocol: [SERVER_PROTOCOL] description: [SERVER_DESCRIPTION] channels: [EVENT_CHANNEL_1]: publish: message: payload: type: object properties: ...
To adapt this template, replace each bracketed placeholder with your concrete data. [EVENT_CATALOG_JSON] should be a structured JSON object where keys are event names and values are objects describing the payload fields, types, and descriptions. If your system does not require security, remove the securitySchemes instruction and the corresponding placeholder. For production use, always pipe the model's raw output through an AsyncAPI validator (like the official asyncapi CLI tool) before accepting it. A common failure mode is the model wrapping the YAML in a markdown code fence despite the constraint; a simple post-processing step to strip leading and trailing fences will harden your pipeline.
Prompt Variables
Each placeholder required by the Webhook AsyncAPI Specification Drafting Prompt. Use these to parameterize the prompt template before sending it to the model. Validation notes describe how to check that the provided value is sufficient before generation.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[EVENT_CATALOG] | The complete list of webhook event types to include in the AsyncAPI spec. Each entry should have a name, description, trigger condition, and payload reference. | order.created, order.updated, payment.captured, shipment.dispatched | Check that the catalog is non-empty and each event has a unique name. Reject if any event is missing a description or payload reference. |
[CHANNEL_NAME] | The AsyncAPI channel name for the webhook endpoint. Typically a path-like identifier that consumers subscribe to. | smartapp/webhooks/v1 | Must be a non-empty string. Validate that it follows the organization's channel naming convention (e.g., lowercase, hyphenated, versioned). |
[SECURITY_SCHEME] | The authentication mechanism for webhook delivery. Describes how the producer signs requests and how consumers verify them. | HMAC-SHA256 signature in X-Signature-256 header with rotating secret | Must specify the scheme type (e.g., HMAC, OAuth2, mutual TLS). Reject if the description is ambiguous about header names or secret rotation. |
[PAYLOAD_SCHEMAS] | The JSON Schema definitions for each event payload. Can be inline schemas or references to external schema files. | {"order.created": {"type": "object", "properties": {"order_id": {"type": "string"}, "amount": {"type": "number"}}, "required": ["order_id", "amount"]}} | Validate each schema against JSON Schema draft-07 or later. Reject if any required field is missing a type definition or if example values are absent. |
[DELIVERY_GUARANTEE] | The delivery semantics the webhook system provides. Must be one of at-most-once, at-least-once, or exactly-once. | at-least-once with 24-hour deduplication window | Must match one of the three standard delivery guarantees. Reject if the description contradicts the retry policy or idempotency documentation. |
[BINDING_PROTOCOL] | The protocol binding for the AsyncAPI spec. Determines the transport layer details included in the generated document. | HTTP | Must be a supported AsyncAPI protocol binding (e.g., HTTP, Kafka, MQTT, AMQP). Reject if the protocol does not match the actual webhook transport. |
[ASYNCAPI_VERSION] | The version of the AsyncAPI specification to target. Controls the schema structure and available features in the output. | 2.6.0 | Must be a valid semver string matching a released AsyncAPI spec version. Reject if the version is unsupported by the target code generation or validation toolchain. |
[CONSUMER_ACKNOWLEDGMENT] | The expected HTTP response status codes and behavior for acknowledging or rejecting events. | 2xx for success, 4xx for rejection, 5xx triggers retry | Must specify the status code ranges and the consequence of each. Reject if the acknowledgment rules conflict with the retry policy or idempotency key handling. |
Implementation Harness Notes
Wire this prompt into an application with validation, repair loops, and production safeguards.
To integrate this prompt into a production pipeline, call the LLM API with the fully rendered prompt string. Set response_format to { "type": "json_object" } if your provider supports structured output modes, and instruct the model to return the AsyncAPI specification inside a JSON wrapper such as {"asyncapi_spec": "<YAML string>"}. This simplifies parsing and reduces the risk of extracting the YAML from free-text responses. After receiving the response, extract the YAML string from the JSON payload and write it to a .yaml file for validation.
Validation is the critical gate before any spec is published or consumed by downstream tools. Run the generated YAML through the official AsyncAPI parser CLI (asyncapi validate spec.yaml) or the @asyncapi/parser JavaScript library. If validation fails, capture the specific error messages—including line numbers, schema violations, and missing required fields—and feed them back into a repair prompt. The repair prompt should include the original generation context, the invalid spec, and the exact validation errors, instructing the model to produce a corrected version that resolves each error without introducing new ones. Log every generation attempt, the validation result, and the final spec version for auditability.
For production pipelines, store the validated spec in a git repository and trigger downstream documentation generation tools (such as AsyncAPI React renderer or custom doc site builds) on merge to the main branch. Never publish an unvalidated spec. Even if the spec passes structural validation, inspect it for placeholder payload examples (e.g., "string", 12345, or obviously hallucinated data) and flag any suspicious content for human review before publication. Consider adding a second evaluation step that checks for semantic completeness: do all channels have descriptions, do all messages have examples, and are security schemes fully defined? This catches gaps that schema validation alone will miss.
Expected Output Contract
The fields, types, and validation rules that define a conformant AsyncAPI specification output. Use this table to build a post-generation validator or schema check.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
asyncapi | string (semver) | Must equal '2.6.0' or a supported version declared in [ASYNCAPI_VERSION] | |
info.title | string | Must be non-empty and match the event domain described in [EVENT_CATALOG] | |
info.version | string (semver) | Must be a valid semantic version string; reject if missing patch segment | |
channels | object (map) | Must contain at least one channel key matching an event type from [EVENT_CATALOG]; each channel must have a publish or subscribe operation | |
channels.*.subscribe.message.payload | object (schema) | Must be a valid JSON Schema object; all $ref references must resolve within the document or to a provided [SCHEMA_REGISTRY] | |
components.securitySchemes | object | If present, each scheme must declare a valid type (e.g., httpApiKey, oauth2); reject unknown scheme types | |
channels.*.parameters | object | If present, each parameter must include schema, description, and location fields; location must be a valid runtime expression | |
info.description | string | If present, must not exceed 5000 characters; must not contain unresolved [PLACEHOLDER] tokens |
Common Failure Modes
When drafting AsyncAPI specs with LLMs, these failure patterns surface most often. Each card pairs a specific risk with a concrete guardrail you can implement before the spec reaches a generator or reviewer.
Hallucinated Channel Paths
What to watch: The model invents channel names or operation paths that don't exist in the event catalog, especially for unsubscribe or list operations. Guardrail: Provide a strict channel template and require the model to map every channel to an entry in the input event catalog. Validate output channels against the source list before accepting the spec.
Missing or Incomplete Message Schemas
What to watch: The model describes payloads in prose but omits the actual JSON Schema definitions, or generates schemas with missing required fields, nullable types, and example values. Guardrail: Require a message.payload schema block for every event type. Run the output through an AsyncAPI parser and a JSON Schema validator; flag any message that lacks a concrete schema.
Inconsistent Security Scheme References
What to watch: The model defines security schemes in the components section but fails to reference them on channels, or references schemes that don't exist. Guardrail: Add a constraint that every channel must include a bindings or security block referencing only schemes defined in components.securitySchemes. Validate references with a schema linter.
Drifting Binding Definitions
What to watch: The model mixes protocol binding versions (e.g., Kafka 0.4.0 vs 0.5.0) or applies HTTP bindings to a WebSocket channel. Guardrail: Specify the exact binding version and protocol in the prompt constraints. Validate that all bindings keys match the declared channel protocol and use a single consistent version.
Omitted AsyncAPI Required Fields
What to watch: The model skips mandatory top-level fields like asyncapi version, info.license, or channels when the prompt doesn't explicitly enumerate them. Guardrail: Include a checklist of required AsyncAPI fields in the prompt. Run the output through @asyncapi/parser and reject any spec that fails structural validation.
Prose Instead of Specification Structure
What to watch: The model produces a markdown document describing the webhook contract instead of a valid YAML/JSON AsyncAPI spec, especially when the prompt uses conversational language. Guardrail: Explicitly request YAML or JSON output with a strict AsyncAPI schema reference. Use a format constraint in the prompt and validate that the output parses as the requested format.
Evaluation Rubric
Use this rubric to test the quality of the generated AsyncAPI specification before shipping it to downstream tools or consumers. Each criterion targets a specific failure mode common in machine-generated specs.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
AsyncAPI Schema Compliance | Document passes validation against the target AsyncAPI version schema (e.g., 2.6.0) with zero structural errors. | Validator returns schema errors such as missing required fields, incorrect types, or invalid pattern properties. | Run the output through the official AsyncAPI parser/validator CLI. Check exit code and error list. |
Channel and Operation Completeness | Every event type from [EVENT_CATALOG] maps to exactly one channel with a publish operation, and the channel address matches the documented routing key pattern. | Event types are missing channels, channels lack operations, or channel addresses use inconsistent naming conventions. | Diff the list of event types in [EVENT_CATALOG] against the channels defined in the spec. Verify one-to-one mapping. |
Message Schema Fidelity | Each message payload schema matches its source definition in [PAYLOAD_SCHEMAS], including all required fields, types, constraints, and example values. | Fields are missing, types are widened (e.g., string instead of enum), required arrays are incomplete, or examples violate their own schema. | Extract each message schema from the output and validate it against the corresponding entry in [PAYLOAD_SCHEMAS] using a JSON Schema validator. |
Security Scheme Definition | All security requirements from [SECURITY_REQUIREMENTS] are represented as valid security scheme objects with correct type, description, and configuration fields. | Security schemes are missing, use wrong type (e.g., apiKey instead of oauth2), or omit required fields like flows for OAuth2. | Parse the components.securitySchemes block and check that every entry in [SECURITY_REQUIREMENTS] has a matching scheme with correct type and required properties. |
Binding and Protocol Consistency | Server objects specify the correct protocol and protocolVersion from [SERVER_CONFIG], and channel bindings match the declared protocol (e.g., HTTP bindings for HTTP protocol). | Protocol mismatch between server and channel bindings, missing protocolVersion, or bindings defined for unsupported protocols. | Cross-reference server protocol fields with channel binding types. Verify protocolVersion matches [SERVER_CONFIG]. |
Info and Contact Metadata | info.title, info.version, and info.contact fields are populated from [SPEC_METADATA] with no placeholder text or empty strings. | Generic placeholders like 'TODO' or 'Your API Name' remain in the output. Version is missing or not a valid semver string. | Inspect the info object. Assert title and version are non-empty and version matches semver pattern. Check contact fields against [SPEC_METADATA]. |
Example Payload Validity | Every message example conforms to its declared schema and represents a realistic, non-trivial event payload. | Examples fail schema validation, use placeholder data like 'string' or 0, or are empty objects. | Validate each message example against its schema. Check for realistic values (e.g., UUIDs for IDs, ISO 8601 timestamps, non-zero amounts). |
Toolchain Compatibility | Output parses without warnings in at least two target tools from [TOOLCHAIN_LIST] (e.g., AsyncAPI Studio, Generator CLI). | Parser warnings about unsupported features, deprecated syntax, or extension conflicts. Generator fails to produce output. | Load the spec into each tool in [TOOLCHAIN_LIST]. Confirm no blocking errors and that code generation or documentation rendering succeeds. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single event type and minimal constraints. Remove strict schema validation instructions and focus on generating a valid AsyncAPI 2.x or 3.x skeleton. Replace [EVENT_CATALOG] with a short inline list of 2-3 events. Drop the [TOOLCHAIN_TARGET] constraint and let the model choose defaults.
Watch for
- Missing
channelsdefinitions when onlycomponents.messagesare generated - Placeholder descriptions that won't survive review
- Incorrect binding protocol values (e.g.,
httpinstead ofwsfor webhooks) - Model inventing security schemes not present in your system

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us