# Running Workflow

The Workflows API enables the initiation of workflows that do not involve integrations requiring interaction with the end user, such as scanning documents or completing forms. All necessary data for the execution of the process can be provided through input parameters.

### Flow overview

{% @mermaid/diagram content="sequenceDiagram
participant Server
participant Auth
participant Cases
participant Workflows
Server ->> Auth: POST /auth/authorize<br/>Request: {key, secret}<br/>Host: api.transactionlink.io
activate Auth
Auth -->> Server: 200 OK {accessToken, refreshToken}
deactivate Auth
Server ->> Cases: POST /cases<br/>Authorization: Bearer {accessToken} <br/>Payload: {firstName, lastName, companyNumber, ...}<br/>Host: api.transactionlink.io
activate Cases
Cases -->> Server: 201 Case Created {caseId}
deactivate Cases
Server ->> Workflows: POST /workflows/run<br/>Authorization: Bearer {accessToken} <br/>Payload: {caseId, workflowDefinitionId, parametersId}<br/>Host: api.transactionlink.io
activate Workflows
Workflows -->> Server: 200 Worklfow has been run {id, caseId, status}
deactivate Workflows
loop Check whether the workflow has been completed.
Server ->> Workflows: GET /workflows/{workflowId}<br/>Authorization: Bearer {accessToken} <br/>Host: api.transactionlink.io
activate Workflows
Workflows -->> Server: 200 Worklfow status {id, caseId, status}
deactivate Workflows
end
Server ->> Workflows: GET /workflows/{workflowId}/result<br/>Authorization: Bearer {accessToken} <br/>Host: api.transactionlink.io
activate Workflows
Workflows -->> Server: 200 Worklfow result {id, caseId, status, custom result}
deactivate Workflows
" %}

## Steps

### Create Case

The initial step is to create a case, which represents an individual who will go through the workflow.

During case creation, you can provide additional data such as first name, last name, number, or company name. These details can be utilized when executing tasks in the workflow. This step must be carried out on your backend server.&#x20;

{% hint style="info" %}
Please ensure that you create a Case for every new end user, as it acts as their representation within the system. For returning users, you can utilize the previously created Case to streamline the process.
{% endhint %}

{% openapi src="/files/1Rs8dYYlBIj4v4fTgVo6" path="/cases" method="post" %}
[new\_openapi.yaml](https://content.gitbook.com/content/1Xg0vxunGGwv17NKWL80/blobs/5NXyNGNpiiwZCTc1mij0/new_openapi.yaml)
{% endopenapi %}

### Create Parameters (optional)

The second step involves passing custom parameters to the workflow if the process requires it. Configuration of this should be done from the dashboard.

{% openapi src="/files/1Rs8dYYlBIj4v4fTgVo6" path="/parameters" method="post" %}
[new\_openapi.yaml](https://content.gitbook.com/content/1Xg0vxunGGwv17NKWL80/blobs/5NXyNGNpiiwZCTc1mij0/new_openapi.yaml)
{% endopenapi %}

### Run Workflow

Next, we can initiate the workflow by providing the `workflowDefinitionId`, `caseId`, and optional `parametersId`.

{% openapi src="/files/1Rs8dYYlBIj4v4fTgVo6" path="/workflows/run" method="post" %}
[new\_openapi.yaml](https://content.gitbook.com/content/1Xg0vxunGGwv17NKWL80/blobs/5NXyNGNpiiwZCTc1mij0/new_openapi.yaml)
{% endopenapi %}

### Check Workflow Status

The workflow result will only be available upon its completion. To check if the workflow has finished, one can implement long polling and periodically check its status through an API or receive a [webhook](/docs/v1/webhooks.md) with information about the completed process.

{% openapi src="/files/1Rs8dYYlBIj4v4fTgVo6" path="/workflows/{workflowId}" method="get" %}
[new\_openapi.yaml](https://content.gitbook.com/content/1Xg0vxunGGwv17NKWL80/blobs/5NXyNGNpiiwZCTc1mij0/new_openapi.yaml)
{% endopenapi %}

### Get Workflow Result

Upon receiving confirmation that the workflow has finished, you can then fetch the result of the process. The specific outcome of the process is contingent upon its individual configuration.

{% openapi src="/files/1Rs8dYYlBIj4v4fTgVo6" path="/workflows/{workflowId}/result" method="get" %}
[new\_openapi.yaml](https://content.gitbook.com/content/1Xg0vxunGGwv17NKWL80/blobs/5NXyNGNpiiwZCTc1mij0/new_openapi.yaml)
{% endopenapi %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.transactionlink.io/docs/v1/integration-quick-guide/running-workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
