swagger: '2.0'
info:
  version: 2.0.0
  title: Alvaria Cloud EmailQueue REST API
  contact:
    name: Alvaria
    url: 'https://www.alvaria.com'
  license:
    name: 'License: Creative Commons Attribution 4.0 International Public License'
    url: 'https://creativecommons.org/licenses/by/4.0/legalcode'
  description: |

    # Overview
    The Email Queue Microservice provides access to realtime status of all emails active within Alvaria&trade; Cloud.
host: orgId.via.aspect-cloud.net
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  '/via/v2/organizations/{orgId}/emailQueue/emails':
    get:
      operationId: getEmailList
      tags:
        - Emails
      produces:
        - application/json
      parameters:
        - name: orgId
          in: path
          required: true
          type: string
          description: Name of customer organization.
        - name: startIndex
          in: query
          required: false
          type: integer
          description: Starting Index of the items returned (0 based).
        - name: maxResults
          in: query
          required: false
          type: integer
          description: Maximum results. This is used to specify the maximum number of records to return in the result set. You can use this to set a result set limit that is less than the system/API-specific limit.
        - name: getExtendedInfo
          in: query
          required: false
          type: boolean
          default: false
          description: This value when set to true helps in getting additional columns in the output by querying Users and Service tables.
        - name: emailType
          in: query
          required: false
          type: string
          enum:
            - InboundEmail
            - ManualOutboundEmail
            - CampaignOutboundEmail
          description: 'Filter items based on email type. Enumeration : `InboundEmail` - Inbound Emails, `ManualOutboundEmail` - Manual Outbound, `CampaignOutboundEmail` - Campaign Outbound'
        - name: umId
          in: query
          required: false
          type: string
          maxLength: 37
          description: Filter items based on umId. Supports wildcard characters.
        - name: workTypeId
          in: query
          required: false
          type: array
          items:
            type: string
          description: Filter items based on workTypeId.
        - name: workHandlerId
          in: query
          required: false
          type: string
          description: Filter items based on Agent Id.
        - name: state
          in: query
          required: false
          type: array
          items:
            type: string
            enum:
              - Invalid
              - Queued
              - Queued2
              - Active
              - Wrap
              - Review
              - ReviewActive
              - Draft
              - DraftActive
              - Transferred
              - TransferredActive
              - Reassigned
              - ReassignedDraft
              - ReassignedActive
          description: 'Filter items based on current state of the email - internal name is State. Enumeration : `Invalid` - Used only if an unexpected state value is detected, `Queued` - Queued in Via (New-1), `Queued2` - Queued in Via, `Active` - Active with Agent, `Wrap` - Wrap with Agent, `Review` - To-be-replied Email waits for Supervisor review (Wait-for-Review), `ReviewActive` - Review-required email in the reviewing state (Read), `Draft` - Agent saved email draft, `DraftActive` - Agent retrieved the draft and is working on it now, `Transferred` - Is transferred email, `TransferredActive` - Agent received the transferred Email and is working on it now, `Reassigned` - Email reassigned to Work Type from the Email Reassignment Widget, `ReassignedDraft` - Email reassigned to User from the Email Reassignment Widget, `ReassignedActive` - An email in the Work Type queue, that was in the Reassigned state, has been routed to a User (by Engagement Hub).'
        - name: Authorization
          in: header
          required: false
          type: string
          description: 'Authentication token with the value: ''Bearer {accessToken}'', where {accessToken} was returned from a call to the authorization endpoint.'
        - name: x-api-key
          in: header
          required: true
          type: string
          description: Alvaria-provided value used to track API endpoint usage.
      security:
        - oauth:
            - emailqueueapi
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/EmailList'
        '400':
          description: Bad Request
          schema:
            $ref: '#/definitions/ErrorResponse'
        '401':
          description: Unauthorized
        '404':
          description: Not Found
          schema:
            $ref: '#/definitions/ErrorResponse'
        '405':
          description: Method Not Allowed
          schema:
            $ref: '#/definitions/ErrorResponse'
        '429':
          description: Too Many Requests
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: Internal Server Error
          schema:
            $ref: '#/definitions/ErrorResponse'
