Workflows

Workflow represent a set of connector steps in Tray that perform a task.

Import Workflows (master token)

post/

The importWorkflows mutation can be used to import the workflow to your embedded account. This is handy when you want to import workflows to your 'production' account from 'staging'.

Note that it is possible to import multiple workflows (you would have to ensure that the workflows and workflowIds are listed in the exact same order in exportedWorkflowsJson and targetWorkflowIds - to make sure the correct workflow is imported to the correct target workflow)

However if you are working with multiple workflows, it is more likely that you will be importing a project.

Required token Notes
Master Obtained from the Tray app UI. Refer this.

The mutation accepts the following arguments:

Argument Required Note
exportedWorkflowsJson Yes Can be obtained either by exporting workflow json from UI or using the exportWorkflows mutation (refer below)
The JSON must be stringified.
targetWorkflowIds Yes Array of workflow IDs
Workflow ID can be obtained from the url of target workflow page: https://app.tray.io/workflow/{workflowId}
clientMutationId No Only relevant if using the Relay GraphQL client

Here is an example mutation:

Import Project
mutation {
    importWorkflows (input: {
        exportedWorkflowsJson: "{\"tray_export_version\":4,\"export_type\":\"workflow\",\"workflows\":[{\"id\":\"ea3c20f5-xxxx-xxxx-xxxx-0ce2b7bb9f29\",\"created\":\"2023-05-15T11:26:14.794686Z\",\"workspace_id\":\"6c595d5b-xxxx-xxxx-xxxx-959ceb938eae\",\"creator\":\"6a4e56d9-xxxx-xxxx-xxxx-2429f79b40ff\",\"version\":{\"id\":\"018cc858-xxxx-xxxx-xxxx-2c8cfe0a7886\",\"created\":\"2023-05-16T22:25:42.413825Z\"},\"title\":\"webhook slack\",\"enabled\":false,\"tags\":[],\"settings\":{\"config\":{},\"input_schema\":{},\"output_schema\":{}},\"steps_structure\":[{\"name\":\"trigger\",\"type\":\"normal\",\"content\":{}}],\"steps\":{\"trigger\":{\"title\":\"Webhook\",\"connector\":{\"name\":\"webhook\",\"version\":\"2.3\"},\"operation\":\"fire_and_forget\",\"output_schema\":{},\"error_handling\":{},\"properties\":{}}},\"dependencies\":[]}],\"projects\":[]}",
        targetWorkflowIds: ["e5dc0748-xxxx-xxxx-xxxx-dfcc33795f12"]
        }) {
      clientMutationId
    }
}
Import Project with clientMutationId
mutation {
    importWorkflows (input: {
        exportedWorkflowsJson: "{\"tray_export_version\":4,\"export_type\":\"workflow\",\"workflows\":[{\"id\":\"ea3c20f5-xxxx-xxxx-xxxx-0ce2b7bb9f29\",\"created\":\"2023-05-15T11:26:14.794686Z\",\"workspace_id\":\"6c595d5b-xxxx-xxxx-xxxx-959ceb938eae\",\"creator\":\"6a4e56d9-xxxx-xxxx-xxxx-2429f79b40ff\",\"version\":{\"id\":\"018cc858-xxxx-xxxx-xxxx-2c8cfe0a7886\",\"created\":\"2023-05-16T22:25:42.413825Z\"},\"title\":\"webhook slack\",\"enabled\":false,\"tags\":[],\"settings\":{\"config\":{},\"input_schema\":{},\"output_schema\":{}},\"steps_structure\":[{\"name\":\"trigger\",\"type\":\"normal\",\"content\":{}}],\"steps\":{\"trigger\":{\"title\":\"Webhook\",\"connector\":{\"name\":\"webhook\",\"version\":\"2.3\"},\"operation\":\"fire_and_forget\",\"output_schema\":{},\"error_handling\":{},\"properties\":{}}},\"dependencies\":[]}],\"projects\":[]}",
        targetWorkflowIds: ["e5dc0748-xxxx-xxxx-xxxx-dfcc33795f12"],
        clientMutationId: "some-mutation-id"
        }) {
      clientMutationId
    }
}

It can return the following data:

Returned Data Notes
clientMutationId while this data is only relevant if using the Relay GraphQL client, it is actually required here as currently this mutation does not return any other data
SecuritybearerAuth
Request
Responses
200

