swadhinbiswas docs: create 23 new advanced guide and how-to recipe pages · 7/25/2026
54132cc
58 lines · 1.4 KB
Raw Download

title: OpenAPI Callbacks and Webhooks
description: Define OpenAPI callbacks and webhooks for outbound request schemas in JustAPI.
keywords: [JustAPI, OpenAPI, callbacks, webhooks, outbound requests]

OpenAPI Callbacks

Callbacks define the schema for outbound requests your API makes:

from justapi import JustAPIApp
from pydantic import BaseModel

class Order(BaseModel):
    id: int
    status: str

app = JustAPIApp()

@app.post("/orders", callbacks={
    "on_order_complete": {
        "http://localhost:8000/webhook": {
            "post": {
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": Order.model_jsonschema()
                        }
                    }
                }
            }
        }
    }
})
def create_order(order: Order):
    return {"id": 1, "status": "pending"}

OpenAPI Webhooks

Define outbound webhook schemas:

@app.webhooks.post("new-order")
def new_order_webhook(order: Order):
    """
    This webhook is triggered when a new order is created.
    """
    pass

See Also