{
  "openapi": "3.1.0",
  "info": {
    "title": "StoreOnCall API",
    "version": "1.0.0",
    "description": "Read-only access to your stores, incidents, monthly reports and hourly orders. Available on the Business and Agency plans. Create keys in Settings > API keys; each key belongs to one account and is shown once."
  },
  "servers": [
    {
      "url": "https://app.storeoncall.com"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer socapi_..."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Store": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "client": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "healthy",
              "attention",
              "problem",
              "quiet",
              "not_connected"
            ]
          },
          "connectedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lastHeartbeatAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "magentoVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "edition": {
            "type": [
              "string",
              "null"
            ]
          },
          "agentVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "checkoutTestEnabled": {
            "type": "boolean"
          },
          "lastCheckoutTest": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "ok": {
                "type": "boolean"
              },
              "blocked": {
                "type": "boolean"
              },
              "at": {
                "type": "string",
                "format": "date-time"
              },
              "step": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "openIncident": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "severity": {
                "type": "string"
              },
              "opened_at": {
                "type": "string"
              },
              "acknowledged_at": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Incident": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "store_name": {
            "type": "string"
          },
          "client": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "critical",
              "high",
              "medium",
              "low"
            ]
          },
          "opened_at": {
            "type": "string",
            "format": "date-time"
          },
          "resolved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "likely_cause": {
            "type": [
              "string",
              "null"
            ]
          },
          "money_per_hour": {
            "type": [
              "number",
              "null"
            ]
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "acknowledged_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "acknowledged_by": {
            "type": [
              "string",
              "null"
            ]
          },
          "assignee": {
            "type": [
              "string",
              "null"
            ]
          },
          "escalated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Report": {
        "type": "object",
        "properties": {
          "storeId": {
            "type": "string"
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "incidents": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "incidentMinutes": {
            "type": "integer"
          },
          "checkoutTests": {
            "type": "integer"
          },
          "checkoutPassRate": {
            "type": [
              "number",
              "null"
            ],
            "description": "Percent, excluding tests blocked by a firewall"
          },
          "heartbeatCoverage": {
            "type": [
              "number",
              "null"
            ],
            "description": "Percent of 5-minute slots with a plugin report"
          },
          "orders": {
            "type": "integer"
          },
          "revenue": {
            "type": "number"
          },
          "changes": {
            "type": "object",
            "properties": {
              "deploys": {
                "type": "integer"
              },
              "extensionChanges": {
                "type": "integer"
              },
              "configChanges": {
                "type": "integer"
              }
            }
          }
        }
      },
      "Orders": {
        "type": "object",
        "properties": {
          "learning": {
            "type": "boolean",
            "description": "True until there is enough history to know what is normal"
          },
          "points": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "hour": {
                  "type": "string",
                  "format": "date-time"
                },
                "orders": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "normal": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "partial": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/stores": {
      "get": {
        "summary": "List stores",
        "description": "Every store in the account, with its status, last plugin report and last checkout test.",
        "responses": {
          "200": {
            "description": "Stores",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Store"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/stores/{id}": {
      "get": {
        "summary": "Get a store",
        "description": "One store, including any planned-work window in force.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The store",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Store"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/incidents": {
      "get": {
        "summary": "List incidents",
        "description": "Incidents in a date range (default: the last 30 days), newest first.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "resolved",
                "unacknowledged"
              ]
            }
          },
          {
            "name": "store",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Store id"
          },
          {
            "name": "severity",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "critical",
                "high",
                "medium",
                "low"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Incidents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Incident"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/incidents/{id}": {
      "get": {
        "summary": "Get an incident",
        "description": "One incident with its full timeline: detection, alerts, acknowledgement, notes and resolution.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The incident and its timeline",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Incident"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/stores/{id}/report": {
      "get": {
        "summary": "Reliability report",
        "description": "Problems, checkout tests, monitoring coverage, orders and changes for a calendar month, or the last 30 days.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "month",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}$"
            },
            "description": "For example 2026-11"
          }
        ],
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Report"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/stores/{id}/orders": {
      "get": {
        "summary": "Hourly orders against normal",
        "description": "Orders per hour and the normal level for each hour.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hours",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 6,
              "maximum": 336,
              "default": 48
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hourly orders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Orders"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 120 requests a minute for this key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
