openapi: 3.0.1
info:
  title: WCS REST API
  description: This is the REST API v 2.0 for Web Call Server 5.2.x
  termsOfService: https://flashphoner.com
  contact:
    email: support@flashphoner.com
  license:
    name: Flashphoner License
  version: 2.0.0
servers:
- url: https://demo.flashphoner.com:8444
paths:
  /rest-api/stream/find:
    post:
      tags:
      - Streaming
      summary: Find streams
      description: Find streams by filter
      operationId: find
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamFilter'
        required: true
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamObject'
        "400":
          description: Bad request
        "404":
          description: Not found
        "500":
          description: Internal server error
  /rest-api/stream/find_all:
    get:
      tags:
      - Streaming
      summary: Find all streams
      operationId: findAll
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stream'
        "404":
          description: Not found
  /rest-api/stream/event/send:
    post:
      tags:
      - Streaming
      summary: Send data to all the stream subscribers
      operationId: sendDataEvent
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RestStreamEvent'
        required: true
      responses:
        "200":
          description: Successful response
        "404":
          description: Not found
        "500":
          description: Internal server error
  /rest-api/stream/snapshot:
    post:
      tags:
      - Streaming
      summary: Make Stream snapshot
      operationId: snapshot
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SnapshotParams'
        required: true
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SnapshotData'
        "404":
          description: Not found
  /rest-api/stream/startRecording:
    post:
      tags:
      - Streaming
      summary: Start stream recording
      description: Start stream recording in specified media session
      operationId: startRecording
      requestBody:
        content:
          application/json:
            schema:
              required:
              - mediaSessionId
              type: object
              properties:
                mediaSessionId:
                  type: string
                  example: b8ffd290-bcfa-11e9-9482-17706e285ec5
                config:
                  $ref: '#/components/schemas/FileRecordConfig'
        required: true
      responses:
        "200":
          description: Successful response
        "404":
          description: Not found
        "500":
          description: Internal server error
  /rest-api/stream/stopRecording:
    post:
      tags:
      - Streaming
      summary: Stop stream recording
      description: Stop stream recording in specified media session
      operationId: stopRecording
      requestBody:
        content:
          application/json:
            schema:
              required:
              - mediaSessionId
              type: object
              properties:
                mediaSessionId:
                  type: string
                  example: b8ffd290-bcfa-11e9-9482-17706e285ec5
        required: true
      responses:
        "200":
          description: Successful response
        "404":
          description: Not found
        "500":
          description: Internal server error
  /rest-api/stream/terminate:
    post:
      tags:
      - Streaming
      summary: Terminate stream
      description: Terminate stream or streams that conforms to query parameters
      operationId: terminate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamFilter'
        required: true
      responses:
        "200":
          description: Successful response
        "404":
          description: Not found
