{
 "openapi": "3.1.0",
 "info": {
  "title": "bayeux.net API",
  "version": "1.0.0",
  "description": "Create and load Bayeux Tapestry memes. Most agents should use the MCP server at https://bayeux.net/mcp instead, which takes simpler, fractional coordinates. This HTTP API stores designs in the editor's own format (pixel units of the chosen format). See https://bayeux.net/llms.txt.",
  "contact": {
   "url": "https://andreas.due.ren/"
  },
  "license": {
   "name": "Artwork: MIT (Historic Tale Construction Kit)",
   "url": "https://github.com/htck/bayeux"
  }
 },
 "servers": [
  {
   "url": "https://bayeux.net"
  }
 ],
 "paths": {
  "/api/library": {
   "get": {
    "operationId": "getLibrary",
    "summary": "Figures, formats, backgrounds, text styles and inks",
    "responses": {
     "200": {
      "description": "The library",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/api/designs": {
   "post": {
    "operationId": "createDesign",
    "summary": "Save a design and get its permanent link",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Design"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Saved (or already existed)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string",
           "pattern": "^[1-9A-HJ-NP-Za-km-z]{10}$"
          },
          "url": {
           "type": "string",
           "format": "uri"
          }
         }
        }
       }
      }
     },
     "413": {
      "description": "Too large"
     },
     "415": {
      "description": "JSON expected"
     },
     "422": {
      "description": "Not a valid design"
     },
     "429": {
      "description": "Too many new designs from this address; see Retry-After"
     }
    }
   }
  },
  "/api/designs/{id}": {
   "get": {
    "operationId": "getDesign",
    "summary": "Load a saved design",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[1-9A-HJ-NP-Za-km-z]{10}$"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The design",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Design"
        }
       }
      }
     },
     "404": {
      "description": "No such design"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Style": {
    "type": "string",
    "enum": [
     "tapestry",
     "meme",
     "script",
     "plain"
    ]
   },
   "Design": {
    "type": "object",
    "required": [
     "version",
     "format",
     "background",
     "top",
     "bottom",
     "items"
    ],
    "description": "Open https://bayeux.net/d/{id} to see, download or remix a design; https://og.due.ren/bayeux/{id}.png is its 1200x630 preview card. The MCP server's create_meme also returns the rendered image.",
    "properties": {
     "version": {
      "const": 1
     },
     "format": {
      "type": "string",
      "enum": [
       "square",
       "portrait",
       "classic",
       "wide",
       "strip"
      ],
      "description": "square 1080x1080, portrait 1080x1350, classic 1200x900, wide 1600x900, strip 2400x800"
     },
     "background": {
      "type": "string",
      "enum": [
       "linen-5",
       "linen-1",
       "linen-2",
       "linen-3",
       "linen-4"
      ]
     },
     "top": {
      "type": "object",
      "required": [
       "text",
       "style",
       "color"
      ],
      "properties": {
       "text": {
        "type": "string",
        "maxLength": 280
       },
       "style": {
        "$ref": "#/components/schemas/Style"
       },
       "color": {
        "type": "string",
        "pattern": "^#[0-9a-fA-F]{6}$"
       }
      }
     },
     "bottom": {
      "type": "object",
      "required": [
       "text",
       "style",
       "color"
      ],
      "properties": {
       "text": {
        "type": "string",
        "maxLength": 280
       },
       "style": {
        "$ref": "#/components/schemas/Style"
       },
       "color": {
        "type": "string",
        "pattern": "^#[0-9a-fA-F]{6}$"
       }
      }
     },
     "items": {
      "type": "array",
      "maxItems": 200,
      "items": {
       "oneOf": [
        {
         "type": "object",
         "required": [
          "kind",
          "src",
          "x",
          "y",
          "scale",
          "rotation",
          "flipX"
         ],
         "properties": {
          "kind": {
           "const": "figure"
          },
          "src": {
           "type": "string",
           "description": "figures/<id>.png with an id from /api/library"
          },
          "x": {
           "type": "number",
           "description": "Centre, in canvas pixels"
          },
          "y": {
           "type": "number"
          },
          "rotation": {
           "type": "number",
           "minimum": -180,
           "maximum": 180
          },
          "scale": {
           "type": "number",
           "minimum": 0.001,
           "maximum": 50
          },
          "flipX": {
           "type": "boolean"
          }
         }
        },
        {
         "type": "object",
         "required": [
          "kind",
          "text",
          "style",
          "color",
          "size",
          "x",
          "y",
          "scale",
          "rotation",
          "flipX"
         ],
         "properties": {
          "kind": {
           "const": "text"
          },
          "text": {
           "type": "string",
           "maxLength": 280
          },
          "style": {
           "$ref": "#/components/schemas/Style"
          },
          "color": {
           "type": "string",
           "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "size": {
           "type": "number",
           "description": "Font size in canvas pixels"
          },
          "x": {
           "type": "number",
           "description": "Centre, in canvas pixels"
          },
          "y": {
           "type": "number"
          },
          "rotation": {
           "type": "number",
           "minimum": -180,
           "maximum": 180
          },
          "scale": {
           "type": "number",
           "minimum": 0.001,
           "maximum": 50
          },
          "flipX": {
           "type": "boolean"
          }
         }
        }
       ]
      }
     }
    }
   }
  }
 }
}
