openapi: 3.1.0
x-customer-voice: true
info:
  title: Scenarios
  version: 0.4.0
  description: |
    The campaign and event scenario asset libraries: create, browse, edit,
    and archive the scenarios you intend to analyze. Scenarios is
    Motionworks' asset-management surface for scenario-based products —
    Campaign was the first, Events is the second. Paid measurement
    (purchase, poll, report) is a separate surface per product — see the
    Viewcast Select reference for Campaign and the Placecast Select
    reference for Events.

    Both asset families move through the same five lifecycle states:
    `draft` (only the asset exists, fully editable), `queued` (a
    measurement has been purchased and results are pending — still
    editable), `in_flight` (the asset's active period is still running and
    results are re-pulled periodically — not final, no longer editable),
    `completed` (every measure is final and the active period has ended —
    retained permanently and cannot be edited or deleted), and `failed` (a
    problem occurred with the measurement — the purchase is refunded,
    less a 1-credit charge for the API call itself, and the asset stays
    editable, so you can fix the issue and retry in place).

    Authenticate with an org-scoped API key (`X-API-Key: mw_…`). Every
    call on the campaign surface costs 1 credit
    (`scenario_campaign_crud`); every call on the event surface costs 1
    credit (`scenario_event_crud`).
  contact:
    name: Motionworks AI
    url: https://mworks.com
    email: api@mworks.com
servers:
  - url: https://api2.mworks.com/v2
    description: Production
security:
  - apiKey: []
