This article is meant to describe how to integrate Content Triggers App with an external system to programmatically push content to screens.


Firstly, if you need to learn how does the Content Triggers App work, you can go to this article.


For this article, we will be using Postman as an external tool to represent a piece of software that will integrate with Nowsignage.


API endpoint


The API is open for POST requests to the following URL:

https://api.nowsignage.com/v2/apps/triggers/events

This endpoint accepts a parameter called trigger, which will send the command key defined in the Triggers App within the CMS. A complete POST request with a trigger parameter will look like the following:

https://api.nowsignage.com/v2/apps/triggers/events?trigger=my_command


Authorization


The request is authorized by using an API key as a bearer token.

The API key can be found in your Nowsignage account (https://secure.nowsignage.com/admin/api_keys) and it must be set with Read/Write access.


To do this, go into 'My Account' > 'API Keys' then '+Generate API Key' to create a new API Key (you can label this Triggers API Key).

Once created, click on options button (...) to the right of the API key and then select the option to 'Set Read & Write Access':



Response


Depending on the evaluation of the request by Nowsignage, it can respond with different data


Successful request


Status code: 200 OK


Structure:

{
    "trigger": "my_command",
    "rules_triggered": {
        "screen_id": {
            "trigger_command": "my_command", (string)
            "playlist": playlist_id, (integer)
            "screens": [screen_ids] (array)
        }
    },
    "screens": {
        "screen_pin": {
            "name": "Screen name", (string)
            "pin": "screen_pin" (string)
        }
    }
}


Example with data from a real response:

{
    "trigger": "open",
    "rules_triggered": {
        "10": {
            "trigger_command": "open",
            "playlist": 11713,
            "screens": [
                9849
            ]
        },
        "14": {
            "trigger_command": "open",
            "playlist": 6,
            "screens": [
                3,
                10
            ]
        }
    },
    "screens": {
        "80531": {
            "name": "Main (Trigger Test)",
            "pin": "80531"
        },
        "35779": {
            "name": "Red screen",
            "pin": "35779"
        },
        "68308": {
            "name": "Meeting Room",
            "pin": "68308"
        },
    }
}



No trigger commands found


Status code: 404 Not Found

{
    "errors": [
        "Requested record was not found"
    ]
}


Not authorized - Wrong API key


Status code: 401 Unauthorized

{
    "errors": [
        "Api Key is invalid"
    ]
}


Not authorized - API key missing


Status code: 401 Unauthorized

{
    "errors": [
        "No authentication token provided"
    ]
}


API key not set as Read/Write


Status code: 403 Forbidden

{
    "errors": [
        "The API key provided does not allow read/write access."
    ]
}