openapi: 3.1.0
info:
  title: SENTn Opportunity API
  version: 1.0.0
  description: >
    Public, read-only access to SENTn Opportunity Intelligence snapshots.
    Responses expose free snapshot-level opportunity fields from the existing
    production opportunity library. Full opportunity reports, raw complaints,
    protected evidence, private research, internal metadata, administrative data,
    and paid intelligence are separate from this API and may require a SENTn
    account, entitlement, or payment through the canonical SENTn destination.
servers:
  - url: https://us-central1-sentn-apps.cloudfunctions.net/opportunityApi
    description: Production Firebase Cloud Function
paths:
  /v1/opportunities/search:
    get:
      operationId: searchOpportunities
      summary: List public opportunity snapshots
      description: >
        Returns public snapshot-level opportunities from SENTn's production
        opportunity library. Results can be filtered by exact category and
        paginated with the cursor returned in the response metadata. Full-text
        search is not implemented by the existing API.
      parameters:
        - name: category
          in: query
          required: false
          description: Exact category value to match against the opportunity category field.
          schema:
            type: string
          examples:
            mobileApps:
              summary: Mobile app opportunity snapshots
              value: mobiviser
            sentnRadar:
              summary: SENTn Radar opportunity snapshots
              value: sentnradar
        - name: limit
          in: query
          required: false
          description: >
            Maximum number of snapshots to return. The current implementation
            defaults omitted, zero, or unparsable values to 10; negative values
            return INVALID_LIMIT.
          schema:
            type: integer
            minimum: 1
            default: 10
          example: 10
        - name: cursor
          in: query
          required: false
          description: >
            Document ID cursor from meta.nextCursor. Pass the last received
            cursor to request the next page. Continue until a response returns
            an empty data array or a null nextCursor.
          schema:
            type: string
          example: catalyst
      responses:
        "200":
          description: A page of public opportunity snapshots.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OpportunitySearchResponse"
              examples:
                firstPage:
                  summary: First page with two public snapshots
                  value:
                    data:
                      - id: surveymonkey
                        tool_name: SurveyMonkey
                        category: null
                        problem: SurveyMonkey's pricing is excessively high for users who only need a simple, straightforward survey tool, leading to significant frustration.
                        problem_summary: Build a simple, affordable, and transparently priced survey tool for small teams and individuals at $29/month.
                        target_customer: Small businesses, individual educators, non-profit organizations, and independent researchers who need a cost-effective and intuitive online survey tool.
                        score: 66
                        evidence_summary: null
                        public_url: https://sentn.app/validate/opportunity/surveymonkey
                      - id: catalyst
                        tool_name: Catalyst
                        category: null
                        problem: Catalyst is an effective solution, but its high price point creates significant frustration and excludes a large segment of potential users.
                        problem_summary: Build a simple, affordable Catalyst alternative for price-sensitive SMBs at $49/month.
                        target_customer: Small to medium businesses, startups, and individual professionals who require Catalyst's core capabilities but are highly sensitive to its current pricing.
                        score: 65
                        evidence_summary: null
                        public_url: https://sentn.app/validate/opportunity/catalyst
                    meta:
                      count: 2
                      nextCursor: catalyst
                      source: SENTn
                emptyPage:
                  summary: End of pagination
                  value:
                    data: []
                    meta:
                      count: 0
                      nextCursor: null
                      source: SENTn
        "400":
          description: Invalid request, invalid cursor, invalid negative limit, or unsupported full-text query.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              examples:
                invalidLimit:
                  value:
                    error:
                      code: INVALID_LIMIT
                      message: Limit must be a positive integer
                invalidCursor:
                  value:
                    error:
                      code: INVALID_CURSOR
                      message: Cursor does not correspond to a valid document
                searchNotImplemented:
                  value:
                    error:
                      code: SEARCH_NOT_IMPLEMENTED
                      message: Full-text search is not available in this phase. Use category filtering instead.
        "429":
          description: Rate limit exceeded.
          content:
            text/html:
              schema:
                type: string
        "500":
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: INTERNAL_ERROR
                  message: An internal error occurred
  /v1/opportunities/{id}:
    get:
      operationId: getOpportunity
      summary: Get one public opportunity snapshot
      description: >
        Returns one public snapshot-level opportunity by ID. The public_url
        field is the canonical SENTn destination for that opportunity and routes
        users into SENTn's existing account, unlock, and payment flow when a
        full report is requested.
      parameters:
        - name: id
          in: path
          required: true
          description: Opportunity document ID in the production opportunity library.
          schema:
            type: string
          example: surveymonkey
      responses:
        "200":
          description: A public opportunity snapshot.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OpportunityResponse"
              example:
                data:
                  id: surveymonkey
                  tool_name: SurveyMonkey
                  category: null
                  problem: SurveyMonkey's pricing is excessively high for users who only need a simple, straightforward survey tool, leading to significant frustration.
                  problem_summary: Build a simple, affordable, and transparently priced survey tool for small teams and individuals at $29/month.
                  target_customer: Small businesses, individual educators, non-profit organizations, and independent researchers who need a cost-effective and intuitive online survey tool.
                  score: 66
                  evidence_summary: null
                  public_url: https://sentn.app/validate/opportunity/surveymonkey
                meta:
                  source: SENTn
        "404":
          description: Opportunity not found.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: NOT_FOUND
                  message: Opportunity not found
        "429":
          description: Rate limit exceeded.
          content:
            text/html:
              schema:
                type: string
        "500":
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: INTERNAL_ERROR
                  message: An internal error occurred
