# Initialising a process flow & sending data

## Introduction

Having obtained a Patchworks token, it can be applied to an API request to initialise a process flow with your data passed in the request body.

{% hint style="warning" %}
You must control when your API requests are sent - the process flow [trigger shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/trigger-shape) schedule cannot currently be used. With this in mind, please ensure that the default trigger shape in your process flow is not configured with any schedules.
{% endhint %}

## The steps

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpLMO12yvTCxi9PorCt53%2Ficons8-film.svg?alt=media&#x26;token=e59864bc-2d97-4f98-966c-a083c18e60db" alt="" data-size="line"> Show me</summary>

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FgoI0pIj25YvCdoupGrqo%2Fdemo%20initialise%20flow.gif?alt=media\&token=1f641f25-a751-4c78-a9dd-d0bad0e22b03)

</details>

**Step 1**\
Create a POST request for the following endpoint:

{% code lineNumbers="true" %}

```
https://start.wearepatchworks.com/api/v1/flows/<flowID>/manual/<flowVERSION>
```

{% endcode %}

...replacing `<flowID>` and `<flowVERSION>` with details for your required process flow noted [previously](https://doc.wearepatchworks.com/product-documentation/developer-hub/patchworks-core-api/core-api-spotlights/initialising-a-process-flow-and-sending-data-via-the-patchworks-api/the-steps/obtaining-process-flow-and-version-ids-for-api-requests).

{% hint style="info" %}
This endpoint is for the Patchworks **production** environment.&#x20;
{% endhint %}

**Step 2**\
In the request `headers`, pass in the token obtained [previously](https://doc.wearepatchworks.com/product-documentation/developer-hub/patchworks-core-api/core-api-spotlights/initialising-a-process-flow-and-sending-data-via-the-patchworks-api/the-steps/obtaining-a-token-for-patchworks-api-authentication) - this should be prefixed with the word `Bearer` - for example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F1ms3oG2gpakrYFmhORJk%2Finbound%20api%202.png?alt=media&#x26;token=a86202b2-4a4b-4e59-93d1-468fb49a7c0f" alt=""><figcaption></figcaption></figure>

**Step 3**\
In the request `body`, pass in the required payload - for example:

{% code lineNumbers="true" %}

```json
{
  "payload": "[{\"id\":1000000001,\"first_name\":\"Jane\",\"last_name\":\"Smith\"},{\"id\":1000000002,\"first_name\":\"George\",\"last_name\":\"Jones\"}]"
}
```

{% endcode %}

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FhjYstPJaWhu2qOf46x9n%2Finbound%20api%201.png?alt=media&#x26;token=bb10e792-1710-42cb-8047-2f79d8b281e7" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
Remember that the payload must be provided as a JSON object with a payload key containing a string of data. For more information please see [Preparing your data](https://doc.wearepatchworks.com/product-documentation/developer-hub/patchworks-core-api/core-api-spotlights/initialising-a-process-flow-and-sending-data-via-the-patchworks-api/the-steps/preparing-your-data).
{% endhint %}

**Step 4**\
Send the request - if successful, a 200 'flow initialised' response is given, together with a `flow run id`:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FVhMBwhSffdo7vMYMUWzA%2Finbound%20api%203.png?alt=media&#x26;token=1a3edbb0-5b7c-4cf3-8172-208c62a58ade" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
You can check the status of this flow run via the [run logs](https://doc.wearepatchworks.com/product-documentation/process-flows/error-reporting-and-exception-handling/run-logs-and-queue).
{% endhint %}
