Skip to main content

API Client

Endpoint​

Tasklist provides an GraphQL API at endpoint /graphql.

Authentication​

To access the API endpoint you need an access token. Your client needs to send a header in each request:

Authorization: Bearer <Token>

For example send a request by using curl:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" -d '{"query": "{tasks(query:{}){name}}"}' http://localhost:8080/graphql

How to obtain the access token​

You need to obtain a token for using the Tasklist API. When you create a Tasklist client you will get all the information you need to connect to Tasklist.

See also Build your own client

Following settings are needed:

NameDescriptionDefault value
client idName of your registered client-
client secretPassword for your registered client-
audiencePermission name, if not given use default valuetasklist.camunda.io
authorization server urlToken issuer server-

You send a token issue POST request to the authorization server with the content:

{
"client_id": "<client-id>",
"client_secret":"<client-secret>",
"audience":"<audience>",
"grant_type":"client_credentials"
}

An example with curl:

curl -X POST --header 'content-type: application/json' --data '{"client_id": "<client-id>", "client_secret":"<client-secret>","audience":"<audience>","grant_type":"client_credentials"}' https://<authorization server url>

If the authorization is successful, the authorization server sends back the access token, when it expires, scope and type:

{
"access_token": "ey...",
"scope": "...",
"expires_in": 86400,
"token_type": "Bearer"
}

Obtain GraphQL Schema​

To obtain the GraphQL schema you need to send a request to the endpoint with a GraphQL introspection query as described in https://graphql.org/learn/introspection/

or you use the generated API documentation

There are also a lot of tools to explore GraphQL API's like this: https://altair.sirmuel.design

For example you want to know all about provided types:

query {
__schema {
queryType {
fields {
name
type {
kind
ofType {
kind
name
}
}
}
}
}
}

Examples requests and responses​

Get all tasks names​

Request:

{"query":"{
tasks(query: {}) {
name
}
}"
}

Response:

{
"data": {
"tasks": [
{
"name": "Check payment"
},
{
"name": "Register the passenger"
}
]
}
}

Get all tasks that are completed with id, name and state​

Request:

{
"query" : "{
tasks(query: { state: COMPLETED }) {
id
name
taskState
}
}"
}

Response:

{
"data": {
"tasks": [
{
"id": "2251799813685728",
"name": "Check payment",
"taskState": "COMPLETED"
}
]
}
}