openapi: 3.0.3
info:
  title: Everflow Affiliate API - Product Feeds
  description: >
    Product feed endpoints for the Everflow Affiliate API. These endpoints allow
    affiliates to retrieve product feed data for offers and search across feeds.
    For product feed details, see the [Product Feeds guide](https://helpdesk.everflow.io/customer/product-feeds).
  version: 1.0.0
servers:
  - description: Production Server
    url: https://api.eflow.team/v1
tags:
  - name: Affiliate Product Feeds
    description: Endpoints for retrieving product feed data as an affiliate.
paths:
  /affiliates/offers/{offerId}/productfeeds:
    get:
      summary: Get Offer Product Feeds
      tags:
        - Affiliate Product Feeds
      parameters:
        - name: offerId
          in: path
          required: true
          description: The numeric ID of the offer.
          schema:
            type: integer
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
                properties:
                  product_feeds:
                    type: array
                    description: Array of product feeds for the offer.
                    items:
                      $ref: "#/components/schemas/ProductFeed"
        "404":
          description: Offer not found or not visible to the affiliate.
      security:
        - API Key: []
  /affiliates/productfeeds:
    post:
      summary: Search Product Feeds
      tags:
        - Affiliate Product Feeds
      requestBody:
        content:
          application/json:
            example:
              filters:
                network_offer_ids: [1, 2]
            schema:
              type: object
              properties:
                filters:
                  type: object
                  description: Optional filters to narrow results.
                  properties:
                    network_offer_ids:
                      type: array
                      items:
                        type: integer
                      description: Filter by specific offer IDs.
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
                properties:
                  product_feeds:
                    type: array
                    items:
                      allOf:
                        - $ref: "#/components/schemas/ProductFeed"
                        - type: object
                          properties:
                            relationship:
                              type: object
                              properties:
                                offers:
                                  type: array
                                  description: Offers associated with this product feed.
                                  items:
                                    type: object
                                    properties:
                                      network_offer_id:
                                        type: integer
                                        description: Unique identifier for the offer.
                                      network_id:
                                        type: integer
                                        description: Network ID.
                                      name:
                                        type: string
                                        description: Name of the offer.
                                      offer_status:
                                        type: string
                                        description: Status of the offer.
                  paging:
                    type: object
                    properties:
                      page:
                        type: integer
                      page_size:
                        type: integer
                      total_count:
                        type: integer
      security:
        - API Key: []

  /affiliates/offers/{offerId}/productfeeds/{productFeedId}:
    get:
      summary: Get Product Feed by ID
      tags:
        - Affiliate Product Feeds
      parameters:
        - name: offerId
          in: path
          required: true
          description: The numeric ID of the offer.
          schema:
            type: integer
        - name: productFeedId
          in: path
          required: true
          description: The numeric ID of the product feed.
          schema:
            type: integer
        - name: relationship
          in: query
          description: Include related data. Use `product_feed_item` to include feed items.
          schema:
            type: string
            enum:
              - product_feed_item
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ProductFeed"
                  - type: object
                    description: >
                      When the `relationship=product_feed_item` query parameter is provided,
                      the relationship object includes a `product_feed_items` array.
                    properties:
                      relationship:
                        type: object
                        properties:
                          product_feed_items:
                            type: array
                            description: >
                              Product feed items. Only included when `relationship=product_feed_item`
                              is passed as a query parameter.
                            items:
                              $ref: "#/components/schemas/ProductFeedItem"
        "404":
          description: Product feed not found or not visible to the affiliate.
      security:
        - API Key: []
  /affiliates/offers/{offerId}/productfeeds/{productFeedId}/download:
    get:
      summary: Download Product Feed
      tags:
        - Affiliate Product Feeds
      parameters:
        - name: offerId
          in: path
          required: true
          description: The numeric ID of the offer.
          schema:
            type: integer
        - name: productFeedId
          in: path
          required: true
          description: The numeric ID of the product feed.
          schema:
            type: integer
      responses:
        "200":
          description: CSV file with standardized product feed data.
          content:
            text/csv:
              schema:
                type: string
                description: CSV data with standardized columns.
        "404":
          description: Product feed not found or not visible to the affiliate.
      security:
        - API Key: []
  /affiliates/offers/{offerId}/productfeeds/{productFeedId}/download/original:
    get:
      summary: Download Original Product Feed
      tags:
        - Affiliate Product Feeds
      parameters:
        - name: offerId
          in: path
          required: true
          description: The numeric ID of the offer.
          schema:
            type: integer
        - name: productFeedId
          in: path
          required: true
          description: The numeric ID of the product feed.
          schema:
            type: integer
      responses:
        "200":
          description: CSV file with original product feed data (after following redirect).
          content:
            text/csv:
              schema:
                type: string
                description: CSV data in original format.
        "302":
          description: >
            Redirect to the original file URL. The client should follow the
            redirect to download the CSV file.
        "404":
          description: Product feed not found or not visible to the affiliate.
      security:
        - API Key: []

components:
  schemas:
    ProductFeed:
      type: object
      properties:
        network_advertiser_product_feed_id:
          type: integer
          description: Unique identifier for the product feed.
        network_id:
          type: integer
          description: Network ID.
        network_advertiser_id:
          type: integer
          description: ID of the advertiser that owns this product feed.
        name:
          type: string
          description: Name of the product feed.
        status:
          type: string
          description: Status of the product feed.
        file_asset_id:
          type: integer
          description: ID of the associated file asset.
        date_valid_from:
          type: integer
          description: Unix timestamp for the start of the validity period. 0 if not set.
        date_valid_to:
          type: integer
          description: Unix timestamp for the end of the validity period. 0 if not set.
        date_valid_timezone_id:
          type: integer
          description: Timezone ID for the validity dates.
        time_created:
          type: integer
          example: 1734455015
          description: Unix timestamp of creation.
        time_saved:
          type: integer
          example: 1734455015
          description: Unix timestamp of last update.
        relationship:
          type: object
          properties:
            document_file_asset:
              type: object
              description: The associated file asset with URL and metadata.
              properties:
                network_asset_id:
                  type: integer
                content_type:
                  type: string
                filename:
                  type: string
                url:
                  type: string
                file_size:
                  type: integer
                image_width:
                  type: integer
                image_height:
                  type: integer
                optimized_thumbnail_url:
                  type: string
    ProductFeedItem:
      type: object
      properties:
        network_advertiser_product_feed_id:
          type: integer
          description: ID of the parent product feed.
        network_id:
          type: integer
          description: Network ID.
        sku:
          type: string
          description: Stock keeping unit identifier.
        name:
          type: string
          description: Name of the product.
        description:
          type: string
          description: Description of the product.
        url_link:
          type: string
          description: URL link to the product.
        url_link_mobile:
          type: string
          description: Mobile URL link to the product.
        image_url:
          type: string
          description: URL of the product image.
        image_url_mobile:
          type: string
          description: URL of the mobile product image.
        price:
          type: number
          description: Price of the product.
        brand:
          type: string
          description: Brand of the product.
        availability:
          type: string
          description: Availability status of the product.
        date_valid_from:
          type: integer
          format: int64
          description: Start date of the product's validity period.
        date_valid_to:
          type: integer
          format: int64
          description: End date of the product's validity period.
  securitySchemes:
    API Key:
      description: >
        The affiliate's API key generated from the Affiliate Portal.
        Uses the X-Eflow-Api-Key header.
      in: header
      name: X-Eflow-Api-Key
      type: apiKey
