Topics and lessons

How to create an incoming Web API

If you want to provide other people with an API to your Triggre application, you can do so by creating an incoming Web API.

Step 1: Creating the incoming Web API

  1. Create an automation flow with a connection triggre as the start:
  1. Add any properties you want as inputs. Please note you can not use data items, only property types such as text, number and date:
  1. Complete your automation flow and publish your application.

Step 2: Locating your Web API

In order to call your new Web API, you first need to know the URL where it is available. The URL that Triggre generates uses the following template:

  • https://{application}/{environment}/interfaces/rest/{automation flow name}/{automation_flow_name_with_underscores}

Let’s take a look at the following example:

  • Application: example.triggre.net
  • Environment: Lab
  • Flow name: My first incoming Web API

This would mean that Triggre creates an incoming Web API for you on the following URL:

  • https://example.triggre.net/lab/interfaces/rest/my first incoming web api/my_first_incoming_web_api
Tip: The automation flow part of the URLs is case-insensitive (after the /rest/ part), so whether you use capitalized words or not, doesn’t matter.

Step 3: Calling your incoming Web API

To call your Web API, you will need to use a POST request with the data you want to supply as JSON. Make sure to set the Content-Type header of your request to application/json.

Triggre uses Basic Authentication for incoming Web APIs, which means you will need to provide a username and password by sending them in a header:

  • Authentication: Basic Base64Encode("username:password")

For more details on how Basic Authentication works, see this Wikipedia article. To find the connection credentials to use, see our article Finding your connection credentials.

The data you send must be structured as a JSON object. For example, if our incoming Web API has only a single input, a text named Example input then the data you send should look like this:

The incoming Web API will return a status code of 200 on success, and any data you have configured as output as a JSON object as well.

Supported types

Triggre property JSON type
Texts
Any text string
Email string
URL string
Numbers
Number (no decimals) number or string*
Number (1-6 decimals) number or string*
Dates & times
Date string, formatted** as:
- YYYY-MM-DD
- DD-MM-YYYY
- DD/MM/YYYY
- DD.MM.YYYY
Date & time string, formatted** as:
- YYYY-MM-DDThh:mm:ssZ
- YYYY-MM-DDThh:mm:ss+hh:mm
- DD-MM-YYYY hh:mm:ss
- DD/MM/YYYY hh:mm:ss
- DD.MM.YYYY hh:mm:ss
- DD-MM-YYYY, hh:mm:ss
- DD/MM/YYYY, hh:mm:ss
- DD.MM.YYYY, hh:mm:ss
Time of day string, formatted** as: hh:mm
Duration string, formatted** as: hh:mm:ss
Files
Any file object with url*** property, e.g. { "Url": "https://some.file"}
Document object with url*** property, e.g. { "Url": "https://some.document"}
Picture object with url*** property, e.g. { "Url": "https://some.image"}
Other types
True/false boolean
Pick list string, value must correspond to pick list value
*) You can use a string for very large numbers, that are not natively supported. In most cases, just a number will be sufficient.
**) Date time notations used per the W3.org date time standard.
***) Note that the Url property is case sensitive and must start with a capital, then lower case letters.

Example

Below is an example of how to format these types as a single item, and as a list of items: