Using Zenaton GraphQL API
If the programming language of your application is not supported through a Zenaton SDK (currently only node.js), you can use the Zenaton GraphQL API to interact with your Zenaton workflows from within your applications.
A GraphQL API has a single endpoint. Zenaton's endpoint is:
https://gateway.zenaton.com/graphql
For authentification, include your personal API token as a "Authorization: Bearer <Api Token>"
header in all GraphQL queries and mutations.
Zenaton offers an API Explorer that lets you play with the API.
Authentification in the API Explorer
The first thing you should do when playing with the API Explorer is to enter your API token.
# Dispatch a task
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: DispatchTaskInput!) { dispatchTask(input: $input) { id } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"name": "<task name>",
"input": "[...<task input>]"
}
}
}'
# Dispatch a workflow
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: DispatchWorkflowInput!) { dispatchWorkflow(input: $input) { id } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"name": "<workflow name>",
"input": "[...<workflow input>]"
}
}
}'
# Schedule a task
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: ScheduleTaskInput!) { scheduleTask(input: $input) { id } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"cron": "<cron expression>",
"name": "<task name>",
"input": "[...<task input>]"
}
}
}'
# Schedule a workflow
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: ScheduleWorkflowInput!) { scheduleWorkflow(input: $input) { id } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"cron": "<cron expression>",
"name": "<workflow name>",
"input": "[...<workflow input>]"
}
}
}'
# Actions to workflows
Currently, there are 3 ways to select workflows:
Type | selector value |
---|---|
by id | { "id": "<workflow id>" } |
by name | { "name": "<workflow name>" } |
by name and tag | { "name": "<workflow name>", "tag": "<workflow tag>" } |
This selector
value should be used in requests below.
# Send an event to workflows
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: SendEventToWorkflowsInput!) { sendEventToWorkflows(input: $input) { status } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"selector": <selector>
"name": "<event name>",
"data": "[...<event data>]"
}
}
}'
# Pause running workflows
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: PauseWorkflowsInput!) { pauseWorkflows(input: $input) { status } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"selector": <selector>
}
}
}'
# Resume paused workflows
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: ResumeWorkflowsInput!) { resumeWorkflows(input: $input) { status } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"selector": <selector>
}
}
}'
# Terminate running workflows
curl --request POST \
--url 'https://gateway.zenaton.com/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <api Token>' \
--data '
{
"query": "mutation($input: TerminateWorkflowsInput!) { terminateWorkflows(input: $input) { status } }",
"variables": {
"input": {
"appId": "<app id>",
"environment": "<environment>",
"selector": <selector>
}
}
}'