{
  "openapi": "3.1.0",
  "info": {
    "title": "OMG Security API",
    "version": "1.0.0",
    "summary": "Public CVE records, index metrics, and package advisory lookups.",
    "description": "The public API requires no key. Package lookup returns advisory matches by ecosystem and name. Commercial operations require an enabled workspace and a server-side API key. See [pricing](https://security.getomg.dev/pricing) for plans and [account](https://security.getomg.dev/account) for subscription management.",
    "contact": {
      "name": "OMG Security",
      "url": "https://security.getomg.dev/"
    },
    "license": {
      "name": "Upstream Attribution & Commercial Data Notices",
      "url": "https://security.getomg.dev/sources#data-notices"
    }
  },
  "servers": [
    {
      "url": "https://security.getomg.dev",
      "description": "OMG Security API"
    }
  ],
  "externalDocs": {
    "description": "API reference and integration guides",
    "url": "https://security.getomg.dev/docs/api-reference/"
  },
  "tags": [
    {
      "name": "Public Index",
      "description": "Unauthenticated CVE, EPSS, status, metrics, and search endpoints"
    },
    {
      "name": "Packages",
      "description": "Single and batch advisory lookup by ecosystem and package name"
    },
    {
      "name": "Commercial",
      "description": "Authenticated endpoints for customer workspaces"
    },
    {
      "name": "Documentation",
      "description": "Machine-readable OpenAPI, Markdown, and agent discovery endpoints"
    }
  ],
  "components": {
    "headers": {
      "MatchScope": {
        "description": "Identity used for advisory matching.",
        "schema": {
          "type": "string",
          "enum": [
            "package_name",
            "exact_version",
            "mixed"
          ]
        }
      },
      "ResultLimit": {
        "description": "Maximum number of findings in this response.",
        "schema": {
          "type": "integer"
        }
      },
      "ResultLimitReached": {
        "description": "True when the response reaches the result cap. Further findings may exist.",
        "schema": {
          "type": "string",
          "enum": [
            "true",
            "false"
          ]
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Secret commercial API key for an enabled workspace. Store it on the server or in CI."
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-OMG-API-Key",
        "description": "Alternative to the Authorization bearer header for an enabled workspace."
      }
    },
    "parameters": {
      "CveId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Canonical CVE identifier",
        "schema": {
          "type": "string",
          "pattern": "^CVE-\\d{4}-\\d{4,19}$"
        },
        "example": "CVE-2026-12345"
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "LatencyDistribution": {
        "type": "object",
        "required": [
          "samples",
          "p50_ms",
          "p95_ms"
        ],
        "properties": {
          "samples": {
            "type": "integer",
            "minimum": 0
          },
          "p50_ms": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0
          },
          "p95_ms": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0
          }
        }
      },
      "MetricsResponse": {
        "type": "object",
        "description": "Rolling 24-hour delivery latency percentiles (ms) and current index counts.",
        "required": [
          "schema_version",
          "as_of",
          "cve_index",
          "inventory",
          "delivery",
          "methodology",
          "data_notices"
        ],
        "properties": {
          "schema_version": {
            "type": "integer",
            "const": 1
          },
          "as_of": {
            "type": "string",
            "format": "date-time"
          },
          "cve_index": {
            "type": "object",
            "required": [
              "checked_at",
              "current"
            ],
            "properties": {
              "checked_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "current": {
                "type": "boolean"
              }
            }
          },
          "inventory": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "as_of": {
                "type": "string",
                "format": "date-time"
              },
              "current": {
                "type": "boolean"
              },
              "publication_window_start": {
                "type": "string",
                "format": "date-time"
              },
              "cve_records": {
                "type": "integer"
              },
              "cves_published_24h": {
                "type": "integer"
              },
              "documented_zero_day_cves": {
                "type": "integer"
              },
              "package_advisory_ids": {
                "type": "integer"
              },
              "malware_advisory_ids": {
                "type": "integer"
              }
            }
          },
          "delivery": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "window_hours": {
                "type": "integer",
                "const": 24
              },
              "sample_limit": {
                "type": "integer",
                "minimum": 0
              },
              "initial_publications": {
                "type": "integer",
                "minimum": 0
              },
              "tracking_started_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "publication_to_intake": {
                "$ref": "#/components/schemas/LatencyDistribution"
              },
              "publication_to_index_write": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/LatencyDistribution"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "publication_to_confirmed_index": {
                "$ref": "#/components/schemas/LatencyDistribution"
              },
              "publication_to_notification": {
                "$ref": "#/components/schemas/LatencyDistribution"
              },
              "publication_to_api_reject": {
                "$ref": "#/components/schemas/LatencyDistribution"
              }
            }
          },
          "methodology": {
            "type": "string",
            "example": "/sources#delivery"
          },
          "data_notices": {
            "type": "string",
            "example": "/sources#data-notices"
          }
        }
      },
      "PackageCoordinate": {
        "type": "object",
        "description": "Package identity for advisory lookup. The API evaluates ecosystem and name.",
        "required": [
          "ecosystem",
          "name"
        ],
        "properties": {
          "ecosystem": {
            "type": "string",
            "example": "npm"
          },
          "name": {
            "type": "string",
            "example": "lodash"
          }
        }
      },
      "PackageAuditRequest": {
        "type": "object",
        "required": [
          "packages"
        ],
        "properties": {
          "packages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/PackageCoordinate"
                },
                {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "string",
                      "maxLength": 128
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "PackageAuditResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "checked_at",
          "queried",
          "malware_count",
          "kev_count",
          "findings",
          "scoped_advisories",
          "result_limit_reached"
        ],
        "properties": {
          "schema_version": {
            "type": "integer",
            "const": 1
          },
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "queried": {
            "type": "integer",
            "minimum": 1,
            "description": "Coordinates submitted to the advisory query"
          },
          "malware_count": {
            "type": "integer",
            "minimum": 0,
            "description": "Returned finding rows marked as malware"
          },
          "kev_count": {
            "type": "integer",
            "minimum": 0,
            "description": "Returned finding rows with a CISA KEV match"
          },
          "findings": {
            "type": "array",
            "maxItems": 1000,
            "items": {
              "type": "object"
            }
          },
          "scoped_advisories": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Version-specific or unresolved advisories excluded from finding counts."
          },
          "result_limit_reached": {
            "type": "boolean"
          }
        }
      },
      "WatchlistTarget": {
        "$ref": "#/components/schemas/PackageCoordinate"
      },
      "WebhookCreateRequest": {
        "type": "object",
        "required": [
          "target_url"
        ],
        "properties": {
          "target_url": {
            "type": "string",
            "format": "uri",
            "example": "https://hooks.example.com/omg"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "cve.published"
              ]
            }
          }
        }
      },
      "WebhookReplayRequest": {
        "type": "object",
        "required": [
          "delivery_id"
        ],
        "properties": {
          "delivery_id": {
            "type": "string",
            "example": "del_123456"
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/openapi.json": {
      "get": {
        "tags": [
          "Documentation"
        ],
        "summary": "Get OpenAPI 3.1 specification",
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 JSON document"
          }
        }
      }
    },
    "/api/v1/status": {
      "get": {
        "tags": [
          "Public Index"
        ],
        "summary": "Upstream feed freshness and baseline proof state",
        "responses": {
          "200": {
            "description": "Feed checkpoints and delta state"
          },
          "503": {
            "description": "Upstream status unavailable"
          }
        }
      }
    },
    "/api/v1/metrics": {
      "get": {
        "tags": [
          "Public Index"
        ],
        "summary": "Index counts and measured rolling 24-hour latency percentiles",
        "responses": {
          "200": {
            "description": "Latency percentiles and index totals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricsResponse"
                }
              }
            }
          },
          "503": {
            "description": "Snapshot unavailable"
          }
        }
      }
    },
    "/api/v1/cves/recent": {
      "get": {
        "tags": [
          "Public Index"
        ],
        "summary": "Paginate newest verified CVE revisions across the trailing 30-day window",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Opaque pagination cursor returned by next_cursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Newest CVE revisions ordered newest-first"
          },
          "400": {
            "description": "Invalid limit or expired cursor"
          }
        }
      }
    },
    "/api/v1/cves/{id}": {
      "get": {
        "tags": [
          "Public Index"
        ],
        "summary": "Fetch canonical CVE JSON 5 record with SHA-256 provenance and KEV annotation",
        "parameters": [
          {
            "$ref": "#/components/parameters/CveId"
          },
          {
            "name": "view",
            "in": "query",
            "description": "Pass summary to omit full payload_json",
            "schema": {
              "type": "string",
              "enum": [
                "summary"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verified CVE record or slim summary"
          },
          "400": {
            "description": "Invalid CVE ID or query parameter"
          },
          "404": {
            "description": "CVE not yet indexed"
          }
        }
      }
    },
    "/api/v1/epss/{id}": {
      "get": {
        "tags": [
          "Public Index"
        ],
        "summary": "Retrieve FIRST EPSS score, percentile, and recent history for a CVE",
        "parameters": [
          {
            "$ref": "#/components/parameters/CveId"
          }
        ],
        "responses": {
          "200": {
            "description": "FIRST EPSS score, percentile, and history when available. Inspect the status and score date."
          },
          "404": {
            "description": "CVE not found"
          }
        }
      }
    },
    "/api/search": {
      "get": {
        "tags": [
          "Public Index"
        ],
        "summary": "Search across indexed packages, CVEs, and malware advisories",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Package name, advisory ID, or CVE prefix (2 to 80 characters)",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 80
            },
            "example": "lodash"
          }
        ],
        "responses": {
          "200": {
            "description": "Matching packages and advisories"
          },
          "503": {
            "description": "Search archive temporarily unavailable"
          }
        }
      }
    },
    "/api/v1/packages/check": {
      "get": {
        "tags": [
          "Packages"
        ],
        "summary": "Look up advisories for one ecosystem and package name",
        "description": "Send an ecosystem and name, with an optional exact version. Version-specific malware is returned separately in scoped_advisories on name-only lookups. Up to 200 total rows.",
        "parameters": [
          {
            "name": "ecosystem",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "npm"
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "lodash"
            }
          },
          {
            "name": "version",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 128,
              "example": "4.17.21"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Indexed advisory matches and flags. An empty result means the query returned no rows.",
            "headers": {
              "X-OMG-Match-Scope": {
                "$ref": "#/components/headers/MatchScope"
              },
              "X-OMG-Result-Limit": {
                "$ref": "#/components/headers/ResultLimit"
              },
              "X-OMG-Result-Limit-Reached": {
                "$ref": "#/components/headers/ResultLimitReached"
              }
            }
          },
          "400": {
            "description": "Missing or invalid query parameters, invalid version, or unsupported ecosystem"
          }
        }
      }
    },
    "/api/v1/packages/audit": {
      "post": {
        "tags": [
          "Packages"
        ],
        "summary": "Look up advisories for a batch of package names",
        "description": "Send 1 to 500 ecosystem and name coordinates, each with an optional exact version. One unsupported coordinate rejects the batch. The response includes at most 1,000 finding rows across the batch.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PackageAuditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Aggregated advisory matches and counts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PackageAuditResponse"
                }
              }
            },
            "headers": {
              "X-OMG-Match-Scope": {
                "$ref": "#/components/headers/MatchScope"
              },
              "X-OMG-Result-Limit": {
                "$ref": "#/components/headers/ResultLimit"
              },
              "X-OMG-Result-Limit-Reached": {
                "$ref": "#/components/headers/ResultLimitReached"
              }
            }
          },
          "400": {
            "description": "Invalid JSON, out-of-range batch size, invalid version, or unsupported ecosystem"
          }
        }
      }
    },
    "/api/v1/commercial/feed": {
      "get": {
        "tags": [
          "Commercial"
        ],
        "summary": "List recently modified CVE metadata for an enabled workspace",
        "description": "Defaults to the 100 newest records. Start forward pagination with order=asc. Follow next_cursor until null. Each page retains the initial as_of upper bound and uses modified_at then CVE ID for ordering.",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "ISO-8601 UTC lower bound (defaults to last 60 minutes)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "Set to asc to start forward pagination.",
            "schema": {
              "type": "string",
              "enum": [
                "asc"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Opaque next_cursor from the preceding forward page. URL-encode it and omit since.",
            "schema": {
              "type": "string",
              "maxLength": 1024
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size for forward reads.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CVE metadata. Forward pages additionally include as_of and next_cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "records",
                    "since"
                  ],
                  "properties": {
                    "since": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "as_of": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "records": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid bounds, limit, cursor or parameter combination"
          },
          "401": {
            "description": "Missing or revoked commercial API key"
          }
        }
      }
    },
    "/api/v1/commercial/watchlist": {
      "get": {
        "tags": [
          "Commercial"
        ],
        "summary": "List watched package coordinates for the authenticated customer",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Configured watchlist coordinates"
          }
        }
      },
      "post": {
        "tags": [
          "Commercial"
        ],
        "summary": "Subscribe a package coordinate (up to 200 targets per customer)",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WatchlistTarget"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Package added to watchlist"
          },
          "409": {
            "description": "Watchlist capacity limit (200) reached"
          }
        }
      },
      "delete": {
        "tags": [
          "Commercial"
        ],
        "summary": "Remove a watched package coordinate",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WatchlistTarget"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Package removed from watchlist"
          }
        }
      }
    },
    "/api/v1/commercial/webhooks": {
      "get": {
        "tags": [
          "Commercial"
        ],
        "summary": "List registered HTTPS webhook subscriptions and recent delivery logs",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Subscriptions and delivery history"
          }
        }
      },
      "post": {
        "tags": [
          "Commercial"
        ],
        "summary": "Create an HTTPS webhook subscription and return its one-time whsec_ secret",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook subscription created (includes one-time signing_secret)"
          },
          "400": {
            "description": "Non-HTTPS or invalid target_url / events"
          },
          "409": {
            "description": "Maximum webhook count reached"
          }
        }
      },
      "delete": {
        "tags": [
          "Commercial"
        ],
        "summary": "Disable an owned receiver and stop new delivery attempts",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "subscription_id"
                ],
                "properties": {
                  "subscription_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receiver disabled, including repeat removals"
          },
          "404": {
            "description": "Subscription not found for this account"
          }
        }
      }
    },
    "/api/v1/commercial/webhooks/replay": {
      "post": {
        "tags": [
          "Commercial"
        ],
        "summary": "Re-queue a webhook delivery",
        "description": "Preview. Inspect delivery history after re-queuing to determine its outcome.",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookReplayRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Delivery queued back to pending state"
          },
          "404": {
            "description": "Delivery ID not found for this account"
          }
        }
      }
    }
  }
}