openapi: 3.0.1
info:
  title: Partner Webhooks
  termsOfService: <http://swagger.io/terms/>
  contact:
    email: [email protected]
  license:
    name: Apache 2.0
    url: <http://www.apache.org/licenses/LICENSE-2.0.html>
  version: 1.0.0
externalDocs:
  description: Find out more about Swagger
  url: <http://swagger.io>
servers:
  - url: <http://127.0.0.1:8080/api>
tags:
  - name: webhook
    description: process audience lists
    externalDocs:
      description: Find out more
      url: <http://swagger.io>
paths:
  /webhook:
    post:
      tags:
        - webhook
      summary: webhook for audience list processing
      operationId: processWebhookMessage
      requestBody:
        description: webhook message
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookMessage'
        required: true
      responses:
        default:
          description: response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookMessage'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    WebhookMessage:
      type: object
      properties:
        action:
          type: string
          enum:
            - members
            - add_members
            - remove_members
        status:
          type: string
          enum:
            - success
            - failure
        error:
          $ref: '#/components/schemas/AudienceError'
        parameters:
          $ref: '#/components/schemas/AudienceParameters'
      example:
        action: members
        error:
          code: 0
          message: message
        parameters:
          mixpanel_project_id: mixpanel_project_id
          mixpanel_cohort_name: mixpanel_cohort_name
          mixpanel_cohort_id: mixpanel_cohort_id
          members:
            - mixpanel_distinct_id: mixpanel_distinct_id
              last_name: last_name
              partner_user_id: partner_user_id
              phone_number: phone_number
              first_name: first_name
              email: email
            - mixpanel_distinct_id: mixpanel_distinct_id
              last_name: last_name
              partner_user_id: partner_user_id
              phone_number: phone_number
              first_name: first_name
              email: email
          page_info:
            total_pages: 10
            page_count: 6
          mixpanel_cohort_description: mixpanel_cohort_description
          mixpanel_session_id: mixpanel_session_id
        status: success
    AudienceError:
      type: object
      properties:
        message:
          type: string
        code:
          type: integer
      example:
        code: 0
        message: message
    AudienceParameters:
      type: object
      properties:
        mixpanel_project_id:
          type: string
        mixpanel_cohort_name:
          type: string
        mixpanel_cohort_id:
          type: string
        mixpanel_cohort_description:
          type: string
        mixpanel_session_id:
          type: string
        members:
          type: array
          items:
            $ref: '#/components/schemas/AudienceMembers'
        page_info:
          $ref: '#/components/schemas/Pagination'
      example:
        mixpanel_project_id: mixpanel_project_id
        mixpanel_cohort_name: mixpanel_cohort_name
        mixpanel_cohort_id: mixpanel_cohort_id
        members:
          - mixpanel_distinct_id: mixpanel_distinct_id
            last_name: last_name
            partner_user_id: partner_user_id
            phone_number: phone_number
            first_name: first_name
            email: email
          - mixpanel_distinct_id: mixpanel_distinct_id
            last_name: last_name
            partner_user_id: partner_user_id
            phone_number: phone_number
            first_name: first_name
            email: email
        page_info:
          total_pages: 1
          page_count: 6
        mixpanel_cohort_description: mixpanel_cohort_description
        mixpanel_session_id: mixpanel_session_id
    AudienceMembers:
      type: object
      properties:
        email:
          type: string
        first_name:
          type: string
        last_name:
          type: string
        mixpanel_distinct_id:
          type: string
        partner_user_id:
          type: string
        phone_number:
          type: string
      example:
        mixpanel_distinct_id: mixpanel_distinct_id
        last_name: last_name
        partner_user_id: partner_user_id
        phone_number: phone_number
        first_name: first_name
        email: email
    Pagination:
      type: object
      properties:
        page_count:
          type: integer
        total_pages:
          type: integer
      example:
        total_pages: 10
        page_count: 6
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: X-API-KEY
      in: header