openapi: 3.0.0
info:
  title: Event Subscription
  contact: {}
  version: '1.0'
servers:
  - url: 'https://api.zebra.com/v2/devices/readers/event'
    variables: {}
paths:
  /subscription:
    get:
      summary: Retrieves all subscriptions
      tags:
        - Event Subscription
      operationId: Retrieve_Subscriptions
      description: Retrieves all RFID event webhook subscriptions
      parameters:
        - schema:
            type: string
          in: header
          name: tenant
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Subscription'
              examples:
                example-1:
                  value:
                    - userTags:
                        - string
                      changeFields:
                        - string
                      deviceIdentifiers:
                        - string
                      jqFilters:
                        decodeData: .epc == "016500041085000000000000"
                      webhookUrl: string
                      webhookVerb: string
                      id: string
    post:
      summary: Creates a subscription
      tags:
        - Event Subscription
      operationId: Create_Subscription
      responses:
        '200':
          $ref: '#/components/responses/valid'
      description: Creates an RFID event webhook subscription and starts the webhook
      parameters:
        - schema:
            type: string
          in: header
          name: tenant
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Create'
          application/javascript:
            schema:
              $ref: '#/components/schemas/Create'
        description: Subscription for an RFID event webhook
  '/subscription/{subscriptionId}':
    parameters:
      - schema:
          type: string
        name: subscriptionId
        in: path
        required: true
    get:
      summary: Retrieves a subscription
      tags:
        - Event Subscription
      responses:
        '200':
          $ref: '#/components/responses/valid'
      operationId: Retrieve_Subscription_By_ID
      description: Retrieves an RFID event webhook subscription by Subscription ID
      parameters:
        - schema:
            type: string
          in: header
          name: tenant
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
    put:
      summary: Updates a subscription
      tags:
        - Event Subscription
      operationId: Update_Subscription_By_ID
      responses:
        '200':
          $ref: '#/components/responses/valid'
      parameters:
        - schema:
            type: string
          in: header
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
          name: tenant
      description: Updates an RFID event webhook subscription by Subscription ID
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Create'
        description: Subscription for an RFID even webhook
    delete:
      summary: Deletes a subscription
      tags:
        - Event Subscription
      operationId: Delete_Subscriptions_By_ID
      responses:
        '200':
          description: OK
      parameters:
        - schema:
            type: string
          in: header
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
          name: tenant
      description: Deletes an RFID event webhook subscription by Subscription ID
  '/subscription/{subscriptionId}/start':
    parameters:
      - schema:
          type: string
        name: subscriptionId
        in: path
        required: true
    post:
      summary: Starts a subscription
      tags:
        - Event Subscription
      operationId: Start_Subscription_By_ID
      responses:
        '200':
          description: OK
      description: Starts sending notifications for an RFID event webhook subscription
      parameters:
        - schema:
            type: string
          in: header
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
          name: tenant
  '/subscription/{subscriptionId}/stop':
    parameters:
      - schema:
          type: string
        name: subscriptionId
        in: path
        required: true
    post:
      summary: Stops a subscription
      tags:
        - Event Subscription
      operationId: Stops_Subscription_by_ID
      responses:
        '200':
          description: OK
      description: Stop sending notifications for an RFID event webhook subscription
      parameters:
        - schema:
            type: string
          in: header
          description: 'The tenant account number. See the [Tenant Service API](https://developer.zebra.com/apis/review-savanna-tenant-service) to get your tenant account number.'
          name: tenant
components:
  schemas:
    JqFilters:
      title: JqFilters
      type: object
      example:
        decodedTagData: .event.data.id == "016500041085000000000000"
      properties:
        decodedTagData:
          type: string
          description: 'See details of JQ filters at [Webhook Filtering Using jq](https://developer.zebra.com/docs/webhook-filter)'
      required:
        - decodedTagData
    Subscription:
      title: Subscription
      type: object
      properties:
        userTags:
          type: array
          description: Device grouped tags (not used)
          items:
            type: string
          example:
          - demo
          - IL Office
        changeFields:
          type: array
          description: 'Current Options: decodedTagData, rawData. Default: decodedTagData'
          items:
            type: string
            example:
            - decodedTagData
        headers:
          type: string
          example: "{'apikey': 'abc12345','tenant': '12345abc'}"
        jqTransform:
          type: string
          example: {"decodedTagData": "{device: .event.deviceId, timestamp: .event.timestamp, value: .event.data.id, type: .type, format: .event.data.format, rssi: .event.data.rssi, antenna: .event.data.antennaId}"}  
        deviceIdentifiers:
          type: array
          description: 'List serial numbers for devices. Do not enter this to take all devices, Enter a blank string to take no devices.'
          items:
            type: string
          example:
          - RFID123456789
        jqFilters:
            $ref: '#/components/schemas/JqFilters'
        webhookUrl:
          type: string
          description: The URL of your server endpoint.
          example: 'https://test.com/myendpoint'
        webhookVerb:
          type: string
          description: 'Options: POST, PUT.  Default: POST'
          example: POST
        id:
          type: string
          example: B5JD07WPJ3BDVXRR
      required:
        - webhookUrl
    Create:
      description: ''
      type: object
      properties:
        userTags:
          type: array
          description: Device grouped tags (not used)
          items:
            type: string
          example: 
          - demo
          - IL Office
        changeFields:
          type: array
          description: 'Current Options: decodedTagData, rawData. Default: decodedTagData'
          items:
            type: string
          example:
          - decodedTagData
        headers:
          type: string
          example: {"apikey": "abc12345","tenant": "12345abc"}
        deviceIdentifiers:
          type: array
          description: 'List serial numbers for devices. Default: All enrolled devices. Enter a blank string to take no devices.'
          items:
            type: string
          example: 
          - RFID123456789
        jqFilters:
            $ref: '#/components/schemas/JqFilters'
        jqTransform:
          type: string
          example: {"decodedTagData": "{device: .event.deviceId, timestamp: .event.timestamp, value: .event.data.id, type: .type, format: .event.data.format, rssi: .event.data.rssi, antenna: .event.data.antennaId, myData: \"myvalue\"}"}
        webhookUrl:
          type: string
          minLength: 1
          description: The URI of your server endpoint.
          example: 'https://test.com/myendpoint'
        webhookVerb:
          type: string
          minLength: 1
          description: 'Options: POST, PUT.  Default: POST'
          example: POST
      required:
        - webhookUrl
  securitySchemes:
    apikey:
      name: apikey
      type: apiKey
      in: header
      description: Your Zebra Savanna application key for usage of this API. See the Getting Started Guide for more details.
    Authorization:
      type: http
      scheme: bearer
      description: 'Authentication bearer token. Example: Bearer AbcdEFGHIJKL123456780123ABCD'
  responses:
    valid:
      description: Example response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Subscription'
          examples:
            example-1:
              value:
                userTags:
                  - demo
                  - IL Office
                changeFields:
                  - decodedTagData
                deviceIdentifiers:
                  - RFID123456789
                jqFilters:
                  decodedTagData: ".event.data.id == \"016500041085000000000000\""
                webhookUrl: 'https://test.com/myendpoint'
                webhookVerb: POST
                id: B5JD07WPJ3BDVXRR
security:
  - apikey: []
  - Authorization: []  
tags:
  - name: Event Subscription