{
  "openapi": "3.1.0",
  "info": {
    "title": "Webdesiz Developer API",
    "version": "1.0.0",
    "description": "Scoped organization-bound read-only stored snapshots. No public customer data in this schema. Key management uses the signed-in Webdesiz settings UI. Limits60/min/key,120/min/org,180/min/IP plus service protections."
  },
  "servers": [
    {
      "url": "https://webdesiz.com/api/v1/developer"
    }
  ],
  "paths": {
    "/accounts": {
      "get": {
        "operationId": "readAccountSnapshots",
        "summary": "Read stored accounts; scope accounts:read",
        "description": "Read only; no live Meta call, advertising write, AI generation or messaging. Organization comes from the key. Unknown query fields are rejected.",
        "security": [
          {
            "DeveloperKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            }
          },
          {
            "name": "accountId",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stored snapshot rows. May be stale. Account and campaign insight levels overlap; do not sum together.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Account"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "source": {
                          "const": "stored_snapshot"
                        },
                        "liveMetaRequest": {
                          "const": false
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "nextOffset": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "returned": {
                          "type": "integer"
                        },
                        "generatedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "dataAsOf": {
                          "type": "string"
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, expired or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope or current administrator membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Account unavailable in organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; wait60seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Protection service unavailable; fail closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/campaigns": {
      "get": {
        "operationId": "readCampaignSnapshots",
        "summary": "Read stored campaigns; scope campaigns:read",
        "description": "Read only; no live Meta call, advertising write, AI generation or messaging. Organization comes from the key. Unknown query fields are rejected.",
        "security": [
          {
            "DeveloperKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            }
          },
          {
            "name": "accountId",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stored snapshot rows. May be stale. Account and campaign insight levels overlap; do not sum together.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Campaign"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "source": {
                          "const": "stored_snapshot"
                        },
                        "liveMetaRequest": {
                          "const": false
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "nextOffset": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "returned": {
                          "type": "integer"
                        },
                        "generatedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "dataAsOf": {
                          "type": "string"
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, expired or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope or current administrator membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Account unavailable in organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; wait60seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Protection service unavailable; fail closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/insights": {
      "get": {
        "operationId": "readInsightSnapshots",
        "summary": "Read stored insights; scope insights:read",
        "description": "Read only; no live Meta call, advertising write, AI generation or messaging. Organization comes from the key. Unknown query fields are rejected.",
        "security": [
          {
            "DeveloperKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            }
          },
          {
            "name": "accountId",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,128}$"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "UTC date, valid range at most90days, no future dates; defaults to last30days"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "description": "UTC date, valid range at most90days, no future dates; defaults to last30days"
          }
        ],
        "responses": {
          "200": {
            "description": "Stored snapshot rows. May be stale. Account and campaign insight levels overlap; do not sum together.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "meta"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Insight"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "source": {
                          "const": "stored_snapshot"
                        },
                        "liveMetaRequest": {
                          "const": false
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "nextOffset": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "returned": {
                          "type": "integer"
                        },
                        "generatedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "dataAsOf": {
                          "type": "string"
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, expired or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Missing scope or current administrator membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Account unavailable in organization",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited; wait60seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Protection service unavailable; fail closed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "DeveloperKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "wd_live_ + 43base64urlcharacters",
        "description": "Send only in Authorization; never URL/query. Expires within90days."
      }
    },
    "schemas": {
      "Account": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "accountName": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean"
          },
          "lastSyncAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Campaign": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "metaAdAccountId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "objective": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "effectiveStatus": {
            "type": [
              "string",
              "null"
            ]
          },
          "dailyBudget": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decimal amount in account currency"
          },
          "lifetimeBudget": {
            "type": [
              "string",
              "null"
            ]
          },
          "syncedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "account": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string"
              },
              "timezone": {
                "type": "string"
              }
            }
          }
        }
      },
      "Insight": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "metaAdAccountId": {
            "type": "string"
          },
          "attributionWindow": {
            "type": "string"
          },
          "campaignId": {
            "type": [
              "string",
              "null"
            ]
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "syncedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "account": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string"
              },
              "timezone": {
                "type": "string"
              }
            }
          },
          "purchaseMeasurement": {
            "enum": [
              "reported_purchase_value",
              "reported_purchase_count",
              "unavailable"
            ]
          },
          "spend": {
            "type": "string",
            "description": "Stored decimal value"
          },
          "ctr": {
            "type": "string",
            "description": "Stored decimal value"
          },
          "cpc": {
            "type": "string",
            "description": "Stored decimal value"
          },
          "cpm": {
            "type": "string",
            "description": "Stored decimal value"
          },
          "impressions": {
            "type": "integer"
          },
          "reach": {
            "type": "integer"
          },
          "clicks": {
            "type": "integer"
          },
          "purchases": {
            "type": [
              "number",
              "null"
            ]
          },
          "purchaseValue": {
            "type": [
              "number",
              "null"
            ]
          },
          "roas": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "message": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          }
        }
      }
    }
  }
}
