> For the complete documentation index, see [llms.txt](https://docs.laminar.run/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.laminar.run/building-an-integration/keywords/lam.execute.md).

# lam.execute

## Functionality

The `execute` keyword executes each specified workflow in the array with its corresponding payload **synchronously**. This blocks the current workflow's execution until all specified workflows complete.

## Invocation

Data transformation must output:

```javascript
{
  "lam.execute": [
    {
      "lam.workflowId": 39,
      "lam.payload": { /* payload data */ }
    }
  ]
}
```

| Key        | Description                             | Type                           |
| ---------- | --------------------------------------- | ------------------------------ |
| execute    | The workflows to execute with a payload | Array<{ workflowId, payload }> |
| workflowId | The workflow ID to invoke               | Integer                        |
| payload    | The payload to pass to the workflow     | Object                         |

## Examples

```javascript
(payload) => {
  const { input } = payload;
  const { Recipient, PackagesInfo } = input;
  
  const packagePayloads = PackagesInfo.Packages.map(pkg => ({
    "lam.workflowId": 39,
    "lam.payload": {
      address_1: Recipient.Address1,
      address_2: Recipient.Address2,
      EXT_FIELD_first_name: Recipient.Firstname,
      EXT_FIELD_last_name: Recipient.Name,
      EXT_FIELD_email: Recipient.Email,
      EXT_FIELD_phone: Recipient.Tel,
      EXT_FIELD_weight: pkg.Weight.Value,
      custom_user_fields: [
        { order_custom_field_id: 1852 }
      ],
      address_city: Recipient.City,
      address_state_id: Recipient.CountryStateCode,
      address_country_id: Recipient.CountryCode,
      address_zip: Recipient.PostalCode,
      tracking_number: pkg.PreAssignTrackingNumber.TrackingNumber
    }
  }));

  return {
    "lam.execute": packagePayloads
  };
}
```

> In this example we map an array of packages to the `execute` keyword. Laminar will then invoke workflow 39 with each individual payload in sequence.
