{
  "openapi": "3.1.0",
  "info": {
    "title": "BeforePress API",
    "version": "1.0.0",
    "description": "Live funding and exec-change signals from public records, delivered before press coverage. Every signal carries a branded receipt_url for verification. Auth: Bearer API key (sk_live_...).",
    "contact": {
      "email": "support@beforepress.com"
    }
  },
  "servers": [
    {
      "url": "https://beforepress.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/signals": {
      "get": {
        "summary": "List signals, newest first",
        "description": "Keyset pagination via next_cursor. Poll with published_after for incremental sync.",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "funding",
                "exec_change"
              ]
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "company_round",
                "fund_close",
                "crowdfunding"
              ]
            },
            "description": "funding only"
          },
          {
            "name": "occurred_after",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "published_after",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Everything published since your last poll"
          },
          {
            "name": "has_domain",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            },
            "description": "Only companies with a resolved website"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Company name contains (case-insensitive)"
          },
          {
            "name": "min_amount",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Only funding signals with amount_raised >= this many USD"
          },
          {
            "name": "occurred_before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Event-date ceiling"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "csv"
              ]
            },
            "description": "CSV output; next cursor in x-next-cursor header"
          }
        ],
        "responses": {
          "200": {
            "description": "Signals page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignalList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/signals/{id}": {
      "get": {
        "summary": "One signal by id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Signal"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "summary": "Your plan and usage",
        "responses": {
          "200": {
            "description": "Usage summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "plan": {
                          "type": "string"
                        },
                        "billing_period": {
                          "type": "string"
                        },
                        "unique_signals_delivered": {
                          "type": "integer"
                        },
                        "requests_last_30_days": {
                          "type": "integer"
                        }
                      }
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks": {
      "post": {
        "summary": "Register a webhook endpoint",
        "description": "HTTPS public hosts only. Response contains the signing secret EXACTLY ONCE. Deliveries are signed: BeforePress-Signature: t=<ts>,v1=HMACSHA256(secret, ts + '.' + body).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "signal_types": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "funding",
                        "exec_change",
                        "hiring"
                      ]
                    },
                    "default": [
                      "funding",
                      "exec_change"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created; includes one-time secret"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "summary": "List your webhook endpoints",
        "responses": {
          "200": {
            "description": "Endpoints (secrets never included)"
          }
        }
      }
    },
    "/v1/webhooks/{id}": {
      "delete": {
        "summary": "Disable a webhook endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Disabled"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/webhooks/{id}/test": {
      "post": {
        "summary": "Fire a synthetic signal.test event at your endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery attempt result (delivered, status_code)"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk_live_..."
      }
    },
    "responses": {
      "Error": {
        "description": "Error envelope",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "request_id": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Signal": {
        "type": "object",
        "properties": {
          "signal_id": {
            "type": "string",
            "format": "uuid"
          },
          "signal_type": {
            "type": "string",
            "enum": [
              "funding",
              "exec_change",
              "hiring"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "superseded",
              "retracted"
            ]
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "Event date. Can be in the future for announced-in-advance exec changes."
          },
          "discovered_at": {
            "type": "string",
            "format": "date-time",
            "description": "When BeforePress caught it"
          },
          "published_at": {
            "type": "string",
            "format": "date-time"
          },
          "company": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "domain": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "country": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "payload": {
            "type": "object",
            "description": "Typed per signal_type. funding: {category, amount_raised: {amount_usd}, total_offering: {amount_usd}, amount_undisclosed, investors, related_persons}. exec_change: {change: appointed|departed, name, role, effective_date}."
          },
          "receipt_url": {
            "type": "string",
            "format": "uri",
            "description": "Public BeforePress verification page; safe to paste in outreach"
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ]
          },
          "version": {
            "type": "integer"
          }
        }
      },
      "SignalList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Signal"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "request_id": {
            "type": "string"
          }
        }
      }
    }
  }
}