> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# RunAutomation

# Package: triggers

# Namespace: EsbConfigResolver

# Method link: https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/run-automation.md

## Permission Scopes:
Set Up Automations: SCOPE.CRM.SETUP-AUTOMATIONS

## Introduction

Runs an automation directly, without reporting an event.

> it can only be called by apps

Use this to activate an automation manually when no triggering event occurs in your system. For example, an automation that sends a confirmation when a customer books online won't run if the customer books by phone instead. Run Automation lets the site owner send that confirmation anyway.

Identify the automation to run in one of these ways:

- `automationIdentifier`: The ID of an existing automation. Retrieve it from the [Automations API](https://dev.wix.com/docs/rest/business-management/automations/introduction.md).
- `preinstalledIdentifier`: The app ID and component ID of a preinstalled automation.

To run an automation in test mode, including unpublished draft automations, call [Test Automation](https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/test-automation.md).

---

## REST API

### Schema

```
 Method: runAutomation
 Description: Runs an automation directly, without reporting an event.  > it can only be called by apps  Use this to activate an automation manually when no triggering event occurs in your system. For example, an automation that sends a confirmation when a customer books online won't run if the customer books by phone instead. Run Automation lets the site owner send that confirmation anyway.  Identify the automation to run in one of these ways:  - `automationIdentifier`: The GUID of an existing automation. Retrieve it from the [Automations API](https://dev.wix.com/docs/rest/business-management/automations/introduction.md). - `preinstalledIdentifier`: The app GUID and component GUID of a preinstalled automation.  To run an automation in test mode, including unpublished draft automations, call [Test Automation](https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/test-automation.md).
 URL: https://www.wixapis.com/automations/esbConfigResolver/v1/events/run-automation
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  identifierType, payload
 Method parameters: 
    - ONE-OF: 
     - name: preinstalledIdentifier | type: PreinstalledIdentifier | description: Identifies a preinstalled automation by its app GUID and component GUID.  
        - name: appId | type: string | description: GUID of the app that the preinstalled automation belongs to.  | validation: format GUID
        - name: componentId | type: string | description: GUID of the app component that defines the preinstalled automation.  | validation: format GUID
     - name: automationIdentifier | type: AutomationIdentifier | description: Identifies an automation by its GUID.  
        - name: automationId | type: string | description: GUID of the automation to run.  | validation: format GUID
   param name: identifierType | type: IdentifierType | description: Specifies how an automation is identified when calling Run Automation or Test Automation. | required: true 
      - enum:
           PREINSTALLED - Identifies a preinstalled automation by its app ID and component ID.
           AUTOMATION - Identifies an automation by its ID.
   param name: migrationFlow | type: migrationFlow | description: When true, indicates this is a migration flow and should bypass the check for future dates that have already passed.  
   param name: payload | type: payload | description: Event payload, formatted as key:value pairs. Must comply with the payload schema if you provided one when configuring your trigger.  Key names can include only alphanumeric characters or underscores (`A-Z`, `a-z`, `0-9`, `_`). They cannot start with an underscore.  Values can be strings, numbers, integers, booleans, or arrays. If a value is an array, the array items must be objects, and nested object properties must be strings, numbers, integers, or booleans only. | required: true 
 Return type: RunAutomationResponse
  - name: activationId | type: string | description: GUID of the activation created for this run.  | validation: format GUID


```

### Examples

### RunAutomation
```curl
~~~cURL
curl POST https://www.wixapis.com/automations/v1/events/run-automation  \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "identifierType": "AUTOMATION",
    "automationIdentifier": {
      "automationId": "d7a341c4-196b-46e7-813c-2b0fc1847ec6"
    },
    "payload": {
      "customerName": "John Doe",
      "bookingId": "a1b2c3d4-5e6f-4a1b-9c8d-7e6f5a4b3c2d"
    }
  }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.automations.activations.runAutomation(identifierType, options)
 Description: Runs an automation directly, without reporting an event.  > it can only be called by apps  Use this to activate an automation manually when no triggering event occurs in your system. For example, an automation that sends a confirmation when a customer books online won't run if the customer books by phone instead. Run Automation lets the site owner send that confirmation anyway.  Identify the automation to run in one of these ways:  - `automationIdentifier`: The GUID of an existing automation. Retrieve it from the [Automations API](https://dev.wix.com/docs/rest/business-management/automations/introduction.md). - `preinstalledIdentifier`: The app GUID and component GUID of a preinstalled automation.  To run an automation in test mode, including unpublished draft automations, call [Test Automation](https://dev.wix.com/docs/api-reference/business-management/automations/triggers/triggered-events/test-automation.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  identifierType, options.payload, options
 Method parameters: 
   param name: identifierType | type: IdentifierType | description: Specifies how an automation is identified when calling Run Automation or Test Automation. | required: true 
      - enum:
           PREINSTALLED - Identifies a preinstalled automation by its app ID and component ID.
           AUTOMATION - Identifies an automation by its ID.
   param name: options | type: RunAutomationOptions  none | required: true 
    - ONE-OF: - required: true
     - name: preinstalledIdentifier | type: PreinstalledIdentifier | description: Identifies a preinstalled automation by its app GUID and component GUID.  
        - name: appId | type: string | description: GUID of the app that the preinstalled automation belongs to.  | validation: format GUID
        - name: componentId | type: string | description: GUID of the app component that defines the preinstalled automation.  | validation: format GUID
     - name: automationIdentifier | type: AutomationIdentifier | description: Identifies an automation by its GUID.  
        - name: automationId | type: string | description: GUID of the automation to run.  | validation: format GUID
        - name: payload | type: object | description: Event payload, formatted as key:value pairs. Must comply with the payload schema if you provided one when configuring your trigger.  Key names can include only alphanumeric characters or underscores (`A-Z`, `a-z`, `0-9`, `_`). They cannot start with an underscore.  Values can be strings, numbers, integers, booleans, or arrays. If a value is an array, the array items must be objects, and nested object properties must be strings, numbers, integers, or booleans only. | required: true 
        - name: migrationFlow | type: boolean | description: When true, indicates this is a migration flow and should bypass the check for future dates that have already passed.  
 Return type: PROMISE<RunAutomationResponse>
  - name: activationId | type: string | description: GUID of the activation created for this run.  | validation: format GUID


```

### Examples

### runAutomation
```javascript
import { activations } from '@wix/automations';

async function runAutomation(identifierType,options) {
  const response = await activations.runAutomation(identifierType,options);
};
```

### runAutomation (with elevated permissions)
```javascript
import { activations } from '@wix/automations';
import { auth } from '@wix/essentials';

async function myRunAutomationMethod(identifierType,options) {
  const elevatedRunAutomation = auth.elevate(activations.runAutomation);
  const response = await elevatedRunAutomation(identifierType,options);
}
```

### runAutomation (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { activations } from '@wix/automations';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { activations },
  // Include the auth strategy and host as relevant
});


async function runAutomation(identifierType,options) {
  const response = await myWixClient.activations.runAutomation(identifierType,options);
};
```

---