{
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "description": "LumaTrack API key, sent as Authorization: Bearer <key>",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "Record automation run events and read realized value from LumaTrack, the system of record for automation value. Authenticate with an API key from Settings, API keys (Authorization: Bearer <key>).",
    "title": "LumaTrack",
    "version": "1"
  },
  "openapi": "3.0.3",
  "paths": {
    "/api/v1/automations": {
      "get": {
        "description": "Slugs, names, and statuses of your automations.",
        "operationId": "listAutomations",
        "responses": {
          "200": {
            "description": "Automation list"
          }
        },
        "summary": "List Automations",
        "tags": [
          "Automations"
        ]
      },
      "post": {
        "description": "Create an automation (as a candidate) so workflows can report against it without visiting the app first.",
        "operationId": "createAutomation",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "manual_minutes": 15,
                "name": "User Onboarding"
              },
              "schema": {
                "properties": {
                  "manual_minutes": {
                    "description": "Minutes a person needs for one manual execution (the baseline)",
                    "example": 15,
                    "type": "number"
                  },
                  "name": {
                    "example": "User Onboarding",
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ],
                "type": "object"
              }
            }
          },
          "description": "The automation to create.",
          "required": true
        },
        "responses": {
          "201": {
            "description": "Automation created"
          },
          "400": {
            "description": "Invalid payload"
          }
        },
        "summary": "Create Automation",
        "tags": [
          "Automations"
        ]
      }
    },
    "/api/v1/runs": {
      "post": {
        "description": "Report one automation execution (success or failure) to the value ledger. Send a stable external_id to make retries idempotent.",
        "operationId": "recordRun",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "automation": "user-onboarding",
                "duration_seconds": 42,
                "external_id": "rewst-exec-8f2a1c",
                "source": "rewst",
                "status": "success",
                "units": 3
              },
              "schema": {
                "properties": {
                  "automation": {
                    "description": "Automation slug in LumaTrack",
                    "example": "user-onboarding",
                    "type": "string"
                  },
                  "duration_seconds": {
                    "description": "Wall-clock runtime in seconds",
                    "example": 42,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "executed_at": {
                    "description": "When the run happened; omit to stamp now",
                    "format": "date-time",
                    "type": "string"
                  },
                  "external_id": {
                    "description": "Idempotency key. In a Rewst workflow, bind this to {{ CTX.execution_id }} so retries dedupe instead of double-counting.",
                    "example": "rewst-exec-8f2a1c",
                    "type": "string"
                  },
                  "failure_reason": {
                    "description": "Root cause for failures",
                    "example": "SMTP timeout after 3 retries",
                    "type": "string"
                  },
                  "metadata": {
                    "additionalProperties": true,
                    "description": "Arbitrary JSON kept with the run",
                    "example": {
                      "tenant": "contoso"
                    },
                    "type": "object"
                  },
                  "source": {
                    "description": "Where the run came from; send \"rewst\". Omitted runs are stored with a blank source.",
                    "example": "rewst",
                    "type": "string"
                  },
                  "status": {
                    "default": "success",
                    "enum": [
                      "success",
                      "failure",
                      "skipped",
                      "cancelled"
                    ],
                    "type": "string"
                  },
                  "units": {
                    "description": "Records or items this run processed; drives per-unit valuation",
                    "example": 3,
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "automation"
                ],
                "type": "object"
              }
            }
          },
          "description": "The automation execution to record.",
          "required": true
        },
        "responses": {
          "200": {
            "description": "Replay: this external_id was already recorded, so nothing was double-counted"
          },
          "201": {
            "description": "Run recorded"
          },
          "202": {
            "description": "Run recorded but held over the plan cap"
          },
          "400": {
            "description": "Invalid payload"
          },
          "404": {
            "description": "No automation with that slug"
          },
          "429": {
            "description": "Rate limited; retry after the Retry-After interval"
          }
        },
        "summary": "Record Run",
        "tags": [
          "Runs"
        ]
      }
    },
    "/api/v1/summary": {
      "get": {
        "description": "The organization's realized value summary: hours saved, gross and net savings, ROI percent, run counts.",
        "operationId": "getRoiSummary",
        "parameters": [
          {
            "description": "Filter the summary to one workspace within this key's organization by its public id; omit for the whole organization. Separate managed clients are separate organizations, each with its own key.",
            "in": "query",
            "name": "workspace",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Summary payload"
          },
          "404": {
            "description": "No workspace with that id in your organization"
          }
        },
        "summary": "Get ROI Summary",
        "tags": [
          "Reporting"
        ]
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "servers": [
    {
      "url": "https://lumatrack.io"
    }
  ],
  "tags": [
    {
      "description": "Report automation executions to the value ledger.",
      "name": "Runs"
    },
    {
      "description": "Read realized value back out.",
      "name": "Reporting"
    },
    {
      "description": "List and create automations.",
      "name": "Automations"
    }
  ]
}
