Tray Platform / Connectivity APIs / Using connectors and operations

Using connectors and operations

Discovering connectors

The Get Connectors (https://api.tray.io/core/v1/connectors) endpoint will return all of the connectors that you have access to:

The response includes:

  • connector name

  • connector version

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

So if your organisation has access to Outreach and Twilio you would see the following:

{
"elements": [
{
"name": "outreach",
"version": "3.2",
"title": "Outreach",
"description": ""
},
{
"name": "twilio-output",
"version": "2.1",
"title": "Twilio",
"description": "Cloud communication platform for developers"
}
]
}

Discovering operations

The operations available within a connector can be identified using the Get Connector Operations endpoint.

So for Twilio the URL would be:

https://api.tray.io/core/v1/connectors/twilio-output/versions/2.1/operations

In the following sample response for Twilio, we have shown only the input schema for the 'Send SMS' operation.

Please see the Get Connector Operations endpoint for complete examples of operation lists and input and output schema:

{
"elements": [
{
"name": "send_sms",
"title": "Send SMS",
"description": "Send SMS.",
"inputSchema": {
"$schema": "https://api.tray.io/core/v1/connectors/operations/input-schema#",
"advanced": [],
"additionalProperties": false,
"type": "object",
"properties": {
"body": {
"type": "string",
"description": "The body of the SMS to send.",
"title": "Body"
},
"media_url": {
"type": "string",
"title": "Media URL",
"description": "This parameter specifies the URL of the media you want to include with your message, for sending an MMS message."
},
"to": {
"type": "string",
"description": "The phone number (including international code) to send the sms to.",
"title": "To"
},
"from": {
"type": "string",
"description": "The valid Twilio number (or authorised number) from which the sms message will appear.",
"title": "From"
},
"status_callback": {
"type": "string",
"title": "Status callback URL",
"description": "By including a StatusCallback URL in your API call, you can tell Twilio where to POST information about your message."
}
},
"required": [
"to",
"from",
"body"
]
},
"hasDynamicOutput": false,
"authScopes": []
}
]
}

Using operations

Connectors can be called using the Call Connector endpoint:

So to call the Twilio connector the following URL would be used:

https://api.tray.io/core/v1/connectors/twilio-output/versions/2.1/call

The body needs to contain:

  • The operation that is being called

  • The authId that was obtained earlier as part of the auth flow

  • The required inputs as dictated by the input schema

The following screenshot demonstrates how to use the above Twilio input schema to construct a call:

twilio-send-sms

Please see the previous section for guidance on obtaining the required authId for the End User.

The response from call connector will be in accordance with the output schema obtained in the connector operations step.