{
  "openapi": "3.0.3",
  "info": {
    "title": "CollabDraw Co-Pilot API",
    "version": "1.0.0",
    "description": "REST API that lets external AI assistants (Claude, DeepSeek, custom agents) drive CollabDraw: list projects, create or update layered designs from a text prompt, poll long builds, and export finished designs as images, documents, or a working website. A hosted Model Context Protocol (MCP) server exposing the same capabilities as native AI tools is available at https://collabdraw.com/api/mcp \u2014 see https://collabdraw.com/mcp.",
    "contact": {
      "name": "CollabDraw",
      "url": "https://www.collabdraw.com"
    }
  },
  "servers": [
    {
      "url": "https://collabdraw.com/api/v1",
      "description": "Production"
    }
  ],
  "x-mcp-server": {
    "url": "https://collabdraw.com/api/mcp",
    "transport": "streamable-http (stateless)",
    "protocolVersion": "2025-06-18",
    "docs": "https://collabdraw.com/mcp",
    "auth": "Authorization: Bearer cd_live_... (or x-api-key: cd_live_...)",
    "tools": [
      "list_projects",
      "create_project",
      "build_design",
      "get_build_status",
      "export_project",
      "generate_website_code"
    ]
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/projects": {
      "get": {
        "summary": "List your projects",
        "description": "Returns the caller's cloud projects, newest first, with share links and thumbnail URLs.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 20,
              "maximum": 100
            },
            "description": "Number of projects to return."
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "Pagination offset."
          }
        ],
        "responses": {
          "200": {
            "description": "Project list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "projects": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "title": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "project_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "thumbnail_url": {
                            "type": "string",
                            "format": "uri",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "summary": "Create a blank project",
        "description": "Creates a new project owned by the caller. Free plans are limited to 10 projects.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Project title. Defaults to 'API Project'."
                  },
                  "template_id": {
                    "type": "string",
                    "description": "Optional template to start from. Some templates are Pro-only."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created project",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "project_url": {
                          "type": "string"
                        }
                      }
                    },
                    "chat_next_steps": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/chat": {
      "post": {
        "summary": "Send a prompt to the CollabDraw AI Co-Pilot",
        "description": "The core endpoint. The Co-Pilot either asks clarifying questions (needs_clarification) or builds/updates a layered design and returns the project link. Pass session_id to continue a conversation, and project_id to build into an existing project. Pass image_url to have Computer Vision describe an attached image before building.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string",
                    "maxLength": 8000,
                    "description": "What to create or change."
                  },
                  "session_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "From a previous chat response, to continue the conversation."
                  },
                  "project_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Existing project to edit. Omit to let the Co-Pilot create one."
                  },
                  "image_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Optional image for the Co-Pilot to look at before building."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Either a clarification request or a completed build",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "description": "needs_clarification",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "needs_clarification"
                          ]
                        },
                        "session_id": {
                          "type": "string"
                        },
                        "project_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "questions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "usage": {
                          "$ref": "#/components/schemas/Usage"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "description": "completed",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "completed",
                            "completed_no_commands"
                          ]
                        },
                        "session_id": {
                          "type": "string"
                        },
                        "project_id": {
                          "type": "string"
                        },
                        "project_url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "summary": {
                          "type": "string"
                        },
                        "objects_added": {
                          "type": "integer"
                        },
                        "usage": {
                          "$ref": "#/components/schemas/Usage"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/chat/{sessionId}": {
      "get": {
        "summary": "Poll a chat session",
        "description": "Returns the current status of a chat session. Poll this after POST /chat when builds take longer than the request timeout.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "completed",
                        "failed"
                      ]
                    },
                    "session_id": {
                      "type": "string"
                    },
                    "project_id": {
                      "type": "string",
                      "nullable": true
                    },
                    "project_url": {
                      "type": "string",
                      "format": "uri",
                      "nullable": true
                    },
                    "export_url": {
                      "type": "string",
                      "format": "uri",
                      "nullable": true
                    },
                    "latest_reply": {
                      "type": "string",
                      "nullable": true
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/projects/{id}/export": {
      "get": {
        "summary": "Export a project",
        "description": "Downloads the project's first page rendered as an image or document. PNG, JPEG, WebP and PDF are available on all plans; SVG at 4x scale is Pro-only.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "png",
                "jpeg",
                "webp",
                "pdf",
                "pptx",
                "svg"
              ],
              "default": "png"
            }
          },
          {
            "name": "scale",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 1,
              "maximum": 4,
              "default": 2
            },
            "description": "Scale factor. Free plans cap at 2. Scale 4 is Pro-only."
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "1-based page number. Defaults to the first page."
          }
        ],
        "responses": {
          "200": {
            "description": "The exported file",
            "content": {
              "image/png": {},
              "image/jpeg": {},
              "image/webp": {},
              "application/pdf": {},
              "application/vnd.openxmlformats-officedocument.presentationml.presentation": {},
              "image/svg+xml": {}
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/projects/{id}/export-code": {
      "post": {
        "summary": "Generate website code for a frame (Pro builds: 20/month on Pro, 3/month on Free)",
        "description": "Runs the Frame-to-Code pipeline on the project's first frame and returns index.html, styles.css and script.js.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Generated website files",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "completed"
                      ]
                    },
                    "export_id": {
                      "type": "string"
                    },
                    "frame_label": {
                      "type": "string"
                    },
                    "project_id": {
                      "type": "string"
                    },
                    "files": {
                      "type": "object",
                      "properties": {
                        "index.html": {
                          "type": "string"
                        },
                        "styles.css": {
                          "type": "string"
                        },
                        "script.js": {
                          "type": "string"
                        }
                      }
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "tier": {
                          "type": "string"
                        },
                        "code_exports_used": {
                          "type": "integer"
                        },
                        "code_exports_remaining": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "No frame found on the project's first page"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "summary": "Read usage statistics",
        "description": "Returns request counts for the authenticated account, counting the REST API and the MCP server separately, plus a breakdown per API key and per endpoint and the monthly quota position for AI chats, images, code exports and QR codes.",
        "operationId": "getUsage",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 365,
              "default": 30
            },
            "description": "Rolling window for the request counts."
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "rest",
                "mcp"
              ],
              "default": "all"
            },
            "description": "Which surface to count."
          },
          {
            "name": "key_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Optional API key id to scope the report to a single key."
          }
        ],
        "responses": {
          "200": {
            "description": "Usage report.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageReport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/qr": {
      "post": {
        "summary": "Generate a QR code",
        "description": "Creates a scannable QR code (URL, text, Wi-Fi, phone, contact card or crypto address) and returns it as a PNG or SVG image. Counts one QR code against the plan allowance: Free 5 per month, Pro unlimited. SVG requires Pro.",
        "operationId": "generateQrCode",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QrRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The QR code image. Headers: X-QR-Preview-URL and X-QR-Usage-Remaining (-1 means unlimited).",
            "headers": {
              "X-QR-Preview-URL": {
                "schema": {
                  "type": "string"
                },
                "description": "Link that renders the same code in the CollabDraw QR tool."
              },
              "X-QR-Usage-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "QR codes left this month; -1 means unlimited."
              }
            },
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Missing content for the chosen tab, or the value is too long to encode",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      },
      "get": {
        "summary": "Describe the QR endpoint",
        "description": "Returns the accepted tabs, fields and limits for POST /qr.",
        "operationId": "getQrCapabilities",
        "responses": {
          "200": {
            "description": "Capability description.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "CollabDraw API key: cd_live_ followed by 32 hex characters. Create keys in Settings > API Keys at collabdraw.com."
      }
    },
    "schemas": {
      "Usage": {
        "type": "object",
        "properties": {
          "tier": {
            "type": "string",
            "enum": [
              "free",
              "pro"
            ]
          },
          "ai_chats_remaining": {
            "type": "integer"
          }
        }
      },
      "UsageReport": {
        "type": "object",
        "properties": {
          "range": {
            "type": "object",
            "properties": {
              "days": {
                "type": "integer"
              },
              "since": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "channel": {
            "type": "string",
            "enum": [
              "all",
              "rest",
              "mcp"
            ]
          },
          "requests": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "rest": {
                "type": "integer"
              },
              "mcp": {
                "type": "integer"
              }
            }
          },
          "by_key": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key_id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "key_prefix": {
                  "type": "string"
                },
                "is_active": {
                  "type": "boolean"
                },
                "requests": {
                  "type": "integer"
                },
                "mcp_requests": {
                  "type": "integer"
                }
              }
            }
          },
          "by_endpoint": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "endpoint": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          },
          "monthly": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "usage_type": {
                  "type": "string",
                  "enum": [
                    "ai_chat",
                    "ai_image",
                    "code_export",
                    "qr_save"
                  ]
                },
                "used": {
                  "type": "integer"
                },
                "limit": {
                  "type": "integer",
                  "description": "-1 means unlimited on this plan."
                },
                "remaining": {
                  "type": "integer",
                  "description": "-1 means unlimited on this plan."
                }
              }
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "tier": {
                "type": "string",
                "enum": [
                  "free",
                  "pro"
                ]
              },
              "rate_per_minute": {
                "type": "integer"
              },
              "max_projects": {
                "type": "integer"
              },
              "max_keys": {
                "type": "integer"
              }
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "True when the breakdown covers only the most recent 5,000 requests."
          }
        }
      },
      "QrRequest": {
        "type": "object",
        "properties": {
          "tab": {
            "type": "string",
            "enum": [
              "url",
              "text",
              "wifi",
              "phone",
              "contact",
              "crypto"
            ],
            "default": "url"
          },
          "value": {
            "type": "string",
            "description": "Exact content to encode; overrides the tab fields."
          },
          "ssid": {
            "type": "string",
            "description": "wifi tab: network name."
          },
          "password": {
            "type": "string",
            "description": "wifi tab: network password."
          },
          "encryption": {
            "type": "string",
            "enum": [
              "WPA",
              "WEP",
              "nopass"
            ],
            "default": "WPA"
          },
          "hidden": {
            "type": "boolean",
            "description": "wifi tab: true when the network is hidden."
          },
          "phone": {
            "type": "string",
            "description": "phone tab, or contact tab phone number."
          },
          "name": {
            "type": "string",
            "description": "contact tab: full name."
          },
          "email": {
            "type": "string",
            "description": "contact tab: email address."
          },
          "org": {
            "type": "string",
            "description": "contact tab: organisation."
          },
          "url": {
            "type": "string",
            "description": "contact tab: website."
          },
          "address": {
            "type": "string",
            "description": "crypto tab: wallet address."
          },
          "currency": {
            "type": "string",
            "enum": [
              "bitcoin",
              "ethereum",
              "litecoin",
              "bitcoincash",
              "dogecoin",
              "solana",
              "usdc",
              "tether"
            ],
            "default": "bitcoin"
          },
          "fgColor": {
            "type": "string",
            "default": "#000000",
            "description": "Hex colour of the code."
          },
          "bgColor": {
            "type": "string",
            "default": "#FFFFFF",
            "description": "Hex colour of the background."
          },
          "size": {
            "type": "integer",
            "minimum": 64,
            "maximum": 2048,
            "default": 512
          },
          "format": {
            "type": "string",
            "enum": [
              "png",
              "svg"
            ],
            "default": "png",
            "description": "SVG requires a Pro plan."
          }
        },
        "additionalProperties": false
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Invalid or missing API key",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                },
                "signup_url": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "Plan or monthly usage limit reached",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                },
                "upgrade_url": {
                  "type": "string"
                },
                "usage": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