components:
  securitySchemes:
    apiKey:
      type: apiKey
      name: X-API-Key
      in: header
  schemas:
    CampaignAssetState:
      type: string
      enum:
        - draft
        - queued
        - in_flight
        - completed
        - failed
      description: |
        `draft` — only the asset exists, fully editable.
        `queued` — a measurement has been purchased, results pending; still editable.
        `in_flight` — the campaign's flight is still active; results are re-pulled
        periodically and are not yet final. No longer editable.
        `completed` — every measure is final and the flight has ended; the asset
        and its report are retained permanently and cannot be edited or deleted.
        `failed` — a problem occurred with the measurement; the purchase is
        refunded, less a 1-credit charge for the API call itself, and the
        asset stays editable and deletable, so you can fix the issue and
        retry in place.
    CampaignRef:
      type: object
      properties:
        name:
          type: string
        reference:
          type: string
      description: Your own name/reference for the campaign, echoed back unchanged.
    CampaignFlight:
      type: object
      required:
        - start_date
        - end_date
      properties:
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
      description: |
        The campaign's overall active period. A spot with no `windows`
        inherits this envelope in full.
    CampaignSpotWindow:
      type: object
      required:
        - start_date
        - end_date
      properties:
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
      description: One contiguous active period for one spot.
    CampaignSpot:
      type: object
      required:
        - display_id
        - spot_id
      properties:
        display_id:
          type: string
          format: uuid
          description: |
            The Motionworks-issued identifier for the physical display this
            spot runs on — a plain UUID. Only format is validated; there is
            no existence check against your own or the public display
            inventory. A UUID that doesn't correspond to a real, measurable
            display is caught once a purchased analysis runs, and the
            purchase is refunded, less a 1-credit charge for the API call
            itself.
        spot_id:
          type: integer
          description: |
            Your own identifying number for this spot, required alongside
            `display_id`.
        customer_spot_id:
          type: string
          description: Your own reference for this spot, echoed back unchanged.
        customer_operator_name:
          type: string
          description: Your own plant or operator reference for this spot, echoed back unchanged.
        windows:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/CampaignSpotWindow'
          description: |
            This spot's own active windows. Omit to inherit the campaign's
            `flight` envelope. Several entries model a rotating flight.
      description: One spot in the campaign — one advertisement on one display.
    CampaignCohort:
      type: object
      required:
        - geography_ids
        - motionworks_segment_ids
        - motionworks_base_segment_id
      properties:
        geography_ids:
          type: array
          minItems: 1
          items:
            type: string
          description: |
            Geography ids for the requested market geography. More than one
            element defines a market group.
        motionworks_segment_ids:
          type: array
          minItems: 1
          items:
            type: string
          description: |
            One or more target audience segment ids. Only the first id is
            measured — additional ids are recorded for reference only.
        motionworks_base_segment_id:
          type: string
          description: Id of the base segment every target segment is measured against.
        measures_release:
          type: integer
          description: |
            Version pin for reproducible results across runs. Reserved for
            future use — not currently applied to measurement.
      description: The market geography and audience to measure.
    CampaignSpeedProfile:
      type: string
      enum:
        - measured
        - weekly_congested
        - daily_congested
      default: measured
      description: |
        How vehicle speed is set when a car passes a display, which sets how
        long the display is in view. Results can change on any spot in the
        campaign, not only digital roadside spots, so compare analyses that
        were measured with the same profile.

        - `measured`: each hour uses the speed measured on that road segment
          in that hour.
        - `weekly_congested`: every hour uses the month's slowest busy hour
          on the segment. A busy hour has at least half the vehicles of the
          month's busiest hour.
        - `daily_congested`: the same, with the slowest busy hour picked
          separately for Monday to Thursday, Friday, Saturday and Sunday.
    CampaignCustomer:
      type: object
      required:
        - customer_id
        - customer_name
        - customer_scenario_id
        - customer_scenario_name
      properties:
        customer_id:
          type: integer
        customer_name:
          type: string
        customer_scenario_id:
          type: string
        customer_scenario_name:
          type: string
        customer_scenario_info:
          type: string
      description: Your own scenario identifiers, echoed back unchanged.
    CampaignAsset:
      type: object
      required:
        - asset_id
        - org_id
        - state
        - flight
        - spots
        - cohort
        - customer
        - speed_profile
        - created_at
        - updated_at
      properties:
        asset_id:
          type: string
          description: The one identifier you need for this campaign, minted at creation.
        org_id:
          type: string
        state:
          $ref: '#/components/schemas/CampaignAssetState'
        campaign:
          $ref: '#/components/schemas/CampaignRef'
        flight:
          $ref: '#/components/schemas/CampaignFlight'
        spots:
          type: array
          minItems: 1
          maxItems: 2000
          items:
            $ref: '#/components/schemas/CampaignSpot'
        cohort:
          $ref: '#/components/schemas/CampaignCohort'
        customer:
          $ref: '#/components/schemas/CampaignCustomer'
        speed_profile:
          $ref: '#/components/schemas/CampaignSpeedProfile'
        last_measured_at:
          type: string
          format: date-time
          nullable: true
          description: Date of the last measurement pull. Populated only while/after `in_flight`.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      description: A campaign asset in your organization's library.
    CampaignAssetSummaryRow:
      type: object
      required:
        - asset_id
        - state
        - flight
        - spot_count
        - cohort
        - customer
        - speed_profile
        - created_at
        - updated_at
      properties:
        asset_id:
          type: string
        state:
          $ref: '#/components/schemas/CampaignAssetState'
        campaign:
          $ref: '#/components/schemas/CampaignRef'
        flight:
          $ref: '#/components/schemas/CampaignFlight'
        spot_count:
          type: integer
          minimum: 0
          description: |
            Number of spots in the campaign, computed server-side. The
            `spots` array itself is never on the wire in summary mode.
        cohort:
          $ref: '#/components/schemas/CampaignCohort'
        customer:
          $ref: '#/components/schemas/CampaignCustomer'
        speed_profile:
          $ref: '#/components/schemas/CampaignSpeedProfile'
        last_measured_at:
          type: string
          format: date-time
          nullable: true
          description: Date of the last measurement pull. Populated only while/after `in_flight`.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      description: |
        Light summary row returned by `fields=summary`: the full
        row minus `spots` and `org_id`, plus the server-computed `spot_count`.
    CampaignAssetCreateRequest:
      type: object
      required:
        - flight
        - spots
        - cohort
        - customer
      properties:
        campaign:
          $ref: '#/components/schemas/CampaignRef'
        flight:
          $ref: '#/components/schemas/CampaignFlight'
        spots:
          type: array
          minItems: 1
          maxItems: 2000
          items:
            $ref: '#/components/schemas/CampaignSpot'
        cohort:
          $ref: '#/components/schemas/CampaignCohort'
        customer:
          $ref: '#/components/schemas/CampaignCustomer'
        speed_profile:
          allOf:
            - $ref: '#/components/schemas/CampaignSpeedProfile'
          description: Omit it to use `measured`.
    CampaignAssetPatchRequest:
      type: object
      properties:
        campaign:
          $ref: '#/components/schemas/CampaignRef'
        flight:
          $ref: '#/components/schemas/CampaignFlight'
        spots:
          type: array
          minItems: 1
          maxItems: 2000
          items:
            $ref: '#/components/schemas/CampaignSpot'
        cohort:
          $ref: '#/components/schemas/CampaignCohort'
        customer:
          $ref: '#/components/schemas/CampaignCustomer'
        speed_profile:
          $ref: '#/components/schemas/CampaignSpeedProfile'
      description: |
        Any field may change while the asset is `draft`, `queued`, or
        `failed` — no field-level restriction. Rejected (400) once the
        asset is `in_flight` or `completed`.
    CampaignAssetSummary:
      type: object
      required:
        - by_state
        - total
      properties:
        by_state:
          type: object
          required:
            - draft
            - queued
            - in_flight
            - completed
            - failed
          properties:
            draft:
              type: integer
            queued:
              type: integer
            in_flight:
              type: integer
            completed:
              type: integer
            failed:
              type: integer
        total:
          type: integer
    EventAssetState:
      type: string
      enum:
        - draft
        - queued
        - in_flight
        - completed
        - failed
      description: |
        `draft` — only the asset exists, fully editable.
        `queued` — a measurement has been purchased, results pending; still editable.
        `in_flight` — the event's measurement periods are still active; results
        are re-pulled periodically and are not yet final. No longer editable.
        `completed` — every measure is final and the last period has ended;
        the asset and its report are retained permanently and cannot be
        edited or deleted.
        `failed` — a problem occurred with the measurement; the purchase is
        refunded, less a 1-credit charge for the API call itself, and the
        asset stays editable and deletable, so you can fix the issue and
        retry in place.
    EventPeriod:
      type: object
      required:
        - period_name
        - start_time
        - end_time
      properties:
        period_name:
          type: string
        start_time:
          type: string
          format: date-time
        end_time:
          type: string
          format: date-time
      description: |
        One named time range to measure. Every period applies to every
        place in the request — there is no per-place override.
    EventCohort:
      type: object
      required:
        - geography_ids
        - motionworks_segment_id
      properties:
        geography_ids:
          type: array
          minItems: 1
          items:
            type: string
          description: |
            Geography ids for the requested market geography. More than one
            element defines a market group.
        motionworks_segment_id:
          type: string
          description: The one target audience segment id to measure.
      description: The market geography and audience to measure.
    EventCustomer:
      type: object
      required:
        - customer_id
        - customer_scenario_id
      properties:
        customer_id:
          type: string
        customer_name:
          type: string
        customer_scenario_id:
          type: string
        customer_scenario_name:
          type: string
        customer_scenario_info:
          type: string
      description: Your own scenario identifiers, echoed back unchanged.
    EventAsset:
      type: object
      required:
        - asset_id
        - org_id
        - state
        - periods
        - place_ids
        - place_set_id
        - cohort
        - customer
        - timezone
        - created_at
        - updated_at
      properties:
        asset_id:
          type: string
          description: The one identifier you need for this event, minted at creation.
        org_id:
          type: string
        state:
          $ref: '#/components/schemas/EventAssetState'
        name:
          type: string
          description: Your own name for the event, echoed back unchanged.
        description:
          type: string
          description: Your own description for the event, echoed back unchanged.
        periods:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EventPeriod'
        place_ids:
          type:
            - array
            - 'null'
          minItems: 1
          items:
            type: string
          description: |
            The Motionworks-issued Placecast place identifiers this event
            runs at (see `GET /v2/placecast/profiles/{place_id}`). Null when
            the event names a place set instead.
        place_set_id:
          type:
            - string
            - 'null'
          pattern: ^pls[0-9A-HJKMNP-TV-Z]{26}$
          description: |
            The place set this event runs at, instead of `place_ids`. Null
            for an event that lists its places inline.
        cohort:
          $ref: '#/components/schemas/EventCohort'
        customer:
          $ref: '#/components/schemas/EventCustomer'
        timezone:
          type: string
          description: IANA timezone of the periods and places.
        last_measured_at:
          type: string
          format: date-time
          nullable: true
          description: Date of the last measurement pull. Populated only while/after `in_flight`.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      description: An event asset in your organization's library.
    EventAssetSummaryRow:
      type: object
      required:
        - asset_id
        - state
        - periods
        - place_count
        - cohort
        - customer
        - created_at
        - updated_at
      properties:
        asset_id:
          type: string
        state:
          $ref: '#/components/schemas/EventAssetState'
        name:
          type: string
          description: Your own name for the event, echoed back unchanged.
        periods:
          type: array
          items:
            $ref: '#/components/schemas/EventPeriod'
        place_count:
          type: integer
          minimum: 0
          description: |
            Number of places this event runs at, computed server-side. An
            event with inline `place_ids` counts them; an event that names
            a place set reports the set's loaded member count, resolved
            server-side in one batched read per page. `place_count` is 0
            while the set is not in state `ready` (still loading, failed,
            expired, or deleted). The `place_ids` array and the
            `place_set_id` handle itself are never on the wire in summary
            mode.
        cohort:
          $ref: '#/components/schemas/EventCohort'
        customer:
          $ref: '#/components/schemas/EventCustomer'
        last_measured_at:
          type: string
          format: date-time
          nullable: true
          description: Date of the last measurement pull. Populated only while/after `in_flight`.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      description: |
        Light summary row returned by `fields=summary`: the full
        row minus `place_ids`/`place_set_id` and `org_id`/`description`/
        `timezone`, plus the server-computed `place_count`.
    EventAssetCreateRequest:
      type: object
      required:
        - periods
        - cohort
        - customer
        - timezone
      description: |
        Name the places with exactly one of `place_ids` (inline) or
        `place_set_id` (a place set your organization owns, for lists too
        large to send inline). Sending both, or neither, is rejected (400).
      properties:
        name:
          type: string
        description:
          type: string
        periods:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EventPeriod'
        place_ids:
          type: array
          minItems: 1
          items:
            type: string
        place_set_id:
          type: string
          pattern: ^pls[0-9A-HJKMNP-TV-Z]{26}$
          description: A place set your organization owns. Any state is accepted here; it must be `ready` when you purchase.
        cohort:
          $ref: '#/components/schemas/EventCohort'
        customer:
          $ref: '#/components/schemas/EventCustomer'
        timezone:
          type: string
    EventAssetPatchRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type: string
        periods:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EventPeriod'
        place_ids:
          type: array
          minItems: 1
          items:
            type: string
        place_set_id:
          type: string
          pattern: ^pls[0-9A-HJKMNP-TV-Z]{26}$
        cohort:
          $ref: '#/components/schemas/EventCohort'
        customer:
          $ref: '#/components/schemas/EventCustomer'
        timezone:
          type: string
      description: |
        Any field may change while the asset is `draft`, `queued`, or
        `failed` — no field-level restriction. Sending `place_ids` or
        `place_set_id` switches the event to that one and clears the
        other; sending both is rejected (400). A `queued` event has
        already been purchased, so pointing it at a different place set
        requires that set to be `ready` (400 otherwise) and counts as a
        use of the set, extending its expiry. Rejected (400) once the
        asset is `in_flight` or `completed`.
    EventAssetSummary:
      type: object
      required:
        - by_state
        - total
      properties:
        by_state:
          type: object
          required:
            - draft
            - queued
            - in_flight
            - completed
            - failed
          properties:
            draft:
              type: integer
            queued:
              type: integer
            in_flight:
              type: integer
            completed:
              type: integer
            failed:
              type: integer
        total:
          type: integer
    PlaceSetState:
      type: string
      enum:
        - awaiting_upload
        - processing
        - ready
        - failed
        - expired
      description: |
        `awaiting_upload` (created; upload the file), `processing` (the
        file has arrived and the list is being loaded), `ready` (usable),
        `failed` (the file could not be loaded; see `load_error`),
        `expired` (past `expires_at`; its place ids and files have been
        removed. Create a new set).
    PlaceSet:
      type: object
      required:
        - set_id
        - org_id
        - state
        - name
        - description
        - source
        - source_file_name
        - source_bytes
        - rows_read
        - duplicates_removed
        - members_loaded
        - preview
        - load_error
        - last_used_at
        - expires_at
        - created_at
        - updated_at
      properties:
        set_id:
          type: string
          description: Identifier of the set, prefixed `pls`.
        org_id:
          type: string
        state:
          $ref: '#/components/schemas/PlaceSetState'
        name:
          type: string
        description:
          type:
            - string
            - 'null'
        source:
          type: string
          enum:
            - upload
            - inline
        source_file_name:
          type:
            - string
            - 'null'
          description: Name of the uploaded file, for display.
        source_bytes:
          type:
            - integer
            - 'null'
          description: Size of the uploaded file, once the upload has arrived.
        rows_read:
          type:
            - integer
            - 'null'
          description: Data rows in the last loaded file or list, not counting the header. Adding or removing place ids does not change it.
        duplicates_removed:
          type:
            - integer
            - 'null'
          description: Rows of the last loaded file or list dropped because their place id was blank or repeated. Adding or removing place ids does not change it.
        members_loaded:
          type:
            - integer
            - 'null'
          description: Place ids in the set. Updated when you add or remove place ids.
        preview:
          type:
            - array
            - 'null'
          items:
            type: string
          description: The first place ids in the set, once it is `ready`.
        load_error:
          type:
            - string
            - 'null'
          description: Why the set is `failed`.
        last_used_at:
          type: string
          format: date-time
        expires_at:
          type: string
          format: date-time
          description: |
            180 days after the set's last use. Creating, uploading to,
            replacing, adding or removing place ids, or purchasing a
            measurement that references the set all count as use and
            move this date out. Reading the set does not.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    PlaceSetWithUpload:
      allOf:
        - $ref: '#/components/schemas/PlaceSet'
        - type: object
          properties:
            upload:
              $ref: '#/components/schemas/PlaceSetUpload'
    PlaceSetUpload:
      type: object
      required:
        - method
        - url
        - required_headers
        - expires_at
      properties:
        method:
          type: string
          enum:
            - PUT
        url:
          type: string
          format: uri
          description: Upload the CSV file to this URL. It works for this set only.
        required_headers:
          type: object
          additionalProperties:
            type: string
          description: 'Send exactly these headers with the upload, for example `Content-Type: text/csv`. They include the accepted file size range, so an empty file or one over 1 GiB is rejected when you upload it.'
        expires_at:
          type: string
          format: date-time
          description: Start the upload before this time.
    PlaceSetItems:
      type: array
      minItems: 1
      maxItems: 10000
      items:
        type: string
        minLength: 1
      description: Place ids. They are not validated; surrounding spaces are trimmed and repeats are dropped.
    PlaceSetUploadSource:
      type: object
      additionalProperties: false
      required:
        - source
      properties:
        source:
          type: string
          enum:
            - upload
          description: Upload a CSV file. The response has an `upload` URL.
        file_name:
          type: string
          minLength: 1
          maxLength: 500
          description: Name of the file you will upload, kept for display.
    PlaceSetInlineSource:
      type: object
      additionalProperties: false
      required:
        - source
        - items
      properties:
        source:
          type: string
          enum:
            - inline
          description: Send the place ids in the request. The set loads straight away.
        items:
          $ref: '#/components/schemas/PlaceSetItems'
    PlaceSetCreateRequest:
      oneOf:
        - type: object
          additionalProperties: false
          required:
            - name
            - source
          properties:
            name:
              type: string
              minLength: 1
              maxLength: 200
            description:
              type: string
              maxLength: 2000
            source:
              type: string
              enum:
                - upload
            file_name:
              type: string
              minLength: 1
              maxLength: 500
              description: Name of the file you will upload, kept for display.
        - type: object
          additionalProperties: false
          required:
            - name
            - source
            - items
          properties:
            name:
              type: string
              minLength: 1
              maxLength: 200
            description:
              type: string
              maxLength: 2000
            source:
              type: string
              enum:
                - inline
            items:
              $ref: '#/components/schemas/PlaceSetItems'
      discriminator:
        propertyName: source
    PlaceSetReplaceRequest:
      oneOf:
        - $ref: '#/components/schemas/PlaceSetUploadSource'
        - $ref: '#/components/schemas/PlaceSetInlineSource'
      discriminator:
        propertyName: source
        mapping:
          upload: '#/components/schemas/PlaceSetUploadSource'
          inline: '#/components/schemas/PlaceSetInlineSource'
    PlaceSetItemsRequest:
      type: object
      additionalProperties: false
      required:
        - items
      properties:
        items:
          $ref: '#/components/schemas/PlaceSetItems'
    PlaceSetItemsChangeResponse:
      type: object
      properties:
        data:
          allOf:
            - $ref: '#/components/schemas/PlaceSet'
            - type: object
              required:
                - changed
              properties:
                changed:
                  type: integer
                  minimum: 0
                  description: Place ids actually added (not already in the set) or removed (were in the set).
        meta:
          $ref: '#/components/schemas/Meta'
    PlaceSetDownload:
      type: object
      required:
        - set_id
        - status
        - url
        - expires_at
      properties:
        set_id:
          type: string
        status:
          type: string
          enum:
            - ready
            - preparing
          description: '`preparing` while a set you have edited is being written to a file; call again shortly.'
        url:
          type:
            - string
            - 'null'
          format: uri
          description: Download the CSV file from this URL with `GET`. Present when `status` is `ready`.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: The URL works until this time.
    Pagination:
      type: object
      properties:
        cursor:
          type: string
          nullable: true
        has_more:
          type: boolean
        total:
          type: integer
    MetaPagination:
      type: object
      required:
        - has_more
        - count
      properties:
        next_cursor:
          type: string
          description: |
            Cursor for the next page. Present only when `has_more` is true;
            omitted, never null, on the final page.
        has_more:
          type: boolean
          description: Whether more rows match the current filter set.
        count:
          type: integer
          minimum: 0
          description: |
            Total number of rows matching the current filter set (not the
            number of rows on this page).
      description: |
        Cursor-style pagination block carried inside `meta` — the same
        envelope as `POST /v2/displays/search`.
    Provenance:
      type: object
      properties:
        source:
          type: string
        source_doc:
          type: string
          format: uri
        methodology_version:
          type: string
        data_vintage:
          type: string
          format: date
        data_freshness:
          type: string
          enum:
            - hourly
            - daily
            - weekly
            - monthly
            - annually
            - on-demand
            - static
        data_latency_days:
          type: integer
        data_maturity:
          type: string
          enum:
            - production
            - research-preview
            - synthetic-only
            - roadmap
    Meta:
      type: object
      properties:
        request_id:
          type: string
        credits_used:
          type: integer
        credits_remaining:
          type: integer
        product:
          type: string
        version:
          type: string
        provenance:
          $ref: '#/components/schemas/Provenance'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            status:
              type: integer
            request_id:
              type: string
            product:
              type: string
            docs_url:
              type: string
