Using triggers


info

This page will take you through what endpoints are involved in discovering and using triggers and their operations.

Discovering triggers

The Get triggers endpoint will return all of the triggers that you have access to:

The response includes:

  • trigger name
  • trigger version

These can then be used with the Get trigger operations endpoint to list the available operations within a particular trigger.

So if your organization has access to Calendly and Typeform you would see the following:

Copy
Copied
{
    "elements": [
        {
            "name": "calendly-trigger",
            "version": "3.0",
            "title": "Calendly",
            "description": "Calendly helps you schedule meetings without the back-and-forth emails.",
            "service": {
                "id": "8e1e2aa9-877b-4710-9acb-5c8ff9dd8059",
                "name": "calendly",
                "version": 2
            }
        },
        {
            "name": "typeform-trigger",
            "version": "4.1",
            "title": "Typeform",
            "description": "Typeform is an online software as a service company that specializes in online form building and online surveys.",
            "service": {
                "id": "668f2ac5-2b44-41c5-a751-4a9773982c3e",
                "name": "typeform",
                "version": 3
            }
        }
    ]
}

Discovering operations

The operations available within a trigger can be identified using the Get trigger operations endpoint.

So for Calendly the URL would be:

https://api.tray.io/core/v1/triggers/calendly-trigger/versions/3.0/operations

In the following sample response for Calendly, we have shown only the input schema for the webhook operation.

Copy
Copied
{
    "elements": [
        {
            "name": "webhook",
            "title": "Webhook",
            "description": "Receive Calendly appointment data in real-time. (Invitee Created Event & Invitee Canceled Events)",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "events": {
                        "type": "array",
                        "description": "List of user events to subscribe to.",
                        "title": "Events",
                        "items": {
                            "type": "string",
                            "enum": [
                                {
                                    "text": "Invitee Created Events",
                                    "value": "invitee.created"
                                },
                                {
                                    "text": "Invitee Canceled Events",
                                    "value": "invitee.canceled"
                                }
                            ],
                            "description": "Event to subscribe to.",
                            "title": "Item"
                        },
                        "additionalItems": true
                    },
                    "scope": {
                        "type": "string",
                        "enum": [
                            {
                                "text": "Organization",
                                "value": "organization"
                            },
                            {
                                "text": "User",
                                "value": "user"
                            }
                        ],
                        "default": "organization",
                        "description": "Indicates if the webhook subscription scope will be 'Organization' or 'User'.",
                        "title": "Scope"
                    },
                    "organization_uri": {
                        "type": "string",
                        "title": "Organization URI",
                        "description": "The unique reference to the organization that the webhook will be tied to."
                    },
                    "user_uri": {
                        "type": "string",
                        "title": "User URI",
                        "description": "The unique reference to the user that the webhook will be tied to. Required if 'Scope' is set to 'User'."
                    },
                    "public_url": {
                        "type": "string",
                        "default_jsonpath": "$.env.public_url",
                        "title": "Public URL"
                    }
                },
                "required": [
                    "events",
                    "scope",
                    "organization_uri",
                    "public_url"
                ],
                "advanced": [
                    "public_url"
                ],
                "$schema": "http://json-schema.org/draft-04/schema#",
                "additionalProperties": false
            },
            "authScopes": []
        }
    ]
}

The Trigger details (name and version) and operation deatils (name, inputSchema) are essential in forming the request payload for Create Subscription call.