Here are practical examples of using Next Matter’s API for common automation tasks.

Start instance and complete a step (script)

Use this Python script to automatically create workflow instances and complete steps programmatically.

Use case: Create a new employee onboarding workflow, automatically complete the first step by, for example, automatically filling in personal details, and advance to the next step.

  1. The script creates an instance with process_id and tags. The name is created automatically as per Next Matter settings.
  2. Fills the step with the required input data and marks a step in the workflow as completed.
    • Uses the API endpoint: https://core.nextmatter.com/api/instances//complete_step/
    • Requires:
      • Instance ID (to specify the workflow instance)
      • Step ID (which step to complete)
      • List of form fields ( with input data required for the step to complete) If successful, shows a completion message.

Filter instances by max total runtime

Use case: Find all workflow instances that completed within a specific time frame.

You can use this API call to get filtered instances of a workflow. In the example below, we’re filtering for all instances with a maximum total runtime of 50 seconds.

https://core.nextmatter.com/api/processes/WORKFLOW_ID/instances/?total_runtime_max=00:50

Here are some other examples of values to use:

  • 01 09:30 - 1 day and 9 minutes and 30 seconds
  • 02:30:00 - 2 hours and 30 minutes (and 0 seconds)
  • PT50M - 50 minutes (as per ISO 8601 duration formats)
  • PT1H30S - 1 hour and 30 seconds (as per ISO 8601 duration formats)