Triggers
Get Triggers
Query triggers
allows to get a list of triggers for creating notifications. Triggers are related to the endpoints where notifications will be sent to.
triggers(filter: JSON = null
ids: [ID] = null
limit: Int = null
offset: Int = null
order: [String] = null
targetId: ID = null
withArchived: WithArchived = null): TriggerCollection!
filter: JSON
: You can filter a list of triggers by specifying one or several endpoints:
creation_date
: Exact trigger creation date in ISO 8601 formatendpoints
: Linked endpoint IDid
: ID assigned to a trigger from the databaseis_active
:last_modified
: Exact date of the last trigger modification in ISO 8601 formatmeta
:workspace
: Workspace IDworkspace_id
: Workspace ID
ids: [ID]
: To get a list of certain triggers, specify their IDs in the list.
limit: Int
: The parameter allows to get the first n
triggers from the list.
offset: Int
: The parameter allows to remove the first n
triggers from the list.
order: [String]
: You can sort a list by specifying the value for the following parameters: creation_date
, endpoints
, id
, is_active
, last_modified
, meta
, workspace
, workspace_id
targetId: ID
: ID assigned to a group which the trigger is linked to
withArchived: WithArchived
: To get all triggers, including the archived ones, specify all
. To get only archived triggers, specify archived
.
TriggerCollection!
: The query result is a list of triggers that contains the following parameters:
totalCount: Int
: Number of returned triggerscollectionItems: [TriggerType!]!
:id: ID!
: Trigger IDcreationDate: DateTime!
: Trigger creation date in ISO 8601 formatlastModified: DateTime!
: Last trigger modification date in ISO 8601 formatmeta: Meta!
: Trigger meta-informationendpoints: [EndpointOutput!]!
: List of endpoints linked to a triggerarchived: Boolean!
: Attribute that a trigger is archived.
Example Request:
{
triggers(ids: ["3e57a95e-028c-4d27-9419-a9c4bfd6f3fb"]) {
totalCount
collectionItems {
id
creationDate
lastModified
meta {
notificationParams
conditionLanguage {
condition
variables {
name
target {
type
uuid
}
type
}
}
}
endpoints {
id
}
archived
}
}
}
Example Response:
API returns the following result:
{
"data": {
"triggers": {
"totalCount": 1,
"collectionItems": [
{
"id": "3e57a95e-028c-4d27-9419-a9c4bfd6f3fb",
"creationDate": "2022-07-07T08:38:22.982190+00:00",
"lastModified": "2022-07-08T05:03:48.961423+00:00",
"meta": {
"notificationParams": "{\"lifetime\": 5}",
"conditionLanguage": {
"condition": null,
"variables": [
{
"name": "0_v",
"target": [
{
"type": "Label",
"uuid": "edbb2c49-bacc-4b43-aac8-e06fd3da35eb"
}
],
"type": "presence"
}
]
}
},
"endpoints": [
{
"id": "db38ec53-c09d-45f2-bfed-5877c9bd9016"
}
],
"archived": false
}
]
}
}
}
Create a Trigger for a Profile Group
Mutation createProfileGroupTrigger
allows to create a new trigger for a profile group. Everytime the camera detects a person from this group, the system creates a notification.
createProfileGroupTrigger(endpointAliases: [DefaultAlias!] = null
endpointIds: [ID!] = null
endpointUrl: String = null
profileGroupId: ID!): TriggerManageOutput!
endpointAliases: [DefaultAlias!]
: You can submit OWNER_EMAIL
or WEB_INTERFACE
. In this case one of endpoints with the same value for parameter defaultAlias
will be linked to a trigger.
endpointIds: [ID!]
: You can submit a list of IDs assigned to endpoints which are linked to a trigger.
endpointUrl: String
: You can submit URL to your webhook. This will create a new endpoint for sending notifications to your URL address.
profileGroupId: ID!
: Group ID necessary for creating a trigger.
TriggerManageOutput!
: The mutation result is JSON that contains the following parameters:
ok: Boolean!
: Attribute that mutation is successfully completedtrigger: TriggerType!
: New trigger object
Incorrect input errors:
- Profile group not found by transmitted id:
{
"message": "Label matching query does not exist."
}
- Endpoint not found by transmitted id:
{
"message": "Endpoint does not exist."
}
Example Request:
mutation{
createProfileGroupTrigger(profileGroupId: "800f0b65-7dbe-42b2-8f66-89af95a734e7", endpointIds: ["afd7c121-3140-4a8c-b0ee-3717581eb76d"]) {
trigger {
endpoints {
id
}
id
}
}
}
Example Response:
API returns the following result:
{
"data": {
"createProfileGroupTrigger": {
"trigger": {
"endpoints": [
{
"id": "afd7c121-3140-4a8c-b0ee-3717581eb76d"
}
],
"id": "9675aede-3ee8-495b-ac8b-e284a07db99e"
}
}
}
}
Update a Trigger
Mutation updateTrigger
allows to update endpoints linked to a trigger. List of linked endpoints is replaced by the new one.
updateTrigger(endpointAliases: [DefaultAlias!] = null
endpointIds: [ID!] = null
triggerId: ID!): TriggerManageOutput!
endpointAliases: [DefaultAlias!]
: You can submit OWNER_EMAIL
or WEB_INTERFACE
. In this case one of endpoints with the same value in parameter defaultAlias
will be linked to a trigger.
endpointIds: [ID!]
: You can submit a list of IDs assigned to endpoints which will be linked to a trigger.
triggerId: ID!
: Trigger ID
TriggerManageOutput!
: The mutation result is JSON that contains the following parameters:
ok: Boolean!
: Attribute that mutation is successfully completedtrigger: TriggerType!
: Updated trigger object
Incorrect input errors:
- Trigger not found by passed id:
{
"message": "Trigger matching query does not exist."
}
- Endpoint not found by transmitted id:
{
"message": "Endpoint does not exist."
}
Example Request:
mutation{
updateTrigger(
triggerId: "64e0a7ec-0df4-4734-a460-601fa1b65a1f",
endpointIds: ["6e5a6d3b-8247-488e-95d7-57a306b294ed"],
endpointAliases: OWNER_EMAIL) {
ok
trigger {
id
endpoints {
id
defaultAlias
}
}
}
}
Example Response:
API returns the following result:
{
"data": {
"updateTrigger": {
"ok": true,
"trigger": {
"id": "64e0a7ec-0df4-4734-a460-601fa1b65a1f",
"endpoints": [
{
"id": "6e5a6d3b-8247-488e-95d7-57a306b294ed",
"defaultAlias": null
},
{
"id": "6fd67f81-a195-442b-a991-1a0eca6bbb69",
"defaultAlias": "OWNER_EMAIL"
}
]
}
}
}
}
Link an Endpoint to a Trigger
Mutation linkEndpoint
allows to link endpoint to trigger. The endpoint is to be added to a list of endpoints linked to the trigger.
linkEndpoint(endpointAliases: [DefaultAlias!] = null
endpointIds: ID! = null
triggerId: ID!): MutationResult!
endpointAliases: [DefaultAlias!]
: You can submit OWNER_EMAIL
or WEB_INTERFACE
. In this case one of endpoints with the same value for parameter defaultAlias
will be linked to a trigger.
endpointIds: ID!
: You can submit ID assigned to an endpoint that will be linked to a trigger.
triggerId: ID!
: Trigger ID
MutationResult!
: The mutation result is JSON that contains the following parameters:
ok: Boolean!
: Attribute that mutation is successfully completed
Incorrect input errors:
- Endpoint id for binding to a trigger has not been passed:
{
"message": "Unknown exception code for 'bad_input_data' type",
"code": "No id or alias provided"
}
- Endpoint not found by transmitted id:
{
"message": "Endpoint matching query does not exist."
}
- Trigger not found by passed id:
{
"message": "Trigger matching query does not exist."
}
Example Request:
mutation{
linkEndpoint(triggerId: "64e0a7ec-0df4-4734-a460-601fa1b65a1f", endpointAlias: WEB_INTERFACE) {
ok
}
}
Example Response:
API returns the following result:
{
"data": {
"linkEndpoint": {
"ok": true
}
}
}
Unlink an Endpoint from a Trigger
Mutation unlinkEndpoint
is used to unlink endpoint from trigger. The endpoint is removed from a list of endpoints linked to the trigger.
unlinkEndpoint(endpointAliases: [DefaultAlias!] = null
endpointIds: ID! = null
triggerId: ID!): MutationResult!
endpointAliases: [DefaultAlias!]
: You can submit OWNER_EMAIL
or WEB_INTERFACE
. In this case one of endpoints with the same value for parameter defaultAlias
is removed from a list of endpoints linked to this trigger.
endpointIds: ID!
: You can submit ID of an endpoint to be removed from a list of endpoints linked to this trigger.
triggerId: ID!
: Trigger ID
MutationResult!
: The mutation result is JSON that contains the following parameters:
ok: Boolean!
: Attribute that mutation is successfully completed.
Incorrect input errors:
- Endpoint id to unlink from the trigger has not been passed:
{
"message": "Unknown exception code for 'bad_input_data' type",
"code": "No id or alias provided"
}
- Endpoint not found by transmitted id:
{
"message": "Endpoint matching query does not exist."
}
- Trigger not found by passed id:
{
"message": "Trigger matching query does not exist."
}
Example Request:
mutation{
unlinkEndpoint(triggerId: "64e0a7ec-0df4-4734-a460-601fa1b65a1f", endpointAlias: WEB_INTERFACE) {
ok
}
}
Example Response:
API returns the following result:
{
"data": {
"unlinkEndpoint": {
"ok": true
}
}
}
Delete a Trigger
Mutation deleteTrigger
allows to delete a trigger.
deleteTrigger(triggerId: ID!): MutationResult!
triggerId: ID!
: Trigger ID
MutationResult!
: The mutation result is JSON that contains the following parameters:
ok: Boolean!
: Attribute that mutation is successfully completed.
Incorrect input errors:
- Trigger not found by passed id:
{
"message": "Trigger matching query does not exist."
}
Example Request:
mutation{
deleteTrigger(triggerId: "64e0a7ec-0df4-4734-a460-601fa1b65a1f") {
ok
}
}
Example Response:
API returns the following result:
{
"data": {
"deleteTrigger": {
"ok": true
}
}
}