{
 "openapi": "3.0.3",
 "info": {
  "title": "Dream Command Center API",
  "version": "1.0.0",
  "description": "The health of your Salesforce orgs as data: the Org Health Index and grade, issues, reviews, monitoring, compliance evidence and activity, plus actions for your own tools. Every answer is JSON with ok; errors carry error.code and error.status. Documentation: https://health.dream.cloud/docs/api/",
  "contact": {
   "name": "Dream",
   "url": "https://dream.cloud/contact.html"
  }
 },
 "servers": [
  {
   "url": "https://health.dream.cloud/v1"
  }
 ],
 "security": [
  {
   "bearerAuth": []
  }
 ],
 "tags": [
  {
   "name": "Orgs"
  },
  {
   "name": "Org Health"
  },
  {
   "name": "Deploy gate"
  },
  {
   "name": "Issues"
  }
 ],
 "paths": {
  "/orgs": {
   "get": {
    "operationId": "listOrgs",
    "summary": "Connected orgs with their connection, monitoring and latest review; with id, one org and its planning answers",
    "tags": [
     "Orgs"
    ],
    "description": "Connected orgs with their connection, monitoring and latest review; with id, one org and its planning answers. Scope: `orgs:read`.",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": false,
      "description": "One org",
      "schema": {
       "type": "integer"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success (ok is true)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "ok",
          "request_id"
         ],
         "properties": {
          "ok": {
           "type": "boolean",
           "description": "true on success; false with an error"
          },
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "connection": {
              "type": "string"
             },
             "id": {
              "type": "integer"
             },
             "last_review": {
              "type": "object",
              "properties": {
               "finished_at": {
                "type": "string"
               },
               "grade": {
                "type": "string"
               },
               "id": {
                "type": "integer"
               },
               "index": {
                "type": "number"
               },
               "run_id": {
                "type": "string"
               }
              }
             },
             "monitoring": {
              "type": "boolean"
             },
             "name": {
              "type": "string"
             },
             "open_alerts": {
              "type": "integer"
             },
             "type": {
              "type": "string"
             }
            }
           }
          },
          "request_id": {
           "type": "string",
           "example": "req_4f2a9c0e1b7d3a5c6e8f"
          },
          "error": {
           "$ref": "#/components/schemas/Error"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Error: unauthorized",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "403": {
      "description": "Error: plan_required, ip_not_allowed, insufficient_scope",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "404": {
      "description": "Error: not_found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "422": {
      "description": "Error: invalid",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "429": {
      "description": "Error: limit_reached, rate_limited",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "500": {
      "description": "Error: internal",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     }
    }
   }
  },
  "/health": {
   "get": {
    "operationId": "getHealth",
    "summary": "Latest Org Health Index, grade and areas, the trend, what the quick fixes and your decisions would reach, and the saved plan",
    "tags": [
     "Org Health"
    ],
    "description": "Latest Org Health Index, grade and areas, the trend, what the quick fixes and your decisions would reach, and the saved plan. Scope: `health:read`.",
    "parameters": [
     {
      "name": "org",
      "in": "query",
      "required": true,
      "description": "Org id (from GET /v1/orgs)",
      "schema": {
       "type": "integer"
      },
      "example": 12
     }
    ],
    "responses": {
     "200": {
      "description": "Success (ok is true)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "ok",
          "request_id"
         ],
         "properties": {
          "ok": {
           "type": "boolean",
           "description": "true on success; false with an error"
          },
          "data": {
           "type": "object",
           "properties": {
            "areas": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "area": {
                "type": "string"
               },
               "checks": {
                "type": "integer"
               },
               "score": {
                "type": "number"
               }
              }
             }
            },
            "grade": {
             "type": "string"
            },
            "healthy_at": {
             "type": "integer"
            },
            "index": {
             "type": "number"
            },
            "org": {
             "type": "object",
             "properties": {
              "id": {
               "type": "integer"
              },
              "name": {
               "type": "string"
              }
             }
            },
            "plan": {
             "type": "object",
             "properties": {
              "items": {
               "type": "integer"
              },
              "gain": {
               "type": "number"
              },
              "to": {
               "type": "number"
              },
              "findings": {
               "type": "array",
               "items": {
                "type": "integer"
               }
              }
             },
             "nullable": true
            },
            "plan_saved_at": {
             "type": "string",
             "format": "date-time",
             "nullable": true
            },
            "plan_saved_by": {
             "type": "string",
             "nullable": true
            },
            "previous": {
             "type": "object",
             "properties": {
              "review": {
               "type": "integer"
              },
              "run_id": {
               "type": "string"
              },
              "index": {
               "type": "number"
              },
              "grade": {
               "type": "string"
              },
              "projected": {
               "type": "object",
               "nullable": true,
               "properties": {
                "base": {
                 "type": "number"
                },
                "quick": {
                 "type": "object",
                 "nullable": true,
                 "properties": {
                  "n": {
                   "type": "integer"
                  },
                  "gain": {
                   "type": "number"
                  },
                  "to": {
                   "type": "number"
                  }
                 }
                },
                "decision": {
                 "type": "object",
                 "nullable": true,
                 "properties": {
                  "n": {
                   "type": "integer"
                  },
                  "gain": {
                   "type": "number"
                  },
                  "to": {
                   "type": "number"
                  }
                 }
                },
                "project": {
                 "type": "object",
                 "nullable": true,
                 "properties": {
                  "n": {
                   "type": "integer"
                  },
                  "gain": {
                   "type": "number"
                  },
                  "to": {
                   "type": "number"
                  }
                 }
                },
                "renewal": {
                 "type": "object",
                 "nullable": true,
                 "properties": {
                  "n": {
                   "type": "integer"
                  },
                  "gain": {
                   "type": "number"
                  },
                  "to": {
                   "type": "number"
                  }
                 }
                }
               }
              },
              "plan": {
               "type": "object",
               "nullable": true,
               "properties": {
                "items": {
                 "type": "integer"
                },
                "gain": {
                 "type": "number"
                },
                "to": {
                 "type": "number"
                },
                "findings": {
                 "type": "array",
                 "items": {
                  "type": "integer"
                 }
                }
               }
              }
             },
             "nullable": true
            },
            "projection": {
             "type": "object",
             "properties": {
              "base": {
               "type": "number"
              },
              "decision": {
               "type": "object",
               "properties": {
                "gain": {
                 "type": "number"
                },
                "n": {
                 "type": "integer"
                },
                "to": {
                 "type": "number"
                }
               }
              },
              "project": {
               "type": "object",
               "properties": {
                "gain": {
                 "type": "number"
                },
                "n": {
                 "type": "integer"
                },
                "to": {
                 "type": "number"
                }
               }
              },
              "quick": {
               "type": "object",
               "properties": {
                "gain": {
                 "type": "number"
                },
                "n": {
                 "type": "integer"
                },
                "to": {
                 "type": "number"
                }
               }
              },
              "renewal": {
               "type": "object",
               "properties": {
                "gain": {
                 "type": "number"
                },
                "n": {
                 "type": "integer"
                },
                "to": {
                 "type": "number"
                }
               }
              }
             }
            },
            "review": {
             "type": "object",
             "properties": {
              "finished_at": {
               "type": "string"
              },
              "id": {
               "type": "integer"
              },
              "run_id": {
               "type": "string"
              }
             }
            },
            "trend": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "at": {
                "type": "string"
               },
               "grade": {
                "type": "string"
               },
               "index": {
                "type": "number"
               },
               "review": {
                "type": "integer"
               },
               "run_id": {
                "type": "string"
               }
              }
             }
            }
           }
          },
          "request_id": {
           "type": "string",
           "example": "req_4f2a9c0e1b7d3a5c6e8f"
          },
          "error": {
           "$ref": "#/components/schemas/Error"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Error: unauthorized",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "403": {
      "description": "Error: plan_required, ip_not_allowed, insufficient_scope",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "404": {
      "description": "Error: not_found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "422": {
      "description": "Error: invalid",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "429": {
      "description": "Error: limit_reached, rate_limited",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "500": {
      "description": "Error: internal",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     }
    }
   }
  },
  "/gate": {
   "get": {
    "operationId": "checkGate",
    "summary": "Pass or fail against your thresholds, with the reasons: for deploy pipelines",
    "tags": [
     "Deploy gate"
    ],
    "description": "Pass or fail against your thresholds, with the reasons: for deploy pipelines. Scope: `health:read`.",
    "parameters": [
     {
      "name": "org",
      "in": "query",
      "required": true,
      "description": "Org id (from GET /v1/orgs)",
      "schema": {
       "type": "integer"
      },
      "example": 12
     },
     {
      "name": "min_grade",
      "in": "query",
      "required": false,
      "description": "Lowest acceptable grade",
      "schema": {
       "type": "string",
       "enum": [
        "A",
        "B",
        "C",
        "D",
        "F"
       ]
      },
      "example": "C"
     },
     {
      "name": "min_index",
      "in": "query",
      "required": false,
      "description": "Lowest acceptable Org Health Index (0 to 100)",
      "schema": {
       "type": "number"
      },
      "example": 70
     },
     {
      "name": "max_critical",
      "in": "query",
      "required": false,
      "description": "Most open critical issues allowed",
      "schema": {
       "type": "integer"
      },
      "example": 0
     },
     {
      "name": "max_new_critical",
      "in": "query",
      "required": false,
      "description": "Most critical issues opened by the latest review or in the last 24 hours",
      "schema": {
       "type": "integer"
      },
      "example": 0
     },
     {
      "name": "max_drop",
      "in": "query",
      "required": false,
      "description": "Largest allowed fall of the Index since the previous review",
      "schema": {
       "type": "number"
      },
      "example": 5
     }
    ],
    "responses": {
     "200": {
      "description": "Success (ok is true)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "ok",
          "request_id"
         ],
         "properties": {
          "ok": {
           "type": "boolean",
           "description": "true on success; false with an error"
          },
          "data": {
           "type": "object",
           "properties": {
            "critical_open": {
             "type": "integer"
            },
            "drop": {
             "type": "number",
             "nullable": true
            },
            "grade": {
             "type": "string"
            },
            "index": {
             "type": "number"
            },
            "new_critical": {
             "type": "integer"
            },
            "org": {
             "type": "object",
             "properties": {
              "id": {
               "type": "integer"
              },
              "name": {
               "type": "string"
              }
             }
            },
            "pass": {
             "type": "boolean"
            },
            "previous_index": {
             "type": "number",
             "nullable": true
            },
            "reasons": {
             "type": "array",
             "items": {
              "type": "string"
             }
            },
            "review": {
             "type": "object",
             "properties": {
              "finished_at": {
               "type": "string"
              },
              "id": {
               "type": "integer"
              },
              "run_id": {
               "type": "string"
              }
             }
            },
            "rules": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "actual": {
                "type": "string"
               },
               "pass": {
                "type": "boolean"
               },
               "required": {
                "type": "string"
               },
               "rule": {
                "type": "string"
               }
              }
             }
            }
           }
          },
          "request_id": {
           "type": "string",
           "example": "req_4f2a9c0e1b7d3a5c6e8f"
          },
          "error": {
           "$ref": "#/components/schemas/Error"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Error: unauthorized",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "403": {
      "description": "Error: plan_required, ip_not_allowed, insufficient_scope",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "404": {
      "description": "Error: not_found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "422": {
      "description": "Error: invalid",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "429": {
      "description": "Error: limit_reached, rate_limited",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "500": {
      "description": "Error: internal",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     }
    }
   }
  },
  "/issues": {
   "get": {
    "operationId": "listIssues",
    "summary": "Findings (FND-) and alerts (ALR-); with id, one issue with its history, exceptions and how to fix it",
    "tags": [
     "Issues"
    ],
    "description": "Findings (FND-) and alerts (ALR-); with id, one issue with its history, exceptions and how to fix it. Scope: `issues:read`.",
    "parameters": [
     {
      "name": "org",
      "in": "query",
      "required": false,
      "description": "Only this org (from GET /v1/orgs)",
      "schema": {
       "type": "integer"
      },
      "example": 12
     },
     {
      "name": "id",
      "in": "query",
      "required": false,
      "description": "One issue, for example FND-41",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "status",
      "in": "query",
      "required": false,
      "description": "open (default: open, acknowledged, snoozed), acknowledged, snoozed, dismissed, resolved or all",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "severity",
      "in": "query",
      "required": false,
      "description": "warn or critical",
      "schema": {
       "type": "string",
       "enum": [
        "warn",
        "critical"
       ]
      }
     },
     {
      "name": "kind",
      "in": "query",
      "required": false,
      "description": "finding or alert",
      "schema": {
       "type": "string",
       "enum": [
        "finding",
        "alert"
       ]
      }
     },
     {
      "name": "updated_since",
      "in": "query",
      "required": false,
      "description": "Only issues changed at or after this ISO time",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "include_items",
      "in": "query",
      "required": false,
      "description": "Add the affected items (needs issues:items)",
      "schema": {
       "type": "boolean"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Success (ok is true)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "ok",
          "request_id"
         ],
         "properties": {
          "ok": {
           "type": "boolean",
           "description": "true on success; false with an error"
          },
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "area": {
              "type": "string"
             },
             "check": {
              "type": "string"
             },
             "due_at": {
              "type": "string"
             },
             "id": {
              "type": "string"
             },
             "items_count": {
              "type": "integer"
             },
             "kind": {
              "type": "string"
             },
             "last_seen_at": {
              "type": "string"
             },
             "occurrences": {
              "type": "integer"
             },
             "opened_at": {
              "type": "string"
             },
             "org": {
              "type": "integer"
             },
             "owner": {
              "type": "string",
              "nullable": true
             },
             "regressed": {
              "type": "boolean"
             },
             "resolved_at": {
              "type": "string",
              "format": "date-time",
              "nullable": true
             },
             "resolved_by": {
              "type": "string",
              "nullable": true
             },
             "severity": {
              "type": "string"
             },
             "snooze_until": {
              "type": "string",
              "format": "date-time",
              "nullable": true
             },
             "status": {
              "type": "string"
             },
             "ticket": {
              "type": "object",
              "properties": {
               "ref": {
                "type": "string"
               },
               "url": {
                "type": "string"
               }
              },
              "nullable": true
             },
             "title": {
              "type": "string"
             },
             "updated_at": {
              "type": "string"
             },
             "value_text": {
              "type": "string"
             },
             "verify_state": {
              "type": "string",
              "enum": [
               "pending",
               "confirmed",
               "failed"
              ],
              "nullable": true
             }
            }
           }
          },
          "request_id": {
           "type": "string",
           "example": "req_4f2a9c0e1b7d3a5c6e8f"
          },
          "error": {
           "$ref": "#/components/schemas/Error"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Error: unauthorized",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "403": {
      "description": "Error: plan_required, ip_not_allowed, insufficient_scope",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "404": {
      "description": "Error: not_found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "422": {
      "description": "Error: invalid",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "429": {
      "description": "Error: limit_reached, rate_limited",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "500": {
      "description": "Error: internal",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     }
    }
   },
   "post": {
    "operationId": "postIssues",
    "summary": "Issues: actions",
    "tags": [
     "Issues"
    ],
    "description": "Send a JSON body with `action` and its fields.\n\n- `acknowledge`: Acknowledge an issue, optionally naming the owner (scope `issues:write`); needs `id`\n- `assign`: Change the owner (scope `issues:write`); needs `id`, `owner`\n- `resolve`: Report it fixed; the next check or review confirms the fix, or reopens the issue (scope `issues:write`); needs `id`\n- `comment`: Add a note to the history (scope `issues:write`); needs `id`, `note`\n- `link`: Link a ticket of your own system (Jira, ServiceNow, Azure DevOps, ...) (scope `issues:write`); needs `id`, `ticket_ref`",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "action"
        ],
        "properties": {
         "action": {
          "type": "string",
          "enum": [
           "acknowledge",
           "assign",
           "resolve",
           "comment",
           "link"
          ],
          "description": "What to do"
         },
         "id": {
          "type": "string",
          "description": "Issue id, e.g. FND-41"
         },
         "owner": {
          "type": "string",
          "description": "Email of a user of your account"
         },
         "note": {
          "type": "string",
          "description": "What was done"
         },
         "ticket_ref": {
          "type": "string",
          "description": "Ticket key, e.g. OPS-7"
         },
         "ticket_url": {
          "type": "string",
          "description": "https link to the ticket"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Success (ok is true)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "ok",
          "request_id"
         ],
         "properties": {
          "ok": {
           "type": "boolean",
           "description": "true on success; false with an error"
          },
          "data": {
           "type": "object"
          },
          "request_id": {
           "type": "string",
           "example": "req_4f2a9c0e1b7d3a5c6e8f"
          },
          "error": {
           "$ref": "#/components/schemas/Error"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Error: unauthorized",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "403": {
      "description": "Error: plan_required, ip_not_allowed, insufficient_scope",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "404": {
      "description": "Error: not_found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "409": {
      "description": "Error: conflict",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "422": {
      "description": "Error: invalid",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "429": {
      "description": "Error: limit_reached, rate_limited",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     },
     "500": {
      "description": "Error: internal",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ErrorAnswer"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearerAuth": {
    "type": "http",
    "scheme": "bearer",
    "bearerFormat": "drm_...",
    "description": "An API token from Admin > API access, sent as Authorization: Bearer drm_..."
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "code": {
      "type": "string",
      "enum": [
       "conflict",
       "insufficient_scope",
       "internal",
       "invalid",
       "ip_not_allowed",
       "limit_reached",
       "not_found",
       "plan_required",
       "rate_limited",
       "unauthorized"
      ]
     },
     "status": {
      "type": "integer",
      "description": "The HTTP status this error stands for"
     },
     "message": {
      "type": "string"
     },
     "retry_after": {
      "type": "integer",
      "description": "rate_limited only: seconds to wait"
     }
    }
   },
   "ErrorAnswer": {
    "type": "object",
    "required": [
     "ok",
     "error",
     "request_id"
    ],
    "properties": {
     "ok": {
      "type": "boolean",
      "description": "false"
     },
     "error": {
      "$ref": "#/components/schemas/Error"
     },
     "request_id": {
      "type": "string",
      "example": "req_4f2a9c0e1b7d3a5c6e8f"
     }
    }
   }
  }
 }
}