# About operations

## Introduction

In Patchworks, an `operation` is counted whenever a request is made to send or receive a payload to/from an endpoint or query.

Crucially, we're not concerned with the number of items in the payload - we simply count the number of times a process flow requests to send or receive a payload. This might happen in several ways:

<table><thead><tr><th width="237">Mechanism</th><th>Summary</th></tr></thead><tbody><tr><td>Connector shape</td><td>A request is made (successfully or otherwise) to <em>receive</em> data from a specified endpoint/query.</td></tr><tr><td>Connector shape</td><td>A request is made (successfully or otherwise) to <em>send</em> data to a specified endpoint/query.</td></tr><tr><td>Webhook trigger</td><td>A <code>webhook</code>  is <em>received</em> (with or without a payload) in the first step of the process flow.</td></tr><tr><td>Event trigger</td><td>An <code>event</code>  is <em>received</em> (with or without a payload) in the first step of the process flow.</td></tr><tr><td>Patchworks API call</td><td>A <code>Patchworks API call</code>  is <em>received</em> (with or without a payload) in the first step of the process flow.</td></tr></tbody></table>

## Considerations for your operations count

The number of payloads that a process flow sends or receives correlates with the number of operations logged. In the most straightforward case, you might create a process flow that always *receives* a single, unpaginated payload from one system and then *sends* a single, unpaginated payload to another system - this would be an operations count of 2.&#x20;

However, as the complexity of a process flow increases, so too does the potential for an increase in the number of payloads being processed. The most likely ways that this can happen are:

**Paginated data.** If you receive paginated data, you receive 1 payload for each page of data - so each page represents 1 *receive* operation. In short, an initial data pull can result in multiple *receive* operations. And if you receive multiple pages, it follows that multiple pages continue through the flow - which means (potentially) multiple pages will be sent into your destination system, resulting in multiple *send* operations.&#x20;

**Flow control.** The [flow control](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape) shape is typically used to batch an incoming payload into multiple, smaller payloads for onward processing. So, even if you start by *receiving* 1 payload, it's likely that you will be *sending* multiple payloads at the end of the flow.

{% hint style="info" %}
Retries for failed connection requests are included in your operations count. For more information on connector retry settings, please see [Understanding how data flows through shapes (retries)](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/understanding-how-data-flows-through-shapes#retries).
{% endhint %}

### Examples

The examples below show the impact that these scenarios can have on operation counts:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><p>In the simplest of flows you might <strong>receive</strong> 1 payload from a source endpoint which contains 350 records in a single, unpaginated payload. The flow goes on to <strong>send</strong> that payload to a destination endpoint. </p><p></p><p>This results in <strong>2</strong> operations - 1 for the <strong>receive</strong> operation and 1 for the <strong>send</strong> operation.</p></td><td><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpHJWedSu9ol1VqKW30cr%2Fops%20example%20a.png?alt=media&#x26;token=15c189aa-2eec-4155-a9e1-6a2436365c4d" alt=""></td><td></td><td><a href="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F5tKEnqIEOJSan5px2unS%2Ftile%201a.png?alt=media&#x26;token=ac0b15f0-e6b3-4439-a704-3aefdba86a94">tile 1a.png</a></td></tr><tr><td><p>In a slightly more complex flow you might <strong>receive</strong> 1 payload from a source endpoint which contains 350 records in a single, unpaginated payload.</p><p></p><p>The flow continues with a <a href="../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape">flow control </a>shape which batches this data into smaller chunks, resulting in 5 payloads, each containing 70 records. The flow goes on to <strong>send</strong> all of these payloads to a destination endpoint. </p><p></p><p>This results in <strong>6</strong> operations - one for the <strong>receive</strong> operation and 5 for the <strong>send</strong> operations.</p></td><td><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FFEPFnOqhYYtShCMRkgRc%2Fops%20example%20b.png?alt=media&#x26;token=dab695c5-b9d6-44f3-b5a9-865dbdde85a8" alt=""></td><td></td><td><a href="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FVhk00GnZqRHMHWtc3Sxb%2Ftile%202a.png?alt=media&#x26;token=fabd119d-c6b9-43ab-a5b9-8639ef9905f2">tile 2a.png</a></td></tr><tr><td><p>In this example, our incoming data is paginated as 50 records per page, so we <strong>receive</strong> 350 records as 7 payloads (50 records in each).  </p><p></p><p>The flow proceeds to <strong>send</strong> all of these payloads to a destination endpoint. </p><p></p><p>This results <strong>14</strong> operations - 7 for <strong>receive</strong> operations and 7 for <strong>send</strong> operations.</p></td><td><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FwspWPcUHnlieGYrP2r0O%2Fops%20example%20c1.png?alt=media&#x26;token=fc1ac399-337e-4372-b3f0-7b14cf104baf" alt=""></td><td></td><td><a href="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FHmB85HV6NAwfpq6EySVz%2Ftile%203a.png?alt=media&#x26;token=234e1fff-3da9-40cd-b276-99873d5b8cd7">tile 3a.png</a></td></tr><tr><td><p>In this example, our incoming data is paginated as 50 records per page, so we <strong>receive</strong> 350 records as 7 payloads (50 records in each).  </p><p></p><p>The flow continues with a <a href="../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape">flow control </a>shape which batches this data into single-item payloads. The flow goes on to <strong>send</strong> all of these payloads to a destination endpoint. </p><p></p><p>This results <strong>357</strong> operations - 7 for <strong>receive</strong> operations and 350 for <strong>send</strong> operations.</p></td><td><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F0DGy3RLqWhZ9srVKJFCE%2Fops%20example%20d1.png?alt=media&#x26;token=777812fa-fec8-43eb-99a6-9353d1dfc5e8" alt=""></td><td></td><td><a href="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FMU35K6ikEyMA82nIMNsm%2Ftile%204a.png?alt=media&#x26;token=14ae5514-9c0b-49f0-be93-153c417ab2a3">tile 4a.png</a></td></tr></tbody></table>