OK - Workflows are imported to the embedded org

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' \
  -data '{
    "query": "mutation ($exportedWorkflowsJson: String!, $targetWorkflowIds: [ID!], $clientMutationId: String) {\n\timportWorkflows (input: {\n  exportedWorkflowsJson: $exportedWorkflowsJson,\n  targetWorkflowIds: $targetWorkflowIds,\n  clientMutationId: $clientMutationId\n }) {\n  clientMutationId\n }\n}",
    "variables": {
      "exportedWorkflowsJson": "{\"tray_export_version\":4,\"export_type\":\"workflow\",\"workflows\":[{\"id\":\"ea3c20f5-xxxx-xxxx-xxxx-0ce2b7bb9f29\",\"created\":\"2023-05-15T11:26:14.794686Z\",\"workspace_id\":\"6c595d5b-xxxx-xxxx-xxxx-959ceb938eae\",\"creator\":\"6a4e56d9-xxxx-xxxx-xxxx-2429f79b40ff\",\"version\":{\"id\":\"018cc858-xxxx-xxxx-xxxx-2c8cfe0a7886\",\"created\":\"2023-05-16T22:25:42.413825Z\"},\"title\":\"webhook slack\",\"enabled\":false,\"tags\":[],\"settings\":{\"config\":{},\"input_schema\":{},\"output_schema\":{}},\"steps_structure\":[{\"name\":\"trigger\",\"type\":\"normal\",\"content\":{}}],\"steps\":{\"trigger\":{\"title\":\"Webhook\",\"connector\":{\"name\":\"webhook\",\"version\":\"2.3\"},\"operation\":\"fire_and_forget\",\"output_schema\":{},\"error_handling\":{},\"properties\":{}}},\"dependencies\":[]}],\"projects\":[]}",
      "targetWorkflowIds": ["e5dc0748-xxxx-xxxx-xxxx-dfcc33795f12"],
      "clientMutationId":"some-mutation-id"
    }
  }'
Response samples
application/json
{
  • "data": {
    • "importProject": {
      • "clientMutationId": null
      }
    }
}

Export Workflows (master token)

post/

The exportWorkflows mutation can be used to export the workflows from your embedded account. This is handy when you want to import workflows to your 'production' account from 'staging'.

Note that it is possible to export multiple workflows

Required token Notes
Master Obtained from the Tray app UI. Refer this.

The mutation accepts the following arguments:

Argument Required Note
workflowIds Yes Array of workflow IDs.
Workflow ID can be obtained from the url of target workflow page: https://app.tray.io/workflow/{workflowId}

Here is an example mutation:

Export Workflows
mutation {
  exportWorkflows (input: {
    workflowIds: ["ea3c20f5-xxxx-xxxx-xxxx-0ce2b7bb9f29", "a6af4264-xxxx-xxxx-xxxx-70a1e59d72b2"]
  }) {
    exportedWorkflowsJson
  }
}

It can return the following data:

Returned Data Notes
exportedWorkflowsJson Stringified JSON of the array of workflows
SecuritybearerAuth
Request
Responses
200

OK - JSON string of the exported workflows 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 ($workflowIds: [ID!]) {\n  exportWorkflows (input: {\n    workflowIds: $workflowIds\n  }) {\n    exportedWorkflowsJson\n  }\n}",
    "variables": {
      "workflowIds": ["ea3c20f5-xxxx-xxxx-xxxx-0ce2b7bb9f29","a6af4264-xxxx-xxxx-xxxx-70a1e59d72b2"]
    }
  }'
