Source: https://leadping.ai/docs/api-reference/automations/runs-an-automation-through-its-manual-trigger

# Runs an automation through its Manual trigger.

Starts the specified automation through its manual trigger and returns the newly created execution record.

## Endpoint

**POST** `/automations/{id}/run`

```bash
curl --request POST \
  --url https://api.leadping.ai/automations/{id}/run \
  --header 'Authorization: Bearer <token>'
```

### Python

```python
import requests

url = "https://api.leadping.ai/automations/{id}/run"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.leadping.ai/automations/{id}/run");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://api.leadping.ai/automations/{id}/run")
  .header("Authorization", "Bearer <token>")
  .asString();
```

### JavaScript

```javascript
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.leadping.ai/automations/{id}/run', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.leadping.ai/automations/{id}/run"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.leadping.ai/automations/{id}/run",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

## Authorizations

### Authorization

- **Type:** `string`
- **Location:** `header`
- **Required:** Yes

Authorization header using the Bearer scheme. Accepted values are Leadping user JWT access tokens and WorkOS organization API keys beginning with `sk_`.

## Path Parameters

### `id`

- **Type:** `string`
- **Required:** Yes

The unique identifier of the automation to run.

## Response

**200** · `application/json`

Returns the newly created automation execution record.

History record schema for Leadping API automation run record data exposed in automation and audit views.

```json
{
  "id": "<string>",
  "automationId": "<string>",
  "organizationId": "<string>",
  "leadId": "<string>",
  "triggerType": "<string>",
  "triggerId": "<string>",
  "conditionResults": {},
  "status": "<string>",
  "executionMode": "<string>",
  "startedAt": "2023-11-07T05:31:56Z",
  "completedAt": "2023-11-07T05:31:56Z",
  "processingAttempts": 123,
  "lastAttemptAt": "2023-11-07T05:31:56Z",
  "failureCode": "<string>",
  "skippedReason": "<string>",
  "actions": [
    {
      "smsDelivery": {
        "smsEventId": "<string>",
        "status": "draft",
        "scheduledFor": "2023-11-07T05:31:56Z",
        "nextRetryAt": "2023-11-07T05:31:56Z",
        "errorCode": "<string>",
        "reason": "<string>",
        "summary": "<string>"
      },
      "id": "<string>",
      "automationRunId": "<string>",
      "actionId": "<string>",
      "actionType": "<string>",
      "order": 123,
      "status": "<string>",
      "selectedConnectionId": "<string>",
      "startedAt": "2023-11-07T05:31:56Z",
      "scheduledAt": "2023-11-07T05:31:56Z",
      "completedAt": "2023-11-07T05:31:56Z",
      "failedAt": "2023-11-07T05:31:56Z",
      "processingAttempts": 123,
      "nextRetryAt": "2023-11-07T05:31:56Z",
      "failureCode": "<string>"
    }
  ]
}
```

### Response fields

#### `id`

- **Type:** `string`

Unique Leadping identifier for this automation run record.

#### `automationId`

- **Type:** `null | string`

Automation ID connected to this workflow, run, or event.

#### `organizationId`

- **Type:** `null | string`

Organization ID that owns this automation run.

#### `leadId`

- **Type:** `null | string`

Lead ID that triggered this automation run, when the run is lead-based.

#### `triggerType`

- **Type:** `null | string`

Automation trigger type that starts the workflow.

#### `triggerId`

- **Type:** `null | string`

Identifier of the trigger node selected when this run was queued.

#### `conditionResults`

- **Type:** `object`

Results of condition nodes already visited by this run, preserved across waits and retries.

#### `status`

- **Type:** `string`

Current lifecycle status for this automation run record in the Leadping API.

#### `executionMode`

- **Type:** `string`

Execution mode used for automation preview or live workflow processing.

#### `startedAt`

- **Type:** `string<date-time>`

UTC timestamp when processing started for this automation run record.

#### `completedAt`

- **Type:** `null | string<date-time>`

UTC timestamp when processing completed for this automation run record.

#### `processingAttempts`

- **Type:** `integer<int32>`

Number of processing attempts made for this workflow or delivery request.

#### `lastAttemptAt`

- **Type:** `null | string<date-time>`

UTC timestamp when Leadping last attempted to process this automation run.

#### `failureCode`

- **Type:** `null | string`

Machine-readable failure code for troubleshooting this automation run record.

#### `skippedReason`

- **Type:** `null | string`

Human-readable reason explaining why Leadping skipped this automation run.

#### `actions`

- **Type:** `object[]`

Automation actions configured or returned for this workflow.

Each action may include:

- `smsDelivery`
  - `smsEventId`
  - `status`
  - `scheduledFor`
  - `nextRetryAt`
  - `errorCode`
  - `reason`
  - `summary`
- `id`
- `automationRunId`
- `actionId`
- `actionType`
- `order`
- `status`
- `selectedConnectionId`
- `startedAt`
- `scheduledAt`
- `completedAt`
- `failedAt`
- `processingAttempts`
- `nextRetryAt`
- `failureCode`

## Error responses

### 400 Bad Request

```json
{
  "type": "about:blank",
  "title": "Bad Request",
  "status": 400,
  "detail": "The request could not be completed."
}
```

### 401 Unauthorized

```json
{
  "type": "about:blank",
  "title": "Unauthorized",
  "status": 401,
  "detail": "The request could not be completed."
}
```

### 403 Forbidden

```json
{
  "type": "about:blank",
  "title": "Forbidden",
  "status": 403,
  "detail": "The request could not be completed."
}
```

### 429 Too Many Requests

```json
{
  "type": "about:blank",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "The request could not be completed."
}
```
