swagger: '2.0'
info:
  version: 2.0.0
  title: Alvaria Cloud Customer Experience Disposable App REST API
  contact:
    name: Alvaria Software
    url: 'https://www.alvaria.com'
    email: support@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 Alvaria&trade; Cloud Customer Experience REST API, provided by the CX Server, facilitates easy integration
    with other systems by providing access to the endpoints needed to interact with the Disposable App Feature

    In order to utilize the Customer Experience REST API the customerexperienceapi scope is required.

host: orgId.via.aspect-cloud.net
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  '/via/v2/organizations/{orgId}/customerexperience/disposableApp/context':
    get:
      tags:
        - Context
      operationId: Get Context
      summary: Get Context
      description: Returns the Context set on a disposable App object
      parameters:
        - name: orgId
          in: path
          description: Name of a customer organization
          required: true
          type: string
        - name: sessionId
          in: query
          description: Dialog Id where the disposable app is running.
          required: true
          type: string
        - name: Authorization
          in: header
          description: |-
            Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint
          required: true
          type: string
        - name: x-api-key
          in: header
          required: true
          type: string
          description: Alvaria-provided value used to track API endpoint usage
      security:
        - oauth:
            - customerexperienceapi
      responses:
        '200':
          description: Successful response
          schema:
            $ref: '#/definitions/Context'
        '400':
          description: Validation exception
          schema:
            $ref: '#/definitions/ErrorResponse'
        '401':
          description: Unauthorized
        '404':
          description: Dialog Id not found on the cluster
          schema:
            $ref: '#/definitions/ErrorResponse'
        '406':
          description: An output format different from XML and JSON was requested
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: Internal server error
          schema:
            $ref: '#/definitions/ErrorResponse'
  '/via/v2/organizations/{orgId}/customerexperience/disposableApp/outcome':
    post:
      tags:
        - Outcome
      operationId: Post Outcome
      summary: Post Outcome
      description: This endpoint is called when the external disposable app is completed
      parameters:
        - name: orgId
          in: path
          description: Name of a customer organization
          required: true
          type: string
        - name: sessionId
          in: query
          description: Dialog Id where the disposable app is running.
          required: true
          type: string
        - name: Authorization
          in: header
          description: |-
            Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint
          required: true
          type: string
        - name: x-api-key
          in: header
          required: true
          type: string
          description: Alvaria-provided value used to track API endpoint usage
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Outcome'
      security:
        - oauth:
            - customerexperienceapi
      responses:
        '204':
          description: Successful response
        '400':
          description: Validation exception
          schema:
            $ref: '#/definitions/ErrorResponse'
        '401':
          description: Unauthorized
        '404':
          description: Dialog Id not found on the cluster
          schema:
            $ref: '#/definitions/ErrorResponse'
        '406':
          description: An output format different from XML and JSON was requested
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: Internal server error
          schema:
            $ref: '#/definitions/ErrorResponse'
securityDefinitions:
  oauth:
    type: oauth2
    authorizationUrl: 'https://myaspect.{region}.id.aspect-cloud.net/tokenservice/oauth2/access_token?realm={orgId}'
    flow: implicit
    scopes:
      customerexperienceapi: manage the complete customer experience api
      customerexperienceapi.disposableapp: manage customer experience - disposable apps
definitions:
  Context:
    type: object
    properties:
      kind:
        description: Identifier used by Alvaria&trade; Cloud components to serialize the payload of the results
        type: string
        default: 'cxp#disposableAppContext'
        example: 'cxp#disposableAppContext'
      content:
        type: string
        description: The content set on the disposable app
        default: ''
        example: 'Context'
  Outcome:
    type: object
    properties:
      kind:
        description: Identifier used by Alvaria&trade; Cloud components to serialize the payload of the results
        type: string
        default: 'cxp#disposableAppOutcome'
        example: 'cxp#disposableAppOutcome'
      variables:
        type: array
        description: List of variables to be set
        items:
          type: object
          properties:
            id:
              description: Unique ID that matches a reference id of a CX script variable or creates a new session variable with that name
              type: string
              example: 'variable1'
            value:
              description: Value to be assigned to the variable or session variable
              type: string
              example: 'Value set by the external Web App'
  ErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: HTTP error status
        example: '400'
      message:
        type: string
        example: Validation exception
      errors:
        type: array
        items:
          $ref: '#/definitions/Error'
  Error:
    type: object
    properties:
      scope:
        type: string
        example: global
      reason:
        type: string
        example: Invalid request
      message:
        type: string
        example: The value for the channel is invalid
