openapi: 3.1.0
info:
  title: Popcast Conscience
  version: 0.1.0
  description: |
    Popcast Conscience will combine the five Popcast signal layers — Conversation, Reporting, Change, Attention and Ambient — into one call for a US Census block group. Ask for every layer, or name only the layers you need with `?layers=`. If one layer cannot be produced the rest are still returned, and the failure is listed in `payload.layer_errors`.

    **Coming soon.** This capability is on the Motionworks roadmap and is not yet available to call. The request and response shapes are published so you can plan an integration; they may change before launch.
  contact:
    name: Motionworks AI
    url: https://mworks.com
    email: api@mworks.com
servers:
  - url: https://api2.mworks.com
tags:
  - name: conscience
    description: All Popcast signal layers for a block group in one call, or just the layers you choose. Coming soon.
    x-displayName: Conscience
paths: {}
components:
  parameters:
    FipsParam:
      name: fips
      in: path
      required: true
      schema:
        type: string
        pattern: ^\d{12}$
      description: 12-digit US Census block group FIPS code.
  schemas:
    ConscienceLayer:
      type: string
      enum:
        - conversation
        - reporting
        - change
        - attention
        - ambient
      description: 'A Popcast signal layer: `conversation`, `reporting`, `change`, `attention` or `ambient`.'
    ConscienceLayerError:
      type: object
      properties:
        layer:
          $ref: '#/components/schemas/ConscienceLayer'
        error:
          type: string
          description: What went wrong, in plain language.
        status:
          type: integer
          description: HTTP status the layer returned.
      description: Why one layer could not be produced.
    ConsciencePayload:
      type: object
      description: One entry per layer, each shaped like that layer's own `payload`, plus any layers that failed.
      properties:
        conversation:
          type: object
          additionalProperties: true
          description: The Conversation layer, when requested and available.
        reporting:
          type: object
          additionalProperties: true
          description: The Reporting layer, when requested and available.
        change:
          type: object
          additionalProperties: true
          description: The Change layer, when requested and available.
        attention:
          type: object
          additionalProperties: true
          description: The Attention layer, when requested and available.
        ambient:
          type: object
          additionalProperties: true
          description: The Ambient layer, when requested and available.
        layer_errors:
          type: array
          items:
            $ref: '#/components/schemas/ConscienceLayerError'
          description: Layers that were requested but could not be produced.
    ConscienceSignal:
      type: object
      required:
        - fips
        - signal_layer
        - period_end
        - refreshed_at
        - layers_included
        - payload
      properties:
        fips:
          type: string
          description: 12-digit US Census block group FIPS code.
        signal_layer:
          type: string
          enum:
            - conscience
          description: Which signal layer this record belongs to.
        period_end:
          type: string
          description: Last day of the period this record covers (`YYYY-MM-DD`).
        refreshed_at:
          type: string
          format: date-time
          description: When the signal was last refreshed (ISO 8601).
        data_quality:
          type: string
          enum:
            - high
            - medium
            - low
          description: 'Confidence in the signal: `high`, `medium` or `low`.'
        layers_included:
          type: array
          items:
            $ref: '#/components/schemas/ConscienceLayer'
          description: The layers actually present in `payload`.
        payload:
          $ref: '#/components/schemas/ConsciencePayload'
      description: The combined signal for one block group.
    Meta:
      type: object
      properties:
        request_id:
          type: string
          description: Unique id for this request. Quote it when contacting support.
        credits_used:
          type: integer
          description: Credits charged for this call.
        product:
          type: string
          description: The Motionworks product that served the call.
        version:
          type: string
          description: API version that served the call.
        requested_layers:
          type: array
          items:
            $ref: '#/components/schemas/ConscienceLayer'
          description: The layers you asked for.
      description: Request metadata.
    ConscienceSignalResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/ConscienceSignal'
        meta:
          $ref: '#/components/schemas/Meta'
      description: One combined signal with request metadata.
    ConscienceBatchRequest:
      type: object
      required:
        - fips_codes
      properties:
        fips_codes:
          type: array
          maxItems: 50
          items:
            type: string
            pattern: ^\d{12}$
          description: Block group FIPS codes to look up (12 digits each).
        layers:
          type: array
          items:
            $ref: '#/components/schemas/ConscienceLayer'
          description: Layers to include. Omit for all five.
      description: Block groups to look up and, optionally, the layers to include.
    ConscienceBatchResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/ConscienceSignal'
          description: The list of results.
        meta:
          $ref: '#/components/schemas/Meta'
      description: One combined signal per requested block group, with request metadata.
    ApiError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable machine-readable error code.
            message:
              type: string
              description: Human-readable explanation of the error.
            status:
              type: integer
              description: HTTP status code, repeated in the body.
            request_id:
              type: string
              description: Unique id for this request. Quote it when contacting support.
          description: 'The error: a stable `code`, a human-readable `message`, and the HTTP `status`.'
      description: The standard error envelope.
  responses:
    NotFound:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    ValidationError:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
x-tagGroups:
  - name: Popcast Conscience
    tags:
      - conscience
x-customer-voice: true