components:
  schemas:
    StreamFilter:
      type: object
      properties:
        custom:
          type: object
          additionalProperties:
            type: object
            example: {}
          example: {}
        nodeId:
          type: string
        appKey:
          type: string
          example: defaultApp
        sessionId:
          type: string
          example: /192.168.1.102:13252/192.168.1.101:8443
        mediaSessionId:
          type: string
          example: 4f112b20-13d0-11e7-b521-59a9cb7eddeb
        name:
          type: string
          example: stream1
        published:
          type: boolean
        status:
          type: string
          enum:
          - NEW
          - PENDING
          - PUBLISHING
          - PLAYING
          - PAUSED
          - UNPUBLISHED
          - STOPPED
          - FAILED
          - RESIZE
          - SNAPSHOT_COMPLETE
          - NOT_ENOUGH_BANDWIDTH
        display:
          type: array
          example:
          - metrics
          items:
            type: string
            example: "[\"metrics\"]"
        customMap:
          type: object
          additionalProperties:
            type: object
            example: {}
          writeOnly: true
          example: {}
    MediaState:
      type: object
      properties:
        muted:
          type: boolean
    StreamInfo:
      type: object
      properties:
        custom:
          type: object
          additionalProperties:
            type: object
            example: {}
          example: {}
        nodeId:
          type: string
        appKey:
          type: string
          example: defaultApp
        sessionId:
          type: string
          example: /192.168.1.102:13252/192.168.1.101:8443
        mediaSessionId:
          type: string
        name:
          type: string
        samplingTime:
          type: integer
          format: int64
        recordTimestamp:
          type: integer
          format: int64
        recordStarted:
          type: boolean
        customMap:
          type: object
          additionalProperties:
            type: object
            example: {}
          writeOnly: true
          example: {}
    StreamObject:
      type: object
      properties:
        custom:
          type: object
          additionalProperties:
            type: object
            example: {}
          example: {}
        nodeId:
          type: string
        appKey:
          type: string
          example: defaultApp
        sessionId:
          type: string
          example: /192.168.1.102:13252/192.168.1.101:8443
        mediaSessionId:
          type: string
          example: 06844ffd-1dce-4a77-a2c2-37629f0e4d13
        remoteMediaElementId:
          type: string
        name:
          type: string
          example: stream1
        published:
          type: boolean
        hasVideo:
          type: boolean
        hasAudio:
          type: boolean
        status:
          type: string
          enum:
          - NEW
          - PENDING
          - PUBLISHING
          - PLAYING
          - PAUSED
          - UNPUBLISHED
          - STOPPED
          - FAILED
          - RESIZE
          - SNAPSHOT_COMPLETE
          - NOT_ENOUGH_BANDWIDTH
        sdp:
          type: string
        audioCodec:
          type: string
          example: opus
        videoCodec:
          type: string
          example: H264
        info:
          type: string
        description:
          type: string
        record:
          type: boolean
        recordName:
          type: string
        width:
          type: integer
          format: int32
        height:
          type: integer
          format: int32
        bitrate:
          type: integer
          format: int64
        minBitrate:
          type: integer
          format: int64
        maxBitrate:
          type: integer
          format: int64
        quality:
          type: integer
          format: int32
        rtmpUrl:
          type: string
        parentMediaSessionId:
          type: string
        timeShift:
          type: integer
          format: int64
        history:
          type: boolean
        gop:
          type: integer
          format: int32
        fps:
          type: integer
          format: int32
        audioBitrate:
          type: integer
          format: int64
        codecImpl:
          type: string
        transport:
          type: string
          example: UDP
        profile:
          type: integer
          format: int32
        level:
          type: integer
          format: int32
        preset:
          type: string
        cvoExtension:
          type: boolean
        profiles:
          type: array
          properties:
            empty:
              type: boolean
          items:
            $ref: '#/components/schemas/VideoStreamProfile'
        watermark:
          type: string
        createDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        mediaType:
          type: string
        audioState:
          $ref: '#/components/schemas/MediaState'
        videoState:
          $ref: '#/components/schemas/MediaState'
        mixerStream:
          type: boolean
        cdnStream:
          type: boolean
        streamInfo:
          $ref: '#/components/schemas/StreamInfo'
        mediaProvider:
          type: string
          example: WebRTC
        lastStatus:
          type: string
          enum:
          - NEW
          - PENDING
          - PUBLISHING
          - PLAYING
          - PAUSED
          - UNPUBLISHED
          - STOPPED
          - FAILED
          - RESIZE
          - SNAPSHOT_COMPLETE
          - NOT_ENOUGH_BANDWIDTH
        authorization:
          type: string
        metrics:
          type: object
          additionalProperties:
            type: number
        publishingStatus:
          type: boolean
        playingStatus:
          type: boolean
        customMap:
          type: object
          additionalProperties:
            type: object
            example: {}
          writeOnly: true
          example: {}
    VideoStreamProfile:
      type: object
      properties:
        width:
          type: integer
          format: int32
        height:
          type: integer
          format: int32
        gop:
          type: integer
          format: int32
        fps:
          type: integer
          format: int32
        bitrate:
          type: integer
          format: int64
        codec:
          type: string
        codecImpl:
          type: string
        quality:
          type: integer
          format: int32
        profile:
          type: integer
          format: int32
        level:
          type: integer
          format: int32
        preset:
          type: string
        audioGroupId:
          type: string
    VideoStreamProfileList:
      type: array
      properties:
        empty:
          type: boolean
      items:
        $ref: '#/components/schemas/VideoStreamProfile'
    Stream:
      type: object
      properties:
        custom:
          type: object
          additionalProperties:
            type: object
            example: {}
          example: {}
        nodeId:
          type: string
        appKey:
          type: string
          example: defaultApp
        sessionId:
          type: string
          example: /192.168.1.102:13252/192.168.1.101:8443
        mediaSessionId:
          type: string
          example: 06844ffd-1dce-4a77-a2c2-37629f0e4d13
        remoteMediaElementId:
          type: string
        name:
          type: string
          example: stream1
        published:
          type: boolean
        hasVideo:
          type: boolean
        hasAudio:
          type: boolean
        status:
          type: string
          enum:
          - NEW
          - PENDING
          - PUBLISHING
          - PLAYING
          - PAUSED
          - UNPUBLISHED
          - STOPPED
          - FAILED
          - RESIZE
          - SNAPSHOT_COMPLETE
          - NOT_ENOUGH_BANDWIDTH
        sdp:
          type: string
        audioCodec:
          type: string
          example: opus
        videoCodec:
          type: string
          example: H264
        info:
          type: string
        description:
          type: string
        record:
          type: boolean
        recordName:
          type: string
        width:
          type: integer
          format: int32
        height:
          type: integer
          format: int32
        bitrate:
          type: integer
          format: int64
        minBitrate:
          type: integer
          format: int64
        maxBitrate:
          type: integer
          format: int64
        quality:
          type: integer
          format: int32
        rtmpUrl:
          type: string
        parentMediaSessionId:
          type: string
        timeShift:
          type: integer
          format: int64
        history:
          type: boolean
        gop:
          type: integer
          format: int32
        fps:
          type: integer
          format: int32
        audioBitrate:
          type: integer
          format: int64
        codecImpl:
          type: string
        transport:
          type: string
          example: UDP
        profile:
          type: integer
          format: int32
        level:
          type: integer
          format: int32
        preset:
          type: string
        cvoExtension:
          type: boolean
        profiles:
          type: array
          properties:
            empty:
              type: boolean
          items:
            $ref: '#/components/schemas/VideoStreamProfile'
        watermark:
          type: string
        createDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        mediaType:
          type: string
        audioState:
          $ref: '#/components/schemas/MediaState'
        videoState:
          $ref: '#/components/schemas/MediaState'
        mixerStream:
          type: boolean
        cdnStream:
          type: boolean
        streamInfo:
          $ref: '#/components/schemas/StreamInfo'
        mediaProvider:
          type: string
          example: WebRTC
        lastStatus:
          type: string
          enum:
          - NEW
          - PENDING
          - PUBLISHING
          - PLAYING
          - PAUSED
          - UNPUBLISHED
          - STOPPED
          - FAILED
          - RESIZE
          - SNAPSHOT_COMPLETE
          - NOT_ENOUGH_BANDWIDTH
        authorization:
          type: string
        publishingStatus:
          type: boolean
        playingStatus:
          type: boolean
        customMap:
          type: object
          additionalProperties:
            type: object
            example: {}
          writeOnly: true
          example: {}
    RestStreamEvent:
      required:
      - payload
      - streamName
      type: object
      properties:
        streamName:
          type: string
          example: test
        payload:
          type: object
          additionalProperties:
            type: object
            example:
              number: 33
              string: hello
              boolean: true
          example:
            number: 33
            string: hello
            boolean: true
    SnapshotParams:
      required:
      - streamName
      type: object
      properties:
        streamName:
          type: string
          example: 64966f33
        persist:
          type: boolean
    SnapshotData:
      type: object
      properties:
        data:
          type: string
          example: iVBORw0KGgoAAAANSUhEUgAAAUAAAADwCAYAAABxLb1rAAAACXBIWXMAAAAAAAAAAQCEeRdzAAAQAElEQVR4nOzd95Pcd37feVjhrFKwXT6fr+r+gPvh6nx1V5bvLMt3liXbkiWtrF1v1O5qVxu4icucwUyABAMIAgSIQOQcBzlnzAADDIDJuadzzjmH173f7+/302l6gO4GiCHIZtWjeqZnejAAu5/9+XzD57tgwYIF6Ojo6PiSmvdfoKOjo2O+zPsv0NHR0TFf5v0X6Ojo6Jgv8/4LdHR0dMyXef8FOjo6OubLvP8CHR0dHfNl3n+Bjo6Ojvky779AR0dHx3yZ91+go6OjY77M+y/Q0dHRMV/m/Rfo6OjomC/z/gt0dHR0zJd5/wU6Ojo65su8/wIdHR0d82Xef4GOjo6O+TLvv0BHR0fHfJn3X6Cjo6Njvsz7L9DR0dExX+b9F+jo6OiYL/P+C3R0dHTMl3n/BTo6Ojrmy7z/Ah0dHR1t+Ue636rzGzr19Tv8jPn/S3R0dHS04z4E8HfR0dHR8XD5DaGC94/rdALY0dHxBXafAlj/wI6OjofPb7foXh//edcJYEfHl4gaCd0tDPXf0+rjHxbNT4F/6/fR0dHxkPsNnhb+DvnNO7zYf1P7nt/8vTYf/3nzj8hvk/+B/GPt76DIfey3dHP8jN/8g/8JHR0dD7d/9Hv/Ixb87j/Hgt/5ZzSt+6dY8D/8Eyz47T+o4Pv4a/Q9v/H7/6L1x3+e8O+m/134d/+tf/Iv8dv/9H/G7/zz/6Xs9/7ZvxS//8/+hfiDP/gD/P7v/z5+7/d+D7/7u7+L3/md3xELVl6PoaOj4
    FileRecordConfig:
      type: object
      properties:
        fileTemplate:
          type: string
          example: "{streamName}-{startTime}-{endTime}"
        rotation:
          type: string
          example: 20M
        seconds:
          type: integer
          format: int64
        megabytes:
          type: integer
          format: int64