## Create Subscription

- Creates a subscription. A subsription is used to send a specific set of events defined by subscription attributes to a remote subscriber. A remote subscriber is an http(s) endpoint that can accept the event notification sent from EFC.

- - ###

    Method | POST
    Request URL | /services/EventingConnector/subscriptions
    Request Content-type | application/json
    Request Body | Subscription.json While trying to create a subscription, the callBackUrl is validated by sending a HTTP POST to it with a dummy data. The remote subscriber needs to respond back with a 200 OK
    Response Content-type | application/json
    Response Body | SubscriptionResponse.json
    Response Status | 200 – Successful subscription 400 – Invalid request, callBackUrl invalid/not reachable 500 – Runtime errors

Sample subscription - the remote subscriber endpoint expects events in multipart/form-data format

In this case callbackContentType is optional

    {
        "family":"Call",
        "eventTypes":[
            "CALL_ALERTING",
            "PARTICIPANT_DROPPED"
        ],
        "callbackUrl":"http://example.com:9988",
        "callbackContentType":"multipart/form-data",
        "filter":{
            "user":"someuser",
            "criteria":[
                {
                    "key":"appid",
                    "value":"1234"
                },
                {
                    "key":"appid7",
                    "value":"12347"
                },
            ]
        }
    }

Sample subscription - the remote subscriber endpoint expects events in json format

    {
        "family":"Call",
        "eventTypes":[
            "CALL_ALERTING",
            "PARTICIPANT_DROPPED"
        ],
        "callbackUrl":"http://example.com:9988",
        "callbackContentType":"application/json",
        "filter":{
            "user":"someuser",
            "criteria":[
                {
                    "key":"appid",
                    "value":"1234"
                },
                {
                    "key":"appid7",
                    "value":"12347"
                },
            ]
        }
    }

Sample subscription response

    {
        "subscriptionId":"EventingConnect-PREFERRED-66c5ad968cf52f291452c09b126bf386d17466ea5722ed61439e039423c00dd3",
        "additionalProperties":{}
    }

Subscription.json

    {
        "title":"Subscription",
        "description":"Subscription schema",
        "type":"object",
        "properties":{
            "family":{
                "description":"The family of event",
                "type":"string"
            },
            "eventTypes":{
                "type":"array",
                "eventType":{
                    "type":"string"
                },
                "minItems":0,
                "uniqueItems":true
            },
            "callbackUrl":{
                "description":"endpoint of the listener",
                "type":"string"
            },
            "callbackContentType":{
                "description":"content-type of the event to be sent to endpoint of the listener, options [multipart/form-data, application/json]. Default is multipart/form-data",
                "type":"string"
            },
            "filter":{
                "description":"filters on metadata",
                "type":"object",
                "properties":{
                    "correlationId":{
                        "type":"string"
                    },
                    "user":{
                        "type":"string"
                    },
                    "serviceProfile":{
                        "type":"string"
                    },
                    "criteria":{
                        "id":"criteria",
                        "type":"array",
                        "items":{
                            "$ref":"#/criterion"
                        },
                        "additionalItems":false
                    },
                    "ignoreCaseCriteria":{
                        "id":"ignoreCaseCriteria",
                        "type":"array",
                        "items":{
                            "$ref":"#/criterion"
                        },
                        "additionalItems":false
                    }
                }
            }
        },
        "criterion":{
            "id":"items",
            "type":"object",
            "properties":{
                "key":{
                    "id":"key",
                    "type":"string"
                },
                "value":{
                    "id":"value",
                    "type":"string"
                }
            },
            "additionalProperties":false
        }
    }

SubscriptionResponse.json

    {
        "title":"SubscriptionResponse",
        "description":"Response object of subscription from EFC",
        "type":"object",
        "properties":{
            "subscriptionId":{
                "type":"string",
                "description":"ID of the subscription"
            },
            "message":{
                "type":"string"
            }
        }
    }

Copyright © 2017 Avaya. All Rights Reserved.