Call Connector

Invoke any operation from any Tray connector

Call a Tray connector

post/

This mutation can be used to call a specific connector operation.

This powerful feature is used in combination with a User Token and Authentication Id, to pull data from a particular service connector operation and display it in your app.

As an example, for a particular End User of your Embedded application, you could use it to display all of the 'Warm' Salesforce Leads assigned to them, or display all the customers with overdue payments.

Check out the Operations explorer app which will help you to figure out the input for any connector/any operation.

The tool also gives insight into the output schema for those operations, which will help you process the result.

Please see full instructions for using this endpoint at Using the call connector API from main docs.

Required token Notes
User or Master Obtained after using Users/Mutations/Create User Token.
The User Token is a persistent token that should be securely stored in your application for future use (expires after 2 days)

The mutation accepts the following arguments:

Input Required Note
connector Yes The programatic connector name. Obtained from the workflow builder, see example below
version Yes The version of the connector being used. Obtained from inspecting the Advanced settings of the input panel in the workflow builder, see example below
operation Yes The programmatic name of the operation. This is usually the name of the operation visible in the workflow builder input panel, converted to snake case. Please reach out to support@tray.io if you get the error message The connector operation ### was not found
authId Yes see prerequisites below on obtaining an authId
input Yes The stringified JSON body representing the input parameters to the operation. You can explore the input schema for all connectors and their operations' in the Operations explorer app.
clientMutationId No Only relevant if using the Relay GraphQL client

Here is a sample mutation:

Call connector - Get all leads in Salesforce
mutation {
    callConnector(input: {
        connector: "salesforce",
        version: "8.1",
        operation: "get_records",
        authId: "########-####-####-####-############",
        input: "{\\"limit\\":10,\\"conditions_type\\":\\"Match all conditions\\",\\"fields\\":[\\"Id\\",\\"Name\\"],\\"object\\":\\"Lead\\"}"
        }) 
    {
        output
    }
}

It returns the following data:

Returned Data Notes
output The stringified JSON body representing the data returned from the connector
clientMutationId Only relevant if using the Relay GraphQL client

Named requests (Aliases)

GraphQL provides the capability to send multiple mutations at once. If you need to use the same mutation multiple times, you can use aliases (avoid any duplicate names).

Here is an example mutation with two mutations merged into one using aliases listAllLeads and listWarmLeads.

Multiple connector calls in one
mutation callSalesforce {
    listAllLeads: callConnector(input: {
        connector: "salesforce",
        version: "4.0",
        operation: "find_records",
        authId: "########-####-####-####-############",
        input: "{\\"limit\\":10,\\"conditions_type\\":\\"Match all conditions\\",\\"fields\\":[\\"Id\\",\\"Name\\"],\\"object\\":\\"Lead\\"}"
        }) {
        output
    },
    listWarmLeads: callConnector(input: {
        connector: "salesforce",
        version: "4.0",
        operation: "find_records",
        authId: "########-####-####-####-############",
        input: "{\\"conditions_type\\":\\"Match all conditions\\",\\"fields\\":[\\"Id\\",\\"Name\\"],\\"conditions\\":[{\\"field\\":\\"Rating\\",\\"operator\\":\\"Equal to\\",\\"value\\":\\"Warm\\"}],\\"object\\":\\"Lead\\"}"
        }) {
        output
    }
}
SecuritybearerAuth
Request
Responses
200

OK - Response of the connector operation is returned

401

Unauthorized

403

Forbidden

500

Internal Error

Request samples
curl -i -X POST \
  https://tray.io/graphql \
  -H 'Authorization: Bearer <MASTER_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "mutation listLeads(\n  $connector: String!, \n  $version: String!, \n  $operation: String!, \n  $authId: String, \n){ listAllLeads: callConnector(input: {\n    connector: $connector,\n    version: $version,\n    operation: $operation,\n    authId: $authId,\n    input: \"{\\\"limit\\\":10,\\\"conditions_type\\\":\\\"Match all conditions\\\",\\\"fields\\\":[\\\"Id\\\",\\\"Name\\\"],\\\"object\\\":\\\"Lead\\\"}\"\n  }) {\n    output\n  }\n}",
    "variables": {
      "connector": "salesforce",
      "version": "8.7",
      "operation": "find_records",
      "authId": "062af7e2-b5xxx-xxx-xxx-xxx-xxxxx46d912"
    }
  }'
Response samples
application/json
{
  • "data": {
    • "listObjects": {
      • "output": "{\"total\":10,\"next_page_offset\":null,\"records\":[{\"Id\":\"00Q8d000005HrKQEA0\",\"Name\":\"Mike Braund\"},{\"Id\":\"00Q8d000005HrKNEA0\",\"Name\":\"Bertha Boxer\"},{\"Id\":\"00Q8d000005HrKOEA0\",\"Name\":\"Phyllis Cotton\"},{\"Id\":\"00Q8d000005HrKPEA0\",\"Name\":\"Jeff Glimpse\"},{\"Id\":\"00Q8d000005HrKREA0\",\"Name\":\"Patricia Feager\"},{\"Id\":\"00Q8d000005HrKVEA0\",\"Name\":\"Tom James\"},{\"Id\":\"00Q8d000005HrKSEA0\",\"Name\":\"Brenda Mcclure\"},{\"Id\":\"00Q8d000005HrKTEA0\",\"Name\":\"Violet Maccleod\"},{\"Id\":\"00Q8d000005HrKUEA0\",\"Name\":\"Kathy Snyder\"},{\"Id\":\"00Q8d000005HrKWEA0\",\"Name\":\"Shelly Brownell\"}]}"
      }
    }
}