Response samples
application/json
{
  • "data": {
    • "exportWorkflows": {
      • "exportedWorkflowsJson": "{\"tray_export_version\":4,\"export_type\":\"workflow\",\"workflows\":[{\"id\":\"ea3c20f5-xxxx-xxxx-xxxx-0ce2b7bb9f29\",\"created\":\"2023-05-15T11:26:14.794686Z\",\"workspace_id\":\"6c595d5b-xxxx-xxxx-xxxx-959ceb938eae\",\"creator\":\"6a4e56d9-xxxx-xxxx-xxxx-2429f79b40ff\",\"version\":{\"id\":\"153485a5-xxxx-xxxx-xxxx-34bc1f9f08f4\",\"created\":\"2023-05-15T11:26:14.794685Z\"},\"title\":\"webhookslack\",\"enabled\":true,\"tags\":[],\"settings\":{\"config\":{},\"input_schema\":{},\"output_schema\":{}},\"steps_structure\":[{\"name\":\"trigger\",\"type\":\"normal\",\"content\":{}}],\"steps\":{\"trigger\":{\"title\":\"ManualTrigger\",\"connector\":{\"name\":\"noop\",\"version\":\"1.1\"},\"operation\":\"trigger\",\"output_schema\":{},\"error_handling\":{},\"properties\":{}}},\"dependencies\":[]},{\"id\":\"a6af4264-xxxx-xxxx-xxxx-70a1e59d72b2\",\"created\":\"2023-04-25T09:06:10.563859Z\",\"workspace_id\":\"6c595d5b-xxxx-xxxx-xxxx-959ceb938eae\",\"creator\":\"6c595d5b-xxxx-xxxx-xxxx-959ceb938eae\",\"version\":{\"id\":\"1a8c552e-xxxx-xxxx-xxxx-4ec119353733\",\"created\":\"2023-04-25T09:23:42.981741Z\"},\"title\":\"Sheetsratelimitingtest\",\"enabled\":true,\"tags\":[],\"settings\":{\"config\":{},\"input_schema\":{},\"output_schema\":{}},\"steps_structure\":[{\"name\":\"trigger\",\"type\":\"normal\",\"content\":{}},{\"name\":\"loop-1\",\"type\":\"loop\",\"content\":{\"_loop\":[{\"name\":\"boolean-condition-1\",\"type\":\"branch\",\"content\":{\"true\":[{\"name\":\"break-loop-1\",\"type\":\"break\",\"content\":{},\"target\":\"loop-1\"}],\"false\":[]}},{\"name\":\"slack-1\",\"type\":\"normal\",\"content\":{}}]}}],\"steps\":{\"slack-1\":{\"title\":\"Slack\",\"connector\":{\"name\":\"slack\",\"version\":\"9.1\"},\"operation\":\"list_users\",\"output_schema\":{},\"error_handling\":{},\"authentication\":{\"group\":\"14c77d41-xxxx-xxxx-xxxx-382944191584\",\"title\":\"MaelDuin'sslackaccount1\",\"service_icon\":{\"icon_type\":\"url\",\"value\":\"//s3.amazonaws.com/images.tray.io/artisan/icons/c25033a972715dbbdb7e73ac79261230.png\"},\"scopes\":[\"mpim:read\",\"im:read\",\"users:read.email\",\"channels:read\",\"chat:write:user\",\"files:read\",\"reminders:write\",\"channels:write\",\"groups:read\",\"chat:write:bot\",\"users:read\",\"groups:write\"],\"service_name\":\"slack\",\"service_version\":4},\"properties\":{\"token\":{\"type\":\"jsonpath\",\"value\":\"$.auth.access_token\"},\"limit\":{\"type\":\"integer\",\"value\":100}}},\"loop-1\":{\"title\":\"LoopCollection\",\"connector\":{\"name\":\"loop\",\"version\":\"1.3\"},\"operation\":\"loop_forever\",\"output_schema\":{\"type\":\"object\",\"$schema\":\"http://json-schema.org/draft-03/schema\",\"id\":\"http://jsonschema.net\",\"properties\":{\"index\":{\"type\":\"number\",\"id\":\"http://jsonschema.net/index\"}}},\"error_handling\":{},\"properties\":{}},\"boolean-condition-1\":{\"title\":\"BooleanCondition\",\"connector\":{\"name\":\"boolean-condition\",\"version\":\"2.3\"},\"operation\":\"boolean_condition\",\"output_schema\":{},\"error_handling\":{},\"properties\":{\"conditions\":{\"type\":\"array\",\"value\":[{\"type\":\"object\",\"value\":{\"value1\":{\"type\":\"jsonpath\",\"value\":\"$.steps.loop-1.index\"},\"comparison_type\":{\"type\":\"string\",\"value\":\"===\"},\"value2\":{\"type\":\"number\",\"value\":250}}}]},\"strictness\":{\"type\":\"string\",\"value\":\"All\"}}},\"break-loop-1\":{\"title\":\"BreakLoop\",\"connector\":{\"name\":\"break-loop\",\"version\":\"1.1\"},\"operation\":\"break\",\"output_schema\":{},\"error_handling\":{},\"properties\":{}},\"trigger\":{\"title\":\"ManualTrigger\",\"connector\":{\"name\":\"noop\",\"version\":\"1.1\"},\"operation\":\"trigger\",\"output_schema\":{},\"error_handling\":{},\"properties\":{}}},\"dependencies\":[]}],\"projects\":[]}"
      }
    }
}