How to start a workflow via API
Besides starting a workflow from the Sample Dashboard, you can also start a workflow via API.
To start a workflow, you will require two things
A SampleHC API key (see Authentication)
The slug (unique identifier) of the workflow you want to start
To find a workflow slug, from the workflow page, click the Edit button at the top right.
On the edit page, next to the title of the workflow (e.g., Sample Workflow Template), you will see the slug (e.g., sample-workflow-template
).
Below are examples of how to start a workflow with different types of request bodies. Remember to replace YOUR_API_KEY
with your actual API key and <my-workflow-slug>
with the slug of your workflow.
application/json
If you want to send data as a JSON object, use the Content-Type: application/json
header. The body should be a JSON object, optionally containing a startData
field.
multipart/form-data
If you need to include files or send data as form fields, use multipart/form-data
. curl
will set the Content-Type
header automatically when you use the -F
option.
Any form fields you send will be collected into the startData
. If you send files, they will be processed and their resulting identifiers or content will also be part of startData
.
The start_data_schema
field in a workflow definition allows you to specify the expected structure and validation rules for data sent when starting a workflow. This schema follows the JSON Schema specification and helps ensure data quality and provides clear documentation of expected inputs.
Here are some basic examples of start_data_schema
definitions:
Sample supports custom extensions to enhance form generation:
x-formFieldType
: Specifies the UI component type (e.g., “file”, “date”, “select”)x-formFieldLabel
: Custom label for the form fieldx-formFieldOrder
: Controls the order of fields in generated formsx-formFieldPlaceholder
: Placeholder text for input fieldsUsing start_data_schema
provides several advantages: