openapi: 3.0.3
info:
  title: Everflow Network API - Coupon Codes
  description: >
    Endpoints for managing coupon codes in the Everflow network. Coupon
    codes are a powerful attribution tool for tracking partner performance
    through easy-to-share codes — they are specifically designed for
    tracking and attributing conversions to the right partners, not for
    discounts (discount functionality is set up in your own e-commerce
    platform). For setup, see the [Coupon Codes guide](https://helpdesk.everflow.io/customer/how-to-create-manage-coupon-codes).
  version: 1.0.0
servers:
  - url: https://api.eflow.team/v1
tags:
  - name: Coupon Codes
paths:
  /networks/couponcodes:
    get:
      summary: List Coupon Codes
      tags:
        - Coupon Codes
      parameters:
        - in: query
          name: filter
          style: form
          explode: true
          schema:
            type: array
            items:
              type: string
              example: coupon_status=active
          description: >
            Filter coupon codes by repeating the `filter` query parameter.
            Use `<field><operator><value>` expressions, such as
            `coupon_status=active`, `coupon_status=paused`,
            `coupon_code=SAVE20`, `network_offer_id=57`,
            `network_affiliate_id=123`, `time_created>1774725262`, or
            `time_saved<1774725262`.
        - in: query
          name: relationship
          schema:
            type: string
            enum:
              - offer
              - affiliate
          description: >
            Include related entity details in the response.
            Use `offer` to include the offer information, or `affiliate`
            to include the affiliate information.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                coupon_codes:
                  - network_coupon_code_id: 1
                    network_id: 1
                    network_affiliate_id: 0
                    network_offer_id: 57
                    coupon_code: "bla"
                    coupon_status: "active"
                    internal_notes: ""
                    time_created: 1774725262
                    time_saved: 1774725262
                    relationship: {}
                    start_date: ""
                    end_date: ""
                    description: ""
                    is_description_plain_text: false
                    time_deleted: 0
              schema:
                type: object
                properties:
                  coupon_codes:
                    type: array
                    items:
                      $ref: "#/components/schemas/CouponCode"
      security:
        - API Key: []
    post:
      summary: Create Coupon Code
      tags:
        - Coupon Codes
      requestBody:
        required: true
        content:
          application/json:
            example:
              coupon_code: "DOCTEST_CODE_1"
              network_offer_id: 1
              coupon_status: "active"
            schema:
              type: object
              required:
                - coupon_code
                - network_offer_id
                - coupon_status
              properties:
                network_offer_id:
                  type: integer
                  description: ID of the offer for which the coupon applies.
                network_affiliate_id:
                  type: integer
                  description: >
                    ID of the affiliate for which the coupon applies. A coupon
                    code without an affiliate specified can exist but cannot be used.
                coupon_code:
                  type: string
                  minLength: 2
                  description: Coupon code value. Must be at least 2 characters.
                coupon_status:
                  type: string
                  enum:
                    - active
                    - paused
                  description: Status of the coupon code.
                internal_notes:
                  type: string
                  description: Notes for internal usage — they will not be visible to the partner.
                description:
                  type: string
                  description: >
                    A description (either plain text or HTML) that will be
                    visible to the partner.
                is_description_plain_text:
                  type: boolean
                  description: >
                    Only relevant when a description is provided. Determines
                    if the description is in HTML or plain text format.
                start_date:
                  type: string
                  description: >
                    An optional date starting at which the coupon code can be used.
                    Use the YYYY-MM-DD format.
                end_date:
                  type: string
                  description: >
                    An optional date at which the coupon code becomes obsolete.
                    Use the YYYY-MM-DD format.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_coupon_code_id: 1
                network_id: 1
                network_affiliate_id: 7
                network_offer_id: 1
                coupon_code: "DOCTEST_CODE_1"
                coupon_status: "active"
                internal_notes: ""
                time_created: 1774725262
                time_saved: 1774725262
                start_date: ""
                end_date: ""
                description: ""
                is_description_plain_text: false
                time_deleted: 0
              schema:
                $ref: "#/components/schemas/CouponCodeWrite"
      security:
        - API Key: []
  /networks/couponcodes/{couponCodeId}:
    get:
      summary: Get Coupon Code by ID
      tags:
        - Coupon Codes
      parameters:
        - in: path
          name: couponCodeId
          required: true
          schema:
            type: integer
          description: The ID of the coupon code you want to fetch.
        - in: query
          name: relationship
          schema:
            type: string
            enum:
              - offer
              - affiliate
          description: >
            Include related entity details in the response. Use `offer` to
            include the offer information, or `affiliate` to include the
            affiliate information. Can be specified multiple times.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_coupon_code_id: 3
                network_id: 1
                network_affiliate_id: 7
                network_offer_id: 1
                coupon_code: "TESTCC"
                coupon_status: "active"
                internal_notes: ""
                time_created: 1774725303
                time_saved: 1774725303
                relationship: {}
                start_date: ""
                end_date: ""
                description: ""
                is_description_plain_text: false
                time_deleted: 0
              schema:
                $ref: "#/components/schemas/CouponCode"
      security:
        - API Key: []
    put:
      summary: Update Coupon Code
      description: >
        Update an existing coupon code. Any omitted non-required
        fields will be reset to defaults.
      tags:
        - Coupon Codes
      parameters:
        - in: path
          name: couponCodeId
          required: true
          schema:
            type: integer
          description: The ID of the coupon code you want to update.
      requestBody:
        required: true
        content:
          application/json:
            example:
              coupon_code: "SAVE20"
              coupon_status: "active"
              network_offer_id: 1
              network_affiliate_id: 7
            schema:
              type: object
              required:
                - coupon_code
                - coupon_status
                - network_offer_id
              properties:
                network_offer_id:
                  type: integer
                  description: ID of the offer for which the coupon applies.
                network_affiliate_id:
                  type: integer
                  description: >
                    ID of the affiliate for which the coupon applies. A coupon
                    code without an affiliate specified can exist but cannot be used.
                coupon_code:
                  type: string
                  description: Coupon code value.
                coupon_status:
                  type: string
                  enum:
                    - active
                    - paused
                  description: >
                    Status of the coupon code. Can be one of the following
                    values: `active` or `paused`.
                internal_notes:
                  type: string
                  description: Notes for internal usage -- they will not be visible to the partner.
                description:
                  type: string
                  description: >
                    A description (either plain text or HTML) that will be
                    visible to the partner.
                is_description_plain_text:
                  type: boolean
                  description: >
                    Only relevant when a description is provided. Determines
                    if the description is in HTML or plain text format.
                start_date:
                  type: string
                  description: "An optional date starting at which the coupon code can be used. Use the YYYY-MM-DD format."
                end_date:
                  type: string
                  description: >
                    An optional date at which the coupon code becomes obsolete.
                    Use the YYYY-MM-DD format.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_coupon_code_id: 3
                network_id: 1
                network_affiliate_id: 7
                network_offer_id: 1
                coupon_code: "TESTCC-UPD"
                coupon_status: "paused"
                internal_notes: "test note"
                time_created: 1774725303
                time_saved: 1774725327
                start_date: "2026-01-01"
                end_date: "2026-12-31"
                description: ""
                is_description_plain_text: false
                time_deleted: 0
              schema:
                $ref: "#/components/schemas/CouponCodeWrite"
      security:
        - API Key: []
    delete:
      summary: Delete Coupon Code
      description: >
        Delete a coupon code by its ID. This action is permanent and cannot
        be undone.
      tags:
        - Coupon Codes
      parameters:
        - in: path
          name: couponCodeId
          required: true
          schema:
            type: integer
          description: The ID of the coupon code you want to delete.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                result: true
              schema:
                type: object
                properties:
                  result:
                    type: boolean
                    description: Whether the deletion was successful.
      security:
        - API Key: []
components:
  schemas:
    CouponCode:
      type: object
      properties:
        network_coupon_code_id:
          type: integer
          description: Unique identifier for this coupon code.
        network_id:
          type: integer
          description: The ID of the network this coupon code belongs to.
        network_affiliate_id:
          type: integer
          description: >
            ID of the affiliate for which the coupon applies. A coupon
            code without an affiliate specified can exist but cannot be used.
        network_offer_id:
          type: integer
          description: ID of the offer for which the coupon applies.
        coupon_code:
          type: string
          description: Coupon code value.
        coupon_status:
          type: string
          enum:
            - active
            - paused
          description: >
            Status of the coupon code. Can be one of the following
            values: `active` or `paused`.
        internal_notes:
          type: string
          description: Notes for internal usage -- they will not be visible to the partner.
        description:
          type: string
          description: >
            A description (either plain text or HTML) that will be
            visible to the partner.
        is_description_plain_text:
          type: boolean
          description: >
            Only relevant when a description is provided. Determines
            if the description is in HTML or plain text format.
        start_date:
          type: string
          description: "An optional date starting at which the coupon code can be used. Uses the YYYY-MM-DD format."
        end_date:
          type: string
          description: "An optional date at which the coupon code becomes obsolete. Uses the YYYY-MM-DD format."
        time_created:
          type: integer
          example: 1734455015
          description: Unix timestamp of when the coupon code was created.
        time_saved:
          type: integer
          example: 1734455015
          description: Unix timestamp of when the coupon code was last updated.
        time_deleted:
          type: integer
          example: 0
          description: Unix timestamp of when the coupon code was deleted. 0 if not deleted.
        relationship:
          type: object
          description: >
            Related resources. Populated when the `relationship` query
            parameter is provided.
          properties:
            offer:
              type: object
              properties:
                network_offer_id:
                  type: integer
                  description: Unique offer ID.
                network_id:
                  type: integer
                  description: Network ID.
                name:
                  type: string
                  description: Offer name.
                offer_status:
                  type: string
                  description: Status of the offer.
            affiliate:
              type: object
              properties:
                network_affiliate_id:
                  type: integer
                  description: Unique affiliate ID.
                network_id:
                  type: integer
                  description: Network ID.
                name:
                  type: string
                  description: Affiliate name.
                account_status:
                  type: string
                  description: Account status of the affiliate.
    CouponCodeWrite:
      type: object
      description: Coupon code as returned by create and update endpoints (without relationship data).
      properties:
        network_coupon_code_id:
          type: integer
          description: Unique identifier for this coupon code.
        network_id:
          type: integer
          description: The ID of the network this coupon code belongs to.
        network_affiliate_id:
          type: integer
          description: >
            ID of the affiliate for which the coupon applies. A coupon
            code without an affiliate specified can exist but cannot be used.
        network_offer_id:
          type: integer
          description: ID of the offer for which the coupon applies.
        coupon_code:
          type: string
          description: Coupon code value.
        coupon_status:
          type: string
          enum:
            - active
            - paused
          description: >
            Status of the coupon code. Can be one of the following
            values: `active` or `paused`.
        internal_notes:
          type: string
          description: Notes for internal usage -- they will not be visible to the partner.
        description:
          type: string
          description: >
            A description (either plain text or HTML) that will be
            visible to the partner.
        is_description_plain_text:
          type: boolean
          description: >
            Only relevant when a description is provided. Determines
            if the description is in HTML or plain text format.
        start_date:
          type: string
          description: "An optional date starting at which the coupon code can be used. Uses the YYYY-MM-DD format."
        end_date:
          type: string
          description: "An optional date at which the coupon code becomes obsolete. Uses the YYYY-MM-DD format."
        time_created:
          type: integer
          example: 1734455015
          description: Unix timestamp of when the coupon code was created.
        time_saved:
          type: integer
          example: 1734455015
          description: Unix timestamp of when the coupon code was last updated.
        time_deleted:
          type: integer
          example: 0
          description: Unix timestamp of when the coupon code was deleted. 0 if not deleted.
  securitySchemes:
    API Key:
      description: The Everflow API key generated from the Control Center > Security.
      in: header
      name: X-Eflow-Api-Key
      type: apiKey
