Workflow REST API
You can use the Workflow REST API to programmatically interact with workflows, for example starting new workflows, retrieving workflow tasks, and completing workflow tasks.
The Workflow REST API provides a downloadable JSON (Swagger ) file, which you can download from the Management Site where the API is enabled, as shown below. You can parse this JSON file for documentation about the various endpoints, methods and properties exposed by the API. You can also click the Open Link button to launch the swagger documentation interface for the API, where you will be able to test the methods exposed by the API as well.
The URL for the REST API is specific to your K2 environment, and is shown in the Base URL field. You will need to use this URL in your code to when interacting with the API.
You can find code samples that demonstrate how to use this API in the Workflow REST API Code Samples topic.
Considerations
- Use the Swagger descriptor to discover the capabilities of the REST endpoints. The Swagger file is accessible from the Workflow API configuration page in the K2 Management site.
- Use the Tasks endpoints to list and action your tasks.
- Use the Workflows endpoints to list and start instances of workflows. The Authorization Framework trims what's exposed and shows workflows that you have Start rights on.
- The Workflow REST API supports Cross Origin Resource Sharing. CORS is a way to protect authentication within a browser, against an API, system or data source that doesn't exist in the same domain that the browser's context runs. For example, you may build a web app that runs locally and needs to hit the Workflow API that would be publicly exposed by K2 Cloud. You need to set up an entry in the CORS, Domains Allowed section of the API configuration page for where your code runs (your local domain, for example http://localhost and http://localhost:3000).
- For information on enabling and using Workflow REST API logging, see the K2 Auditing and Logging topic in the Installation and Configuration Guide.
- We don't support multiple file upload, but we do support uploading a single file as a file data type.
"parameters": [The method used would then have to only accept a single file, instead of an array for uploading files.
{
"in": "formData",
"name": "file",
"type": "file"
}
],For more information on the Swagger File uploading see: Swagger file upload.