Skip to main content
Skip table of contents

Creating an event and reaction

Creating an event and reaction. Users can create specific events and reactions and add them to analytic cases. When the analytics is triggered by an event, the specified reaction will be executed.

POST/api/v1/scripts

Headers

Authorization

Bearer token

Accept

application/json

X-Client

ios-cctv|android-cctv|thick-legal|web

X-UUID

unique device id

Body

json

JSON
{
    "reaction_id": 1,
    "event_id": 1,
    "title": "script",
    "status": "active",
    "cameras": null,
    "users": [
        1
    ],
    "timetable": {
        "days": [
            {
                "type": "same_every_day",
                "from": "00:00:00+05:00",
                "to": "23:59:00+05:00",
                "breaks": [
                    {
                        "from": "16:00:00+05:00",
                        "to": "17:00:00+05:00"
                    }
                ]
            }
        ]
    },
    "extra": {
        "chat_id": "chat_id",
        "bot_token": "bot_token"
    }
}

titlerequired

string

Event and reaction name

reaction_idrequired

int

Reaction ID. The value is taken from the statistics, see Basic Configurations

event_idrequired

int

Event ID. The value is taken from the statistics, see Basic Configurations

usersrequired

array

Array of user IDs to whom the reaction will be sent. Sub-users will receive reactions: show-camera-sidebar, sound, show-camera

statusrequired

array

Event and reaction status. If it is disabled (false), the events will not be processed

timetablerequired

array

Event and reaction working time

timetable.daysrequired

array

Event and reaction schedule

timetable.days.*.typerequired

string

Event and reaction schedule within a single day

timetable.days.*.fromrequired

string

Start time of the event and reaction

timetable.days.*.torequired

string

End time of the event and reaction

timetable.days.*.breaksrequired

array

Time pauses during the event and reaction

timetable.days.*.breaks.*.fromrequired

string

Start time of the event and reaction pause

timetable.days.*.breaks.*.torequired

string

End time of the event and reaction pause

timetable.intervalsrequired

array

Working schedule based on time intervals of the event and reaction

timetable.intervals.*.fromrequired

string

Start date and time of the event and reaction

timetable.intervals.*.torequired

string

End date and time of the event and reaction

extrarequired

array

Data for creating an event and reaction with the «telegram-message» reaction type

extra.bot_tokenrequired

str

Telegram bot token

extra.chat_idrequired

str

Telegram chat ID

Response

201

Returns the event and reaction object

JSON
{
    "id": 1,
    "title": "script",
    "schedule": [],
    "timetable": {
        "days": [
            {
                "to": "23:59:00+05:00",
                "from": "00:00:00+05:00",
                "type": "same_every_day",
                "breaks": [
                    {
                        "to": "17:00:00+05:00",
                        "from": "16:00:00+05:00"
                    }
                ]
            }
        ],
        "intervals": []
    },
    "status": "active",
    "created_at": "2022-04-08 10:30:11",
    "updated_at": "2022-04-08 10:30:11",
    "users": [
        {
            "id": 1,
            "login": "user@mail.com",
            "name": "User name",
            "parent_id": 3,
            "permissions": [
                {
                    "id": 240,
                    "name": "inner_key_name",
                    "display_name": "Permission name for the user"
                }
            ],
            "created_at": "2021-05-27 15:47:57",
            "updated_at": "2022-02-10 12:34:50",
            "online_request_interval": 100,
            "access_token_id": "3zsdfqc32323fbc38cc98e7b",
            "can_update_password": true
        }
    ],
    "event": {
        "id": 1,
        "name": "inner_key_name",
        "description": "Event name",
        "color": "#07D4F0",
        "analytic_type": "analytic_type"
    },
    "reaction": {
        "id": 1,
        "name": "inner_key_name",
        "description": "Event name",
        "is_default": false
    },
    "extra": {
        "chat_id": "chat_id",
        "bot_token": "bot_token"
    }
}
401

Authorization token not provided or invalid, see Obtaining a token

422

Returns a JSON object with an error, see Validation

JSON
{
    "message": "There won't be any informative message here",
    "errors": {
        "any_key": [
            "Here the error cause will be described"
        ]
    }
}

Example

JSON
curl -k --location --request POST 'https://vms.local/api/v1/scripts' \
--header 'Authorization:Bearer token' \
--header 'Accept:application/json' \
--header 'X-Client:ios-cctv|android-cctv|thick-legal|web' \
--header 'X-UUID:unique device id' \
--header 'Content-Type: application/json \
--data-raw '{
    "reaction_id": 1,
    "event_id": 1,
    "title": "script",
    "status": "active",
    "cameras": null,
    "users": [
        1
    ],
    "timetable": {
        "days": [
            {
                "type": "same_every_day",
                "from": "00:00:00+05:00",
                "to": "23:59:00+05:00",
                "breaks": [
                    {
                        "from": "16:00:00+05:00",
                        "to": "17:00:00+05:00"
                    }
                ]
            }
        ]
    },
    "extra": {
        "chat_id": "chat_id",
        "bot_token": "bot_token"
    }
}'
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.