{
    "openapi": "3.1.0",
    "info": {
        "title": "Codey Generator API",
        "version": "1.0.0",
        "summary": "Generate a simple Arduino/ESP32 example sketch, a wiring diagram and a connection table for your products.",
        "description": "The Codey Generator API turns a list of electronic components (and optionally a short request) into a ready-to-publish example project: a compiled-and-verified Arduino sketch, a wiring diagram image and a connection-table image (both WebP), rendered with the same engine as the Codey Online IDE.\n\nGenerations are **asynchronous**: `POST /generations` returns `202 Accepted` with an id; poll `GET /generations/{id}` or receive a signed webhook when it is done (typically 20–90 seconds).\n\nAll output carries a reference to Codey.online (sketch header comment, image footer and watermark). See https://codey.online/developers/docs for the full guide.",
        "contact": {
            "name": "Codey Online",
            "url": "https://codey.online/developers",
            "email": "support@codey.online"
        },
        "termsOfService": "https://codey.online/developers/terms"
    },
    "servers": [
        {
            "url": "https://api.codey.online/v1"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "Generations",
            "description": "Create and retrieve generated example projects."
        },
        {
            "name": "Catalog",
            "description": "Boards and components known to Codey. Use these ids to get exact matches."
        },
        {
            "name": "Account",
            "description": "Your API account, limits and usage."
        },
        {
            "name": "Assets",
            "description": "Public WebP images produced by generations."
        }
    ],
    "paths": {
        "/generations": {
            "post": {
                "tags": [
                    "Generations"
                ],
                "operationId": "createGeneration",
                "summary": "Create a generation",
                "description": "Validates the request, resolves every component against the Codey catalog and queues the job. Unknown components are rejected with `422 unknown_component` (no credits used) and suggestions are returned.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Unique key (max 100 chars) to safely retry. Same key + same body returns the original generation; same key + different body returns 409.",
                        "schema": {
                            "type": "string",
                            "maxLength": 100
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/GenerationRequest"
                            },
                            "examples": {
                                "product": {
                                    "summary": "One product, Dutch output",
                                    "value": {
                                        "board": "arduino-uno",
                                        "components": [
                                            {
                                                "id": "hc-sr04"
                                            }
                                        ],
                                        "language": "nl",
                                        "external_reference": "SKU-10023"
                                    }
                                },
                                "combo": {
                                    "summary": "Two parts with a request",
                                    "value": {
                                        "board": "esp32-devkit-v1",
                                        "components": [
                                            {
                                                "id": "hc-sr04"
                                            },
                                            {
                                                "name": "0.96 inch OLED I2C SSD1306"
                                            }
                                        ],
                                        "prompt": "Show the measured distance in cm on the OLED",
                                        "language": "en",
                                        "webhook_url": "https://shop.example.com/hooks/codey"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "Accepted and queued.",
                        "headers": {
                            "Location": {
                                "schema": {
                                    "type": "string"
                                },
                                "description": "URL of the generation."
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Generation"
                                }
                            }
                        }
                    },
                    "200": {
                        "description": "Idempotent replay: the generation created earlier with this Idempotency-Key.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Generation"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/Error"
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "402": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error"
                    },
                    "409": {
                        "$ref": "#/components/responses/Error"
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "get": {
                "tags": [
                    "Generations"
                ],
                "operationId": "listGenerations",
                "summary": "List generations",
                "description": "Newest first. The list omits `sketch.content` and `wiring`; fetch a single generation for those.",
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "starting_after",
                        "in": "query",
                        "description": "Generation id to paginate after.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "$ref": "#/components/schemas/GenerationStatus"
                        }
                    },
                    {
                        "name": "external_reference",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of generations.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "object": {
                                            "const": "list"
                                        },
                                        "has_more": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Generation"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/generations/{id}": {
            "get": {
                "tags": [
                    "Generations"
                ],
                "operationId": "getGeneration",
                "summary": "Retrieve a generation",
                "description": "Poll until `status` is `succeeded` or `failed`. While queued/processing the response carries `Retry-After: 10`.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/GenerationId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The generation.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Generation"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/generations/{id}/sketch": {
            "get": {
                "tags": [
                    "Generations"
                ],
                "operationId": "downloadSketch",
                "summary": "Download the sketch as an .ino file",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/GenerationId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The sketch.",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/boards": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "operationId": "listBoards",
                "summary": "List supported boards",
                "responses": {
                    "200": {
                        "description": "Supported boards.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "object": {
                                            "const": "list"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Board"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/components": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "operationId": "listComponents",
                "summary": "List catalog components",
                "parameters": [
                    {
                        "name": "search",
                        "in": "query",
                        "description": "Substring match on id, name and keywords.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "examples": [
                                "sensor",
                                "display",
                                "actuator",
                                "output",
                                "input"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Components (without pins).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "object": {
                                            "const": "list"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Component"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/components/{id}": {
            "get": {
                "tags": [
                    "Catalog"
                ],
                "operationId": "getComponent",
                "summary": "Retrieve a component (with pins)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The component.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Component"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/components/resolve": {
            "post": {
                "tags": [
                    "Catalog"
                ],
                "operationId": "resolveComponents",
                "summary": "Match product names to catalog components",
                "description": "Free of charge. Use it once to map your product catalog to Codey component ids, then send ids in generations for exact, repeatable results.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "names"
                                ],
                                "properties": {
                                    "names": {
                                        "type": "array",
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "items": {
                                            "type": "string",
                                            "maxLength": 160
                                        }
                                    }
                                }
                            },
                            "example": {
                                "names": [
                                    "HC-SR04 ultrasonic sensor",
                                    "DHT22 temperature sensor"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "One result per name, in order.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "object": {
                                            "const": "list"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/ResolveResult"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/account": {
            "get": {
                "tags": [
                    "Account"
                ],
                "operationId": "getAccount",
                "summary": "Your account, credits, limits and usage",
                "responses": {
                    "200": {
                        "description": "Account.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Account"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/assets/{asset}.webp": {
            "get": {
                "tags": [
                    "Assets"
                ],
                "operationId": "getAsset",
                "summary": "Download a generated image",
                "description": "Public, unguessable URL; no API key needed. Cached for a year (`immutable`). You may hotlink it, but we recommend downloading and hosting it yourself.",
                "security": [],
                "parameters": [
                    {
                        "name": "asset",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^img_[0-9A-Za-z]{32}$"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "WebP image.",
                        "content": {
                            "image/webp": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        }
    },
    "webhooks": {
        "generation.succeeded": {
            "post": {
                "summary": "A generation finished successfully",
                "description": "Sent to the `webhook_url` of the generation (or the account default). Verify the `Codey-Signature` header: `t=<unix>,v1=<hex>` where v1 = HMAC-SHA256(webhook_secret, `<t>.<raw body>`). Reject timestamps older than 5 minutes. Respond with any 2xx within 15 s; failed deliveries are retried after 1 min, 10 min and 1 hour.",
                "parameters": [
                    {
                        "name": "Codey-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Codey-Event",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Acknowledged."
                    }
                }
            }
        },
        "generation.failed": {
            "post": {
                "summary": "A generation failed (no credits charged)",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookEvent"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Acknowledged."
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "`cdy_live_…` for real generations, `cdy_test_…` for a free fixed example (integration testing)."
            }
        },
        "parameters": {
            "GenerationId": {
                "name": "id",
                "in": "path",
                "required": true,
                "schema": {
                    "type": "string",
                    "pattern": "^gen_[0-9A-Za-z]{24}$"
                }
            }
        },
        "responses": {
            "Error": {
                "description": "Error.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        },
        "schemas": {
            "GenerationRequest": {
                "type": "object",
                "required": [
                    "components"
                ],
                "properties": {
                    "board": {
                        "type": "string",
                        "description": "Board id from GET /boards (e.g. `arduino-uno`, `esp32-devkit-v1`), or `auto` to let Codey choose (WiFi/Bluetooth or I2S needed, or 3.3V-only parts → ESP32 DevKit V1; more than 18 signal pins → Mega 2560; otherwise Arduino UNO). Omitted → `arduino-uno`. A board may also be passed as one of the components; that always wins.",
                        "default": "arduino-uno",
                        "examples": [
                            "arduino-uno",
                            "esp32-devkit-v1",
                            "auto"
                        ]
                    },
                    "components": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 8,
                        "items": {
                            "$ref": "#/components/schemas/ComponentRef"
                        }
                    },
                    "prompt": {
                        "type": "string",
                        "maxLength": 500,
                        "description": "Optional short description of what the example should do. Without it Codey makes a typical beginner demo."
                    },
                    "language": {
                        "type": "string",
                        "enum": [
                            "en",
                            "nl",
                            "de",
                            "fr",
                            "es",
                            "it",
                            "pl"
                        ],
                        "default": "en",
                        "description": "Language of code comments, title, explanation and image texts."
                    },
                    "external_reference": {
                        "type": "string",
                        "maxLength": 190,
                        "description": "Your own reference (e.g. SKU); returned as-is and filterable."
                    },
                    "webhook_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Public https URL for the completion event. Overrides the account default."
                    },
                    "options": {
                        "type": "object",
                        "properties": {
                            "image_width": {
                                "type": "integer",
                                "minimum": 800,
                                "maximum": 2400,
                                "default": 1600,
                                "description": "Width in pixels of both images."
                            }
                        }
                    }
                }
            },
            "ComponentRef": {
                "type": "object",
                "description": "Pass `id` (exact, recommended) or `name` (matched against the catalog).",
                "properties": {
                    "id": {
                        "type": "string",
                        "examples": [
                            "hc-sr04"
                        ]
                    },
                    "name": {
                        "type": "string",
                        "examples": [
                            "0.96 inch OLED I2C SSD1306"
                        ]
                    },
                    "quantity": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 8,
                        "default": 1
                    }
                }
            },
            "GenerationStatus": {
                "type": "string",
                "enum": [
                    "queued",
                    "processing",
                    "succeeded",
                    "failed"
                ]
            },
            "Generation": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "examples": [
                            "gen_hDl7j574YsFNMhbLTfKiOODy"
                        ]
                    },
                    "object": {
                        "const": "generation"
                    },
                    "status": {
                        "$ref": "#/components/schemas/GenerationStatus"
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "live",
                            "test"
                        ]
                    },
                    "external_reference": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "language": {
                        "type": "string"
                    },
                    "board": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "fqbn": {
                                "type": "string"
                            },
                            "selection": {
                                "type": "object",
                                "description": "How the board was determined.",
                                "properties": {
                                    "mode": {
                                        "type": "string",
                                        "enum": [
                                            "specified",
                                            "default",
                                            "auto"
                                        ]
                                    },
                                    "reason": {
                                        "type": "string",
                                        "enum": [
                                            "wireless",
                                            "i2s",
                                            "3v3_parts",
                                            "many_pins",
                                            "default"
                                        ],
                                        "description": "Only for mode auto."
                                    },
                                    "explanation": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    },
                    "components": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "input": {
                                    "type": "string"
                                },
                                "id": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "quantity": {
                                    "type": "integer"
                                },
                                "match": {
                                    "type": "string",
                                    "enum": [
                                        "id",
                                        "name",
                                        "semantic"
                                    ]
                                }
                            }
                        }
                    },
                    "prompt": {
                        "type": "string"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "completed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "result": {
                        "$ref": "#/components/schemas/GenerationResult"
                    },
                    "error": {
                        "type": "object",
                        "description": "Only when status = failed.",
                        "properties": {
                            "code": {
                                "type": "string",
                                "enum": [
                                    "generation_failed",
                                    "compile_failed"
                                ]
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    },
                    "credits_charged": {
                        "type": "integer"
                    }
                }
            },
            "GenerationResult": {
                "type": "object",
                "description": "Only when status = succeeded.",
                "properties": {
                    "title": {
                        "type": "string"
                    },
                    "explanation": {
                        "type": "string",
                        "description": "2–4 sentences, in the requested language."
                    },
                    "sketch": {
                        "type": "object",
                        "properties": {
                            "filename": {
                                "type": "string"
                            },
                            "language": {
                                "const": "arduino"
                            },
                            "content": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "Full sketch, starting with the Codey.online header comment. Null in list responses."
                            },
                            "libraries": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "name": {
                                            "type": "string"
                                        },
                                        "version": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "board": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "fqbn": {
                                        "type": "string"
                                    }
                                }
                            },
                            "compile_verified": {
                                "type": "boolean",
                                "description": "The sketch compiled with arduino-cli for this board."
                            }
                        }
                    },
                    "connections": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Connection"
                        }
                    },
                    "wiring": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "Raw Codey wiring JSON (parts + connections), e.g. to re-open the design in Codey. Null in list responses."
                    },
                    "images": {
                        "type": "object",
                        "properties": {
                            "wiring_diagram": {
                                "$ref": "#/components/schemas/Image"
                            },
                            "connection_table": {
                                "$ref": "#/components/schemas/Image"
                            }
                        }
                    },
                    "attribution": {
                        "type": "object",
                        "description": "Text and a ready-made HTML snippet to show near the images.",
                        "properties": {
                            "text": {
                                "type": "string"
                            },
                            "url": {
                                "type": "string"
                            },
                            "html": {
                                "type": "string"
                            }
                        }
                    },
                    "warnings": {
                        "type": "array",
                        "description": "Non-fatal remarks, e.g. `component_without_photo` (the part is drawn as a schematic block).",
                        "items": {
                            "type": "object",
                            "properties": {
                                "code": {
                                    "type": "string"
                                },
                                "component": {
                                    "type": "string"
                                },
                                "message": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "Connection": {
                "type": "object",
                "properties": {
                    "from": {
                        "$ref": "#/components/schemas/Endpoint"
                    },
                    "to": {
                        "$ref": "#/components/schemas/Endpoint"
                    },
                    "color": {
                        "type": "string",
                        "description": "Wire colour as drawn (GND black, 5V red, 3.3V dark orange)."
                    }
                }
            },
            "Endpoint": {
                "type": "object",
                "properties": {
                    "part": {
                        "type": "string"
                    },
                    "label": {
                        "type": "string"
                    },
                    "pin": {
                        "type": "string"
                    }
                }
            },
            "Image": {
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "width": {
                        "type": "integer"
                    },
                    "height": {
                        "type": "integer"
                    },
                    "bytes": {
                        "type": "integer"
                    },
                    "format": {
                        "const": "webp"
                    }
                }
            },
            "Board": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "fqbn": {
                        "type": "string"
                    },
                    "family": {
                        "type": "string"
                    },
                    "image_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "Component": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "category": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "protocols": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "libraries": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "image_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "catalog_url": {
                        "type": "string"
                    },
                    "pins": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "signal": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "ResolveResult": {
                "type": "object",
                "properties": {
                    "input": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "matched",
                            "ambiguous",
                            "not_found"
                        ]
                    },
                    "component": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "name": {
                                "type": "string"
                            },
                            "category": {
                                "type": "string"
                            }
                        }
                    },
                    "match": {
                        "type": "string",
                        "enum": [
                            "id",
                            "name",
                            "semantic"
                        ]
                    },
                    "score": {
                        "type": "number"
                    },
                    "suggestions": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "score": {
                                    "type": "number"
                                }
                            }
                        }
                    }
                }
            },
            "Account": {
                "type": "object",
                "properties": {
                    "object": {
                        "const": "account"
                    },
                    "company_name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string"
                    },
                    "key_mode": {
                        "type": "string",
                        "enum": [
                            "live",
                            "test"
                        ]
                    },
                    "credits_balance": {
                        "type": "integer"
                    },
                    "billing_enabled": {
                        "type": "boolean"
                    },
                    "price_per_generation": {
                        "type": "integer"
                    },
                    "limits": {
                        "type": "object",
                        "properties": {
                            "requests_per_minute": {
                                "type": "integer"
                            },
                            "generations_per_day": {
                                "type": "integer"
                            },
                            "max_in_progress": {
                                "type": "integer"
                            }
                        }
                    },
                    "usage": {
                        "type": "object",
                        "properties": {
                            "generations_today": {
                                "type": "integer"
                            },
                            "generations_this_month": {
                                "type": "integer"
                            },
                            "succeeded_this_month": {
                                "type": "integer"
                            },
                            "in_progress": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "WebhookEvent": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "object": {
                        "const": "event"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "generation.succeeded",
                            "generation.failed"
                        ]
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "data": {
                        "$ref": "#/components/schemas/Generation"
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "required": [
                            "type",
                            "code",
                            "message",
                            "request_id"
                        ],
                        "properties": {
                            "type": {
                                "type": "string",
                                "enum": [
                                    "invalid_request_error",
                                    "authentication_error",
                                    "billing_error",
                                    "rate_limit_error",
                                    "api_error"
                                ]
                            },
                            "code": {
                                "type": "string",
                                "examples": [
                                    "invalid_request",
                                    "missing_api_key",
                                    "invalid_api_key",
                                    "account_not_active",
                                    "insufficient_credits",
                                    "idempotency_conflict",
                                    "unknown_component",
                                    "unsupported_board",
                                    "multiple_boards",
                                    "rate_limited",
                                    "too_many_in_progress",
                                    "daily_limit_reached",
                                    "maintenance",
                                    "not_found"
                                ]
                            },
                            "message": {
                                "type": "string"
                            },
                            "details": {
                                "type": "object"
                            },
                            "request_id": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}