components:
  schemas:
    OpportunitySnapshot:
      type: object
      additionalProperties: false
      description: Free public snapshot-level opportunity intelligence.
      required:
        - id
        - tool_name
        - category
        - problem
        - problem_summary
        - target_customer
        - score
        - evidence_summary
        - public_url
      properties:
        id:
          type: string
          description: Opportunity document ID.
          examples:
            - surveymonkey
        tool_name:
          type:
            - string
            - "null"
          description: Product, company, or incumbent name associated with the opportunity.
          examples:
            - SurveyMonkey
        category:
          type:
            - string
            - "null"
          description: Existing opportunity category value, when present.
          examples:
            - sentnradar
            - mobiviser
        problem:
          type:
            - string
            - "null"
          description: Public one-sentence problem statement.
        problem_summary:
          type:
            - string
            - "null"
          description: Public one-line opportunity summary or pitch.
        target_customer:
          type:
            - string
            - "null"
          description: Public target customer description.
        score:
          type:
            - number
            - "null"
          description: Public opportunity score from the existing production library.
        evidence_summary:
          oneOf:
            - $ref: "#/components/schemas/EvidenceSummary"
            - type: "null"
          description: Public evidence teaser, present only when the existing snapshot has a complaint quote.
        public_url:
          type: string
          format: uri
          description: Canonical SENTn destination for the opportunity and full-report conversion flow.
          examples:
            - https://sentn.app/validate/opportunity/surveymonkey
    EvidenceSummary:
      type: object
      additionalProperties: false
      required:
        - quote
        - source
        - date
      properties:
        quote:
          type:
            - string
            - "null"
          description: Public complaint quote teaser.
        source:
          type:
            - string
            - "null"
          description: Public source platform label for the evidence teaser.
          examples:
            - G2
            - Capterra
        date:
          type:
            - string
            - "null"
          description: Public evidence date value as stored by the existing API.
    OpportunitySearchResponse:
      type: object
      additionalProperties: false
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/OpportunitySnapshot"
        meta:
          $ref: "#/components/schemas/PaginationMeta"
    OpportunityResponse:
      type: object
      additionalProperties: false
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/OpportunitySnapshot"
        meta:
          $ref: "#/components/schemas/SourceMeta"
    PaginationMeta:
      type: object
      additionalProperties: false
      required:
        - count
        - nextCursor
        - source
      properties:
        count:
          type: integer
          minimum: 0
          description: Number of snapshots returned in this response.
        nextCursor:
          type:
            - string
            - "null"
          description: Cursor ID to pass as the cursor query parameter for the next page.
        source:
          type: string
          const: SENTn
          description: Response data source label.
    SourceMeta:
      type: object
      additionalProperties: false
      required:
        - source
      properties:
        source:
          type: string
          const: SENTn
          description: Response data source label.
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - SEARCH_NOT_IMPLEMENTED
                - INVALID_LIMIT
                - INVALID_CURSOR
                - INVALID_ID
                - NOT_FOUND
                - INTERNAL_ERROR
              description: Machine-readable error code returned by the existing API.
            message:
              type: string
              description: Human-readable error message returned by the existing API.
