openapi: 3.0.3
info:
  title: Everflow Network API - Advertiser Users
  description: >
    Endpoints for managing advertiser user accounts from the network level.
    Advertiser users are individual people who belong to an advertiser
    (brand) account. Networks can create, update, and retrieve these users
    to control who has access to the advertiser platform and dashboard.
  version: 1.0.0
servers:
  - url: https://api.eflow.team/v1
tags:
  - name: Advertiser Users
paths:
  /networks/advertisers/{advertiserId}/users:
    get:
      summary: List Advertiser Users by Advertiser
      tags:
        - Advertiser Users
      parameters:
        - in: path
          name: advertiserId
          required: true
          schema:
            type: integer
          description: The ID of the advertiser whose users you want to fetch.
        - in: query
          name: relationship
          required: false
          schema:
            type: string
            enum:
              - logins
              - api
              - customizations
          description: >
            Include additional relationships in the response. Multiple relationships can be supplied
            by repeating this query parameter. Supported values: `logins` (includes the user's list
            of logins), `api` (includes the user's API key and whitelisted IPs), `customizations`
            (includes the user's customizations).

            `customizations` populates `relationship.customization` (singular). An unrecognised
            value is ignored.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                users:
                  - network_advertiser_user_id: 17
                    network_id: 1
                    network_advertiser_id: 13
                    first_name: "Bob"
                    last_name: "T"
                    email: "everflow.test+adv@gmail.com"
                    title: ""
                    work_phone: "7726565527"
                    cell_phone: ""
                    instant_messaging_id: 5
                    instant_messaging_identifier: "312312"
                    language_id: 1
                    timezone_id: 75
                    currency_id: "USD"
                    account_status: "active"
                    time_created: 1774296114
                    time_saved: 1774615432
                    relationship: {}
                  - network_advertiser_user_id: 34
                    network_id: 1
                    network_advertiser_id: 13
                    first_name: "Oscar"
                    last_name: "Fischer"
                    email: "everflow.test+volKdRxvXkZaZOjMcVZI@gmail.com"
                    title: ""
                    work_phone: "7492318197"
                    cell_phone: ""
                    instant_messaging_id: 0
                    instant_messaging_identifier: ""
                    language_id: 1
                    timezone_id: 75
                    currency_id: "USD"
                    account_status: "active"
                    time_created: 1774296114
                    time_saved: 1774296114
                    relationship: {}
              schema:
                type: object
                properties:
                  users:
                    type: array
                    items:
                      $ref: "#/components/schemas/AdvertiserUser"
      security:
        - API Key: []
    post:
      summary: Create Advertiser User
      tags:
        - Advertiser Users
      parameters:
        - in: path
          name: advertiserId
          required: true
          schema:
            type: integer
          description: The ID of the advertiser for whom to create a user.
        - in: query
          name: notification
          schema:
            type: boolean
            default: true
          description: Whether to send a welcome notification email to the user. Defaults to `true` when omitted.
      requestBody:
        required: true
        content:
          application/json:
            example:
              first_name: "Bob"
              last_name: "Smith"
              email: "adv.user.doctest.new@example.com"
              title: "Manager"
              work_phone: "1234567788"
              cell_phone: ""
              instant_messaging_id: 0
              instant_messaging_identifier: ""
              language_id: 1
              timezone_id: 90
              currency_id: "USD"
              account_status: "active"
              send_activation_email: true
              set_password_manually: false
              initial_password: ""
            schema:
              $ref: "#/components/schemas/AdvertiserUserInput"
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_advertiser_user_id: 256
                network_id: 1
                network_advertiser_id: 13
                first_name: "Bob"
                last_name: "Smith"
                email: "adv.user.doctest.new@example.com"
                title: "Manager"
                work_phone: "1234567788"
                cell_phone: ""
                instant_messaging_id: 0
                instant_messaging_identifier: ""
                language_id: 1
                timezone_id: 90
                currency_id: "USD"
                account_status: "active"
                time_created: 1774322306
                time_saved: 1774322306
                relationship: {}
              schema:
                $ref: "#/components/schemas/AdvertiserUser"
      security:
        - API Key: []
  /networks/advertisers/{advertiserId}/users/{userId}:
    get:
      summary: Find Advertiser User by ID
      tags:
        - Advertiser Users
      parameters:
        - in: path
          name: advertiserId
          required: true
          schema:
            type: integer
          description: The ID of the advertiser whose user you want to fetch.
        - in: path
          name: userId
          required: true
          schema:
            type: integer
          description: The ID of the user you want to fetch.
        - in: query
          name: relationship
          required: false
          schema:
            type: string
            enum:
              - logins
              - api
              - customizations
          description: >
            Include additional relationships in the response. Multiple relationships can be supplied
            by repeating this query parameter. Supported values: `logins` (includes the user's list
            of logins), `api` (includes the user's API key and whitelisted IPs), `customizations`
            (includes the user's customizations).

            `customizations` populates `relationship.customization` (singular). An unrecognised
            value is ignored.
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_advertiser_user_id: 17
                network_id: 1
                network_advertiser_id: 13
                first_name: "Bob"
                last_name: "T"
                email: "everflow.test+adv@gmail.com"
                title: ""
                work_phone: "7726565527"
                cell_phone: ""
                instant_messaging_id: 5
                instant_messaging_identifier: "312312"
                language_id: 1
                timezone_id: 75
                currency_id: "USD"
                account_status: "active"
                time_created: 1774296114
                time_saved: 1774615432
                relationship:
                  logins:
                    total: 0
                    entries: []
              schema:
                $ref: "#/components/schemas/AdvertiserUser"
      security:
        - API Key: []
    put:
      summary: Update Advertiser User
      tags:
        - Advertiser Users
      parameters:
        - in: path
          name: advertiserId
          required: true
          schema:
            type: integer
          description: The ID of the advertiser whose user you want to update.
        - in: path
          name: userId
          required: true
          schema:
            type: integer
          description: The ID of the user you want to update.
      requestBody:
        required: true
        content:
          application/json:
            example:
              first_name: "Bob"
              last_name: "Smith"
              email: "adv.user.doctest.update@example.com"
              title: "Manager"
              work_phone: "1234567788"
              cell_phone: ""
              instant_messaging_id: 3
              instant_messaging_identifier: "@bobsmith"
              language_id: 1
              timezone_id: 90
              currency_id: "USD"
              account_status: "active"
            schema:
              $ref: "#/components/schemas/AdvertiserUserUpdateInput"
      responses:
        "200":
          description: ""
          content:
            application/json:
              example:
                network_advertiser_user_id: 17
                network_id: 1
                network_advertiser_id: 13
                first_name: "Bob"
                last_name: "Smith"
                email: "adv.user.doctest.update@example.com"
                title: "Manager"
                work_phone: "1234567788"
                cell_phone: ""
                instant_messaging_id: 3
                instant_messaging_identifier: "@bobsmith"
                language_id: 1
                timezone_id: 90
                currency_id: "USD"
                account_status: "active"
                time_created: 1774296114
                time_saved: 1774615395
                relationship: {}
              schema:
                $ref: "#/components/schemas/AdvertiserUser"
        "404":
          description: Advertiser user not found.
      security:
        - API Key: []
components:
  schemas:
    AdvertiserUser:
      type: object
      properties:
        network_advertiser_user_id:
          type: integer
          description: Unique advertiser user ID.
        network_id:
          type: integer
          description: The network ID this user belongs to.
        network_advertiser_id:
          type: integer
          description: The advertiser ID this user belongs to.
        first_name:
          type: string
          description: The advertiser user's first name.
        last_name:
          type: string
          description: The advertiser user's last name.
        email:
          type: string
          description: The advertiser user's email address.
        title:
          type: string
          description: The advertiser user's title.
        account_status:
          type: string
          enum:
            - active
            - inactive
            - suspended
          description: The advertiser user's account status.
        work_phone:
          type: string
          description: The advertiser user's work phone number.
        cell_phone:
          type: string
          description: The advertiser user's cell phone number.
        instant_messaging_id:
          type: integer
          description: >
            The ID of an instant messaging platform. Values are 0 for None, 1 for Skype,
            2 for Yahoo Messenger, 3 for Telegram, 4 for WhatsApp, 5 for Other.
        instant_messaging_identifier:
          type: string
          description: The advertiser user's instant messaging identifier.
        language_id:
          type: integer
          description: The advertiser user's language ID.
        timezone_id:
          type: integer
          description: The advertiser user's timezone ID.
        currency_id:
          type: string
          description: The advertiser user's currency ID (ISO currency code).
        relationship:
          type: object
          nullable: true
          description: >
            Related data for this advertiser user. Populate by passing `relationship` query
            parameters (e.g. `?relationship=logins&relationship=api`).
          properties:
            logins:
              type: object
              description: The user's list of logins.
              properties:
                total:
                  type: integer
                  description: Total number of login records.
                entries:
                  type: array
                  description: List of login records.
                  items:
                    type: object
            customization:
              type: object
              description: The user's customizations.
              properties:
                network_advertiser_user_id:
                  type: integer
                  description: The advertiser user ID this customization belongs to.
                dashboard_refresh_rate:
                  type: integer
                  description: Dashboard refresh rate in seconds.
                pins_customization:
                  type: string
                  description: JSON string of pinned dashboard widgets.
                columns_customization:
                  type: string
                  description: JSON string of column display preferences.
                time_created:
                  type: integer
                  example: 1734455015
                  description: Unix timestamp of creation.
                time_saved:
                  type: integer
                  example: 1734455015
                  description: Unix timestamp of last update.
            api:
              type: object
              description: API key and whitelisted IPs for this user.
              properties:
                api_key:
                  type: string
                  description: The user's API key. Empty if not generated.
                restricted_ips:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: List of whitelisted IP addresses. Null if unrestricted.
        time_created:
          type: integer
          example: 1734455015
          description: Unix timestamp of creation.
        time_saved:
          type: integer
          example: 1734455015
          description: Unix timestamp of last update.
    AdvertiserUserInput:
      type: object
      required:
        - first_name
        - last_name
        - email
        - language_id
        - timezone_id
        - currency_id
        - account_status
      properties:
        first_name:
          type: string
          description: The advertiser user's first name.
        last_name:
          type: string
          description: The advertiser user's last name.
        email:
          type: string
          description: The advertiser user's email. Must be unique among all advertiser users. Used to log in the platform.
        title:
          type: string
          description: The advertiser user's title.
        work_phone:
          type: string
          description: The advertiser user's work phone number.
        cell_phone:
          type: string
          description: The advertiser user's cell phone number.
        instant_messaging_id:
          type: integer
          description: >
            The ID of an instant messaging platform. Values are 0 for None, 1 for Skype,
            2 for Yahoo Messenger, 3 for Telegram, 4 for WhatsApp, 5 for Other.
        instant_messaging_identifier:
          type: string
          description: >
            The advertiser user's instant messaging identifier. Required when an
            `instant_messaging_id` is selected.
        language_id:
          type: integer
          description: The advertiser user's language ID. This is limited to the value 1 (English).
        timezone_id:
          type: integer
          description: The advertiser user's timezone ID. Can be found using the metadata API.
        currency_id:
          type: string
          description: The advertiser user's currency ID. Can be found using the metadata API.
        account_status:
          type: string
          enum:
            - active
            - inactive
            - suspended
          description: The advertiser user's account status.
        send_activation_email:
          type: boolean
          description: >
            When set to true, an activation email is sent to the user notifying them of
            their account creation.
        set_password_manually:
          type: boolean
          description: >
            When set to true, the `initial_password` field is required and will be used
            as the user's login password. When false, the user will receive a password
            reset email to set their own password.
        initial_password:
          type: string
          description: >
            The user's login password. Required when `set_password_manually` is true.
            Must be a minimum of 12 characters.
    AdvertiserUserUpdateInput:
      type: object
      required:
        - first_name
        - last_name
        - email
        - language_id
        - timezone_id
        - currency_id
        - account_status
      properties:
        first_name:
          type: string
          description: The advertiser user's first name.
        last_name:
          type: string
          description: The advertiser user's last name.
        email:
          type: string
          description: The advertiser user's email. Must be unique among all advertiser users. Used to log in the platform.
        title:
          type: string
          description: The advertiser user's title.
        work_phone:
          type: string
          description: The advertiser user's work phone number.
        cell_phone:
          type: string
          description: The advertiser user's cell phone number.
        instant_messaging_id:
          type: integer
          description: >
            The ID of an instant messaging platform. Values are 0 for None, 1 for Skype,
            2 for Yahoo Messenger, 3 for Telegram, 4 for WhatsApp, 5 for Other.
        instant_messaging_identifier:
          type: string
          description: >
            The advertiser user's instant messaging identifier. Required when an
            `instant_messaging_id` is selected.
        language_id:
          type: integer
          description: The advertiser user's language ID. This is limited to the value 1 (English).
        timezone_id:
          type: integer
          description: The advertiser user's timezone ID. Can be found using the metadata API.
        currency_id:
          type: string
          description: The advertiser user's currency ID. Can be found using the metadata API.
        account_status:
          type: string
          enum:
            - active
            - inactive
            - suspended
          description: The advertiser user's account status.
  securitySchemes:
    API Key:
      description: The Everflow API key generated from the Control Center > Security.
      in: header
      name: X-Eflow-Api-Key
      type: apiKey
