{
  "openapi": "3.1.0",
  "info": {
    "title": "Cedar247 Order API",
    "version": "1.1.0",
    "description": "Place Cedar247 floor plan orders from your own software or AI assistant. Orders are priced like the website and paid from the prepaid wallet. Docs: https://cedar247.com/api-docs/",
    "contact": {
      "email": "hello@cedar247.com"
    }
  },
  "servers": [
    {
      "url": "https://cedar247.com/wp-json/cedar247/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key c247_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. X-API-Key header also accepted."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "fields": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "balance": {
                "type": "number"
              },
              "required": {
                "type": "number"
              },
              "topup_url": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        }
      },
      "OrderRequest": {
        "type": "object",
        "required": [
          "service"
        ],
        "properties": {
          "service": {
            "type": "string",
            "enum": [
              "matterport-floor-plan",
              "floor-plan-redraw",
              "3d-floor-plan",
              "scan-to-bim",
              "iphone-floor-plan",
              "matterport-video"
            ]
          },
          "reference": {
            "type": "string",
            "maxLength": 100,
            "description": "Your unique job id. Repeating it returns the existing order (duplicate: true), never a second charge."
          },
          "link": {
            "type": "string",
            "description": "Matterport link (matterport-floor-plan, 3d-floor-plan, scan-to-bim, matterport-video). iphone-floor-plan: Google Drive / WeTransfer link to the scan. floor-plan-redraw: added to the notes."
          },
          "address": {
            "type": "string"
          },
          "floors": {
            "type": [
              "string",
              "integer"
            ],
            "description": "1-6, or 10000 for '>= 10.000 sq.ft'. Auto-detected from the Matterport link when omitted."
          },
          "unit": {
            "type": "string",
            "examples": [
              "Imperial",
              "Metric",
              "Both",
              "None"
            ]
          },
          "language": {
            "type": "string",
            "examples": [
              "English",
              "Français",
              "Deutsch",
              "Čeština",
              "Español"
            ]
          },
          "naming": {
            "type": [
              "string",
              "integer"
            ],
            "description": "Floor naming style 1-5."
          },
          "extras": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "Add North Arrow",
                "6\" Wall Thickness"
              ]
            ]
          },
          "output": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "PDF",
                "SVG"
              ]
            ]
          },
          "paper": {
            "type": "string",
            "examples": [
              "Letter",
              "A4(Landscape)"
            ]
          },
          "style": {
            "type": [
              "string",
              "integer",
              "null"
            ],
            "description": "Colour style 1-12. null = black and white."
          },
          "siteplan": {
            "type": [
              "string",
              "integer",
              "boolean",
              "null"
            ],
            "description": "matterport-floor-plan: site plan style 1-4. 3d-floor-plan: true = add site plan (+$20)."
          },
          "cadfile": {
            "type": "boolean"
          },
          "floor3d": {
            "type": "boolean",
            "description": "Add a 3D floor plan to a matterport-floor-plan order. Price follows floors ($25-$125)."
          },
          "ceiling": {
            "type": "boolean",
            "description": "Add a ceiling plan to a matterport-floor-plan order (+$20)."
          },
          "delivery": {
            "type": "boolean",
            "description": "true = 12 hours rush."
          },
          "files": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "maxItems": 20,
            "description": "Public file URLs or URLs from POST /files."
          },
          "notes": {
            "type": "string"
          },
          "size": {
            "type": [
              "integer",
              "string"
            ],
            "description": "scan-to-bim: project size in square feet (e.g. 3200) or a size label. Read from the Matterport link when omitted. Above 15,000 sq ft: contact us."
          },
          "addons": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "scan-to-bim: Interior Furniture, MEP, Exterior. matterport-video: Add Minimap, Google Fly-in, GG Fly-in + Lot Line."
          },
          "file_link": {
            "type": "string",
            "description": "scan-to-bim: download link to MatterPak, E57 or other files."
          },
          "template_link": {
            "type": "string",
            "description": "scan-to-bim: link to your preferred template."
          },
          "scan_files": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "maxItems": 10,
            "description": "iphone-floor-plan: the scan export (OBJ, DAE or XYZ)."
          },
          "dwg": {
            "type": "boolean",
            "description": "iphone-floor-plan: add DWG file (+$1)."
          },
          "music": {
            "type": "string",
            "description": "matterport-video: Corporate, Piano, Ambient, Electronic, Upbeat / Energetic."
          },
          "use_defaults": {
            "type": "boolean",
            "default": true,
            "description": "Fill missing fields from the saved defaults of the account."
          },
          "payment": {
            "type": "string",
            "enum": [
              "wallet",
              "pay_link",
              "account"
            ],
            "default": "wallet"
          },
          "if_insufficient": {
            "type": "string",
            "enum": [
              "reject",
              "pay_link"
            ],
            "default": "reject"
          },
          "callback_url": {
            "type": "string",
            "format": "uri",
            "description": "HTTPS webhook URL for this order."
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "number": {
            "type": "string"
          },
          "service": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "stage": {
            "type": "string",
            "enum": [
              "awaiting_payment",
              "in_progress",
              "delivered",
              "on_hold",
              "cancelled",
              "refunded",
              "failed"
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "paid": {
            "type": "boolean"
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payment": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "subtotal": {
            "type": "number"
          },
          "discount": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "pay_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "options": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          },
          "files": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "downloads": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string"
                },
                "from": {
                  "type": "string",
                  "enum": [
                    "cedar247",
                    "customer"
                  ]
                },
                "text": {
                  "type": "string"
                },
                "links": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "view_url": {
            "type": "string"
          },
          "duplicate": {
            "type": "boolean"
          }
        }
      },
      "File": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "size": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/me": {
      "get": {
        "operationId": "getAccount",
        "summary": "Account, wallet balance and pay-later status",
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/services": {
      "get": {
        "operationId": "listServices",
        "summary": "Services, fields, allowed values, prices and saved defaults",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/quote": {
      "post": {
        "operationId": "quoteOrder",
        "summary": "Price an order without creating it",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/orders": {
      "post": {
        "operationId": "createOrder",
        "summary": "Place and pay an order",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Duplicate reference, existing order returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "listOrders",
        "summary": "Your orders, newest first",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50,
              "default": 20
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "reference",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "api"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "operationId": "getOrder",
        "summary": "One order with status, files, messages and downloads",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/orders/{id}/messages": {
      "post": {
        "operationId": "sendOrderMessage",
        "summary": "Send a message or revision request to the Cedar247 team",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message"
                ],
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sent"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/files": {
      "post": {
        "operationId": "uploadFile",
        "summary": "Upload a file (multipart 'file' up to 100 MB, JSON {name,data base64} up to 25 MB, or JSON {url})",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "data": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  }
}