paths:
  /scenarios/campaigns:
    post:
      operationId: createCampaignAsset
      summary: Create a draft campaign asset
      description: |
        Creates a draft campaign asset from its spots, flight, cohort, and
        customer, and returns the asset in state `draft`. Synchronous, 1
        credit. No idempotency key — a retry creates a second asset.
      tags:
        - Assets
      x-credit-cost: 1
      x-motionworks-status: production
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignAssetCreateRequest'
      responses:
        '200':
          description: Draft asset created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CampaignAsset'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid payload — for example more than 2000 spots, an empty spot list, or an unrecognized geography id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: listCampaignAssets
      summary: List your campaign asset library
      description: |
        Lists the campaign assets your organization owns. Every filter is
        AND-ed. Paginated by an opaque signed cursor — pass back
        `meta.pagination.next_cursor` from the previous response. Cursors
        are bound to the filter set: replaying a cursor with different
        filters, an edited or tampered cursor, or a cursor minted before
        the current grammar returns a 400 asking you to restart pagination
        without it.

        `fields=summary` returns light summary rows (`spots` stripped,
        `spot_count` added); `include=spots` restores the full rows on a
        summary request.
      tags:
        - Assets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: state
          in: query
          description: Filter by lifecycle state — a comma-separated list, for example `state=draft,queued`. Unknown states are rejected (400).
          schema:
            type: string
        - name: cursor
          in: query
          description: Opaque pagination cursor from the previous response's `meta.pagination.next_cursor`. Cursors are versioned, bound to the request's filter set, and signed for tamper-evidence. A legacy integer-offset cursor, a cursor minted for a different filter set, or a tampered cursor returns a 400 asking you to restart pagination without it.
          schema:
            type: string
        - name: limit
          in: query
          description: Page size. Default 25, max 100.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
        - name: created_after
          in: query
          description: Inclusive lower bound on `created_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: created_before
          in: query
          description: Inclusive upper bound on `created_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: updated_after
          in: query
          description: Inclusive lower bound on `updated_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: updated_before
          in: query
          description: Inclusive upper bound on `updated_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: reference
          in: query
          description: Exact match on your own `campaign.reference`.
          schema:
            type: string
            minLength: 1
        - name: customer_scenario_id
          in: query
          description: Exact match on your own `customer.customer_scenario_id`.
          schema:
            type: string
            minLength: 1
        - name: name
          in: query
          description: Case-insensitive contains on `campaign.name`.
          schema:
            type: string
            minLength: 1
            maxLength: 200
        - name: order
          in: query
          description: |
            Row order. Ties break by `id` in the same direction. Defaults
            to `created_at.desc` (newest first).
          schema:
            type: string
            enum:
              - created_at.desc
              - created_at.asc
              - updated_at.desc
              - updated_at.asc
        - name: fields
          in: query
          description: |
            `summary` — return light summary rows (`spots` stripped,
            `spot_count` added).
          schema:
            type: string
            enum:
              - summary
        - name: include
          in: query
          description: |
            `spots` — on a `fields=summary` request, restore the full rows
            (the `spots` arrays) instead of summary rows.
          schema:
            type: string
            enum:
              - spots
        - name: asset_id
          in: query
          description: Batch read by id — repeat the parameter, at most 100 ids per call. More is rejected (400) naming `asset_id`.
          schema:
            type: array
            items:
              type: string
              minLength: 1
              maxLength: 128
            minItems: 1
            maxItems: 100
      responses:
        '200':
          description: Paginated asset list.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/CampaignAsset'
                        - $ref: '#/components/schemas/CampaignAssetSummaryRow'
                  meta:
                    allOf:
                      - $ref: '#/components/schemas/Meta'
                      - type: object
                        required:
                          - pagination
                        properties:
                          pagination:
                            $ref: '#/components/schemas/MetaPagination'
  /scenarios/campaigns/summary:
    get:
      operationId: getCampaignAssetsSummary
      summary: Count your campaign assets by state
      description: Returns counts of your organization's campaign assets by lifecycle state.
      tags:
        - Assets
      x-credit-cost: 1
      x-motionworks-status: production
      responses:
        '200':
          description: Library summary counts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CampaignAssetSummary'
                  meta:
                    $ref: '#/components/schemas/Meta'
  /scenarios/campaigns/{asset_id}:
    get:
      operationId: getCampaignAsset
      summary: Read one campaign asset
      description: Returns one campaign asset by its `asset_id`.
      tags:
        - Assets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The asset.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CampaignAsset'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '404':
          description: Unknown asset_id, or an asset that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    patch:
      operationId: patchCampaignAsset
      summary: Edit a draft, queued, or failed campaign asset
      description: |
        Edits any of `campaign`, `flight`, `spots`, `cohort`, or `customer`
        while the asset is `draft`, `queued`, or `failed` — no field-level
        restriction. Rejected (400) once the asset is `in_flight` or
        `completed`.
      tags:
        - Assets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignAssetPatchRequest'
      responses:
        '200':
          description: The updated asset.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CampaignAsset'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid payload, or the asset is `in_flight` or `completed` (no longer editable).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown asset_id, or an asset that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The asset's state changed to `in_flight` or `completed` between your read and this edit. Re-read the asset and retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: deleteCampaignAsset
      summary: Delete a draft, queued, or failed campaign asset
      description: |
        Deletes a `draft`, `queued`, or `failed` asset you no longer want.
        An `in_flight` asset cannot be deleted while measurement is
        running; a `completed` asset cannot be deleted — its report is
        retained permanently.
      tags:
        - Assets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Deleted.
        '400':
          description: The asset is `in_flight` or `completed` and cannot be deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown asset_id, or an asset that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /scenarios/events:
    post:
      operationId: createEventAsset
      summary: Create a draft event asset
      description: |
        Creates a draft event asset from its place ids, periods, cohort, and
        customer, and returns the asset in state `draft`. Synchronous, 1
        credit. No idempotency key — a retry creates a second asset.
      tags:
        - Events
      x-credit-cost: 1
      x-motionworks-status: production
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventAssetCreateRequest'
      responses:
        '200':
          description: Draft asset created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EventAsset'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid payload — for example an empty place id list or an unrecognized geography id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: listEventAssets
      summary: List your event asset library
      description: |
        Lists the event assets your organization owns. Every filter is
        AND-ed. Paginated by an opaque signed cursor — pass back
        `meta.pagination.next_cursor` from the previous response. Cursors
        are bound to the filter set: replaying a cursor with different
        filters, an edited or tampered cursor, or a cursor minted before
        the current grammar returns a 400 asking you to restart pagination
        without it.

        `fields=summary` returns light summary rows (`place_ids` stripped,
        `place_count` added); `include=places` restores the full rows on a
        summary request.
      tags:
        - Events
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: state
          in: query
          description: Filter by lifecycle state — a comma-separated list, for example `state=draft,queued`. Unknown states are rejected (400).
          schema:
            type: string
        - name: cursor
          in: query
          description: Opaque pagination cursor from the previous response's `meta.pagination.next_cursor`. Cursors are versioned, bound to the request's filter set, and signed for tamper-evidence. A legacy integer-offset cursor, a cursor minted for a different filter set, or a tampered cursor returns a 400 asking you to restart pagination without it.
          schema:
            type: string
        - name: limit
          in: query
          description: Page size. Default 25, max 100.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
        - name: created_after
          in: query
          description: Inclusive lower bound on `created_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: created_before
          in: query
          description: Inclusive upper bound on `created_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: updated_after
          in: query
          description: Inclusive lower bound on `updated_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: updated_before
          in: query
          description: Inclusive upper bound on `updated_at` (ISO-8601 date-time).
          schema:
            type: string
            format: date-time
        - name: customer_scenario_id
          in: query
          description: Exact match on your own `customer.customer_scenario_id`.
          schema:
            type: string
            minLength: 1
        - name: name
          in: query
          description: Case-insensitive contains on the event's own `name`.
          schema:
            type: string
            minLength: 1
            maxLength: 200
        - name: order
          in: query
          description: |
            Row order. Ties break by `id` in the same direction. Defaults
            to `created_at.desc` (newest first).
          schema:
            type: string
            enum:
              - created_at.desc
              - created_at.asc
              - updated_at.desc
              - updated_at.asc
        - name: fields
          in: query
          description: |
            `summary` — return light summary rows (`place_ids` stripped,
            `place_count` added).
          schema:
            type: string
            enum:
              - summary
        - name: include
          in: query
          description: |
            `places` — on a `fields=summary` request, restore the full rows
            instead of summary rows.
          schema:
            type: string
            enum:
              - places
        - name: asset_id
          in: query
          description: Batch read by id — repeat the parameter, at most 100 ids per call. More is rejected (400) naming `asset_id`.
          schema:
            type: array
            items:
              type: string
              minLength: 1
              maxLength: 128
            minItems: 1
            maxItems: 100
      responses:
        '200':
          description: Paginated asset list.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/EventAsset'
                        - $ref: '#/components/schemas/EventAssetSummaryRow'
                  meta:
                    allOf:
                      - $ref: '#/components/schemas/Meta'
                      - type: object
                        required:
                          - pagination
                        properties:
                          pagination:
                            $ref: '#/components/schemas/MetaPagination'
  /scenarios/events/summary:
    get:
      operationId: getEventAssetsSummary
      summary: Count your event assets by state
      description: Returns counts of your organization's event assets by lifecycle state.
      tags:
        - Events
      x-credit-cost: 1
      x-motionworks-status: production
      responses:
        '200':
          description: Library summary counts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EventAssetSummary'
                  meta:
                    $ref: '#/components/schemas/Meta'
  /scenarios/events/{asset_id}:
    get:
      operationId: getEventAsset
      summary: Read one event asset
      description: Returns one event asset by its `asset_id`.
      tags:
        - Events
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The asset.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EventAsset'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '404':
          description: Unknown asset_id, or an asset that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    patch:
      operationId: patchEventAsset
      summary: Edit a draft, queued, or failed event asset
      description: |
        Edits any of `name`, `description`, `periods`, `place_ids`,
        `place_set_id`, `cohort`, `customer`, or `timezone` while the asset is `draft` or
        `failed` — no field-level restriction. A `queued` asset stays
        editable for a window after purchase, so you can correct a mistake
        before measurement starts; once it has been submitted for
        measurement, it is locked (400) for the rest of the measurement
        and becomes editable again only if the run fails and is refunded.
        Also rejected (400) once the asset is `in_flight` or `completed`.
      tags:
        - Events
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventAssetPatchRequest'
      responses:
        '200':
          description: The updated asset.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EventAsset'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid payload, the asset has already been submitted for measurement, or it is `in_flight` or `completed` (no longer editable).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown asset_id, or an asset that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The asset's state changed to `in_flight` or `completed` between your read and this edit. Re-read the asset and retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: deleteEventAsset
      summary: Delete a draft, queued, or failed event asset
      description: |
        Deletes a `draft` or `failed` asset you no longer want, or a
        `queued` asset that has not yet been submitted for measurement.
        Once a `queued` asset has been submitted, it can no longer be
        deleted until the run fails and is refunded. An `in_flight` asset
        cannot be deleted while measurement is running; a `completed`
        asset cannot be deleted — its report is retained
        permanently.
      tags:
        - Events
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: asset_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Deleted.
        '400':
          description: The asset has already been submitted for measurement, or it is `in_flight` or `completed`, and cannot be deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown asset_id, or an asset that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /sets/places:
    post:
      operationId: createPlaceSet
      summary: Create a place set and get its upload URL
      description: |
        Creates a place set from a CSV file or from a list of place ids.

        With `source: "upload"` the set starts in `awaiting_upload` and the
        response has an `upload` URL. Upload the file directly to that URL
        with `PUT`, sending the returned `required_headers`. There is
        nothing else to call: once the upload finishes, the set moves to
        `processing` on its own and then to `ready` (a large file can take a
        few minutes). The file is a CSV with a header row and a `place_id`
        column; other columns are ignored. If you upload again after the set
        has moved to `processing`, the new file is not used and loading
        fails; use `PUT /sets/places/{set_id}` to replace the file instead.

        With `source: "inline"` you send up to 10,000 place ids in `items`,
        and the set starts in `processing`.

        Place ids are not validated. Blank and repeated ids are dropped.
        Check progress with `GET /sets/places/{set_id}`. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlaceSetCreateRequest'
      responses:
        '200':
          description: Set created. `upload` is present when `source` is `upload`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/PlaceSetWithUpload'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: listPlaceSets
      summary: List your place sets
      description: Lists the place sets your organization owns, newest first. Optionally filter by name (case-insensitive substring) or state. Paginated by cursor. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: name
          in: query
          schema:
            type: string
        - name: state
          in: query
          schema:
            $ref: '#/components/schemas/PlaceSetState'
        - name: cursor
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      responses:
        '200':
          description: Paginated list of sets.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/PlaceSet'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid query parameters, or an invalid cursor.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /sets/places/{set_id}:
    get:
      operationId: getPlaceSet
      summary: Read one place set
      description: Returns one place set, including its state, counts, and expiry. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/PlaceSet'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      operationId: replacePlaceSet
      summary: Replace a place set's contents
      description: |
        Replaces every place id in the set, from a new CSV file
        (`source: "upload"`, returns an `upload` URL and moves the set to
        `awaiting_upload`) or a list of up to 10,000 place ids
        (`source: "inline"`, moves the set to `processing`). The set keeps
        its `set_id`, name and description. The set stops being `ready`
        straight away: its counts and preview are cleared, and it can't be
        browsed, edited, downloaded or used by a purchase until the new
        contents finish loading. With an upload, if no file arrives within
        7 days the set expires and its old place ids are removed too. Not
        allowed while the set is `processing` or after it has `expired`.
        1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlaceSetReplaceRequest'
      responses:
        '200':
          description: The set with its new contents loading. `upload` is present when `source` is `upload`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/PlaceSetWithUpload'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The set is `processing` or `expired`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    delete:
      operationId: deletePlaceSet
      summary: Delete a place set
      description: |
        Deletes the set, its place ids and its files. Measurements that
        reference a deleted set can no longer be purchased. Not allowed
        while the set is `processing`. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: Deleted.
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The set is `processing`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /sets/places/{set_id}/items:
    get:
      operationId: listPlaceSetItems
      summary: Page through a place set's place ids
      description: |
        Returns the set's place ids in id order, paginated by cursor. The
        set must be `ready`. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
        - name: cursor
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 100
      responses:
        '200':
          description: A page of place ids. `pagination.total` is the number of place ids in the set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: string
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          description: Invalid query parameters, or an invalid cursor.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The set is not `ready`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: addPlaceSetItems
      summary: Add place ids to a place set
      description: |
        Adds up to 10,000 place ids to a `ready` set. Ids already in the
        set are skipped. The response has the updated set and `changed`,
        the number of ids actually added. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlaceSetItemsRequest'
      responses:
        '200':
          description: The updated set.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceSetItemsChangeResponse'
        '400':
          description: Invalid payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The set is not `ready`, or changed during the edit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /sets/places/{set_id}/items/remove:
    post:
      operationId: removePlaceSetItems
      summary: Remove place ids from a place set
      description: |
        Removes up to 10,000 place ids from a `ready` set. Ids not in the
        set are skipped. The response has the updated set and `changed`,
        the number of ids actually removed. 1 credit.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlaceSetItemsRequest'
      responses:
        '200':
          description: The updated set.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaceSetItemsChangeResponse'
        '400':
          description: Invalid payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The set is not `ready`, or changed during the edit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /sets/places/{set_id}/download:
    get:
      operationId: downloadPlaceSet
      summary: Download a place set as one CSV file
      description: |
        Returns a URL for one CSV file of the set's place ids, valid for one
        hour. If you have not edited the set, the file is the one it was
        loaded from. If you have added or removed place ids, the file is
        written fresh with a `place_id` header row: the first call answers
        `status: "preparing"`; call again in a minute or so for the URL. The
        set must be `ready`. 1 credit per call.
      tags:
        - Place Sets
      x-credit-cost: 1
      x-motionworks-status: production
      parameters:
        - name: set_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The download URL, or `preparing`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/PlaceSetDownload'
                  meta:
                    $ref: '#/components/schemas/Meta'
        '404':
          description: Unknown set_id, or a set that does not belong to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: The set is not `ready`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: A service the API depends on is unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
x-tagGroups:
  - name: Campaigns
    tags:
      - Assets
  - name: Events
    tags:
      - Events
  - name: Place Sets
    tags:
      - Place Sets
tags:
  - name: Assets
    description: |
      Create, browse, edit, and archive campaign assets.
  - name: Events
    description: |
      Create, browse, edit, and archive event assets.
  - name: Place Sets
    description: |
      Reusable lists of place ids, uploaded as a CSV file or sent as a
      list. Once a set is `ready` you can page through its place ids, add
      or remove place ids, replace its contents, download it as one CSV
      file, or delete it. Each set shows an `expires_at` date, 180 days
      after its last use; after that it becomes `expired` and its place
      ids are removed. A measurement uses the set's contents at the time
      it runs, so editing a set after purchasing a measurement changes
      what is measured.