definitions:
  Error:
    type: object
    properties:
      scope:
        type: string
        example: scope
      reason:
        type: string
        example: reason
      message:
        type: string
        example: message
  ErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: HTTP error status
        example: 404
      message:
        type: string
        example: not found
      errors:
        type: array
        items:
          $ref: '#/definitions/Error'
  EmailItem:
    type: object
    properties:
      id:
        type: string
        format: int32
        description: Alvaria-generated unique identifier for the email instance.
        example: '42235'
      threadId:
        type: string
        format: int32
        description: Alvaria-generated unique identifier for the thread of the email instance.
        example: '247958000'
      umId:
        type: string
        maxLength: 37
        description: Alvaria-generated unique identifier for the Universal Media ID of an interaction.
        example: 01-0010010000-190415-184140862-00034
      contactId:
        type: string
        format: int32
        description: This is a deprecated property.
        example: '5504'
      interactionId:
        type: string
        format: int32
        description: Alvaria-generated unique identifier for the interaction instance.
        example: '5504'
      workTypeId:
        type: string
        format: int32
        description: Alvaria-generated unique identifier for the WorkType.
        example: '111'
      workHandlerId:
        type: string
        maxLength: 97
        description: Alvaria-generated unique identifier for the user that processed the email.
        example: 208ddce3f41ec82
      sentTime:
        type: string
        format: date-time
        description: 'Timestamp of when email was sent, specified in ISO 8601 format (e.g. 1985-04-12T23:20:50.525Z).'
        example: '2019-04-15T18:37:01.000Z'
      receivedTime:
        type: string
        format: date-time
        description: 'Timestamp of when email was received, specified in ISO 8601 format (e.g. 1985-04-12T23:20:50.525Z).'
        example: '2019-04-15T18:41:40.000Z'
      startTime:
        type: string
        format: date-time
        description: 'Timestamp of when email call was started, specified in ISO 8601 format (e.g. 1985-04-12T23:20:50.525Z).'
        example: '2019-04-15T18:41:40.874Z'
      queuedTime:
        type: string
        format: date-time
        description: 'Timestamp of when email call was queued, specified in ISO 8601 format (e.g. 1985-04-12T23:20:50.525Z).'
        example: '2019-04-15T18:41:40.874Z'
      activeTime:
        type: string
        format: date-time
        description: 'Timestamp of when email call went active, specified in ISO 8601 format (e.g. 1985-04-12T23:20:50.525Z).'
        example: '2019-04-15T20:02:20.213Z'
      lastModifiedTime:
        type: string
        format: date-time
        description: 'Timestamp of when email call was modified, specified in ISO 8601 format (e.g. 1985-04-12T23:20:50.525Z).'
        example: '2019-04-15T20:02:49.446Z'
      eventSequenceNumber:
        type: integer
        format: int64
        description: Alvaria-generated unique identifier for the sequence of the processed email call.
        example: '77143977'
      state:
        type: string
        enum:
          - Invalid
          - Queued
          - Queued2
          - Active
          - Wrap
          - Review
          - ReviewActive
          - Draft
          - DraftActive
          - Transferred
          - TransferredActive
          - Reassigned
          - ReassignedDraft
          - ReassignedActive
        description: 'Filter items based on current state of the email - internal name is State. Enumeration : `Invalid` - Used only if an unexpected state value is detected, `Queued` - Queued in Via (New-1), `Queued2` - Queued in Via, `Active` - Active with Agent, `Wrap` - Wrap with Agent, `Review` - To-be-replied Email waits for Supervisor review (Wait-for-Review), `ReviewActive` - Review-required email in the reviewing state (Read), `Draft` - Agent saved email draft, `DraftActive` - Agent retrieved the draft and is working on it now, `Transferred` - Is transferred email, `TransferredActive` - Agent received the transferred Email and is working on it now, `Reassigned` - Email reassigned to Work Type from the Email Reassignment Widget, `ReassignedDraft` - Email reassigned to User from the Email Reassignment Widget, `ReassignedActive` - An email in the Work Type queue, that was in the Reassigned state, has been routed to a User (by Engagement Hub).'
        example: Queued
      emailType:
        type: string
        enum:
          - InboundEmail
          - ManualOutboundEmail
          - CampaignOutboundEmail
        description: 'Filter items based on email type. Enumeration : `InboundEmail` - Inbound Emails, `ManualOutboundEmail` - Manual Outbound, `CampaignOutboundEmail` - Campaign Outbound'
        example: InboundEmail
      emailObjectId:
        type: string
        maxLength: 100
        description: Alvaria-generated unique identifier for the access key.
        example: email/1c8e-20190415-184140/111-0
      replyEmailObjectId:
        type: string
        maxLength: 100
        description: Alvaria-generated unique identifier for the access key of the replied or draft email body.
        example: email/fe1f-20190415-200249/111-1
      fromAddress:
        type: string
        maxLength: 256
        description: Email address of the sender.
        example: customer@gmail.com
      toAddress:
        type: string
        maxLength: 256
        description: Email address of the destination.
        example: service01@orgname.com
      subject:
        type: string
        maxLength: 512
        description: Subject of the email.
        example: Follow-up email to confirm my appointment
      workHandlerName:
        type: string
        maxLength: 512
        description: Name of the user handling the email call.
        example: 'doe, jane'
      workTypeName:
        type: string
        maxLength: 512
        description: Alvaria-generated unique identifier for the work type.
        example: Service01
  EmailList:
    type: object
    properties:
      kind:
        type: string
        default: via#emailList
        description: Identifier used by Alvaria&trade; Cloud components to serialize the payload of the results.
        example: via#emailList
      totalItems:
        type: integer
        description: Total number of email items contained in the list.
        example: 1
      lastIndexReturned:
        type: integer
        description: This is a deprecated property.
        example: 0
      version:
        type: string
        description: The release version of Alvaria&trade; Cloud.  Internal use only.
        example: '20.0'
      items:
        type: array
        items:
          $ref: '#/definitions/EmailItem'
        description: List of email items which meet the filter parameters.
securityDefinitions:
  oauth:
    type: oauth2
    authorizationUrl: 'https://myaspect.id.aspect-cloud.net/'
    flow: implicit
    scopes:
      emailqueueapi: manage the Email Queue resource
