# Runs

> Monitor and debug your automation executions.

Every time an event [triggers](https://www.mailblastr.com/docs/automations/trigger) an automation, MailBlastr creates a **run**.

A run tracks the execution of each step in the workflow, including its status and timing, along with any errors.

## How it works

Each run has one of the following statuses:

| Status | Description |
| --- | --- |
| `running` | The automation is currently executing steps. |
| `completed` | All steps finished successfully. |
| `failed` | A step encountered an error and the run stopped. |
| `cancelled` | The run was cancelled before completing. |
| `skipped` | The run ended on a Send Email step that was skipped because the contact has unsubscribed. |

### Skipped steps

When a contact unsubscribes, any remaining [Send Email](https://www.mailblastr.com/docs/automations/send-email) steps in the automation will be skipped automatically. Other step types (such as Delay, Condition, or Contact Update) will still be executed as normal.

## Listing runs

In the dashboard, select an automation to view its runs — each run shows its **status**, when it **started**, and its **duration**. Over the API, list all runs for an automation with `GET /automations/:id/runs`.

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.automations.runs('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd');
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Automations.runs("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd")
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->automations->runs('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd');
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Automations.runs("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd")
```

**Go**

```go
package main

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

func main() {
    req, _ := http.NewRequest("GET", "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs", nil)
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .get("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X GET 'https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
mailblastr automations runs c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd
```

**Response**

```json
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "automation_run",
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "contact_id": "26e2b838-bf6d-4515-b6a7-17525b12b05a",
      "contact_email": "jordan@acme.com",
      "status": "completed",
      "started_at": "2026-10-01T12:00:00.000Z",
      "completed_at": "2026-10-01T12:05:00.000Z",
      "created_at": "2026-10-01T12:00:00.000Z"
    }
  ]
}
```

View the [List Automation Runs API reference](https://www.mailblastr.com/docs/api/automations-list-runs) for more details.

## Filtering runs by status

You can filter runs by status to find specific executions. Over the API, filter by multiple statuses using a comma-separated list.

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.automations.runs('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', { status: running,completed });
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Automations.runs("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", {
  "status": "running,completed"
})
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->automations->runs('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', [
  'status' => "running,completed"
]);
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Automations.runs("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", {
  "status": "running,completed"
})
```

**Go**

```go
package main

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

func main() {
    req, _ := http.NewRequest("GET", "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs?status=running,completed", nil)
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .get("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs?status=running,completed")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs?status=running,completed"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs?status=running,completed");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X GET 'https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs?status=running,completed' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

## Viewing a single run

In the dashboard, click on a run to view its details and select the step you want to debug. Over the API, retrieve the full details of one run — including the `steps` array — with `GET /automations/:id/runs/:runId`. The first entry in `steps` is the trigger step.

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.automations.getRun('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', 'a1b2c3d4-e5f6-7890-abcd-ef1234567890');
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Automations.get_run("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", "a1b2c3d4-e5f6-7890-abcd-ef1234567890")
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->automations->getRun('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd', 'a1b2c3d4-e5f6-7890-abcd-ef1234567890');
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Automations.get_run("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", "a1b2c3d4-e5f6-7890-abcd-ef1234567890")
```

**Go**

```go
package main

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

func main() {
    req, _ := http.NewRequest("GET", "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890", nil)
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .get("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X GET 'https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/runs/a1b2c3d4-e5f6-7890-abcd-ef1234567890' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
mailblastr automations run c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd a1b2c3d4-e5f6-7890-abcd-ef1234567890
```

**Response**

```json
{
  "object": "automation_run",
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "automation_id": "c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd",
  "contact_id": "26e2b838-bf6d-4515-b6a7-17525b12b05a",
  "contact_email": "jordan@acme.com",
  "status": "completed",
  "error": null,
  "started_at": "2026-10-01T12:00:00.000Z",
  "completed_at": "2026-10-01T12:05:00.000Z",
  "created_at": "2026-10-01T12:00:00.000Z",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "status": "completed",
      "started_at": "2026-10-01T12:00:00.000Z",
      "completed_at": "2026-10-01T12:00:01.000Z",
      "output": null,
      "error": null
    },
    {
      "key": "welcome",
      "type": "send_email",
      "status": "completed",
      "started_at": "2026-10-01T12:00:01.000Z",
      "completed_at": "2026-10-01T12:00:02.000Z",
      "output": {
        "to": "user@example.com",
        "email_id": "6278820d-2421-42d0-85f0-80e9e28c1c69",
        "template": {
          "id": "caa9851e-e7bf-4a50-a408-56024edc19c0",
          "variables": null
        }
      },
      "error": null
    }
  ]
}
```

Each step in the response includes:

| Field | Description |
| --- | --- |
| `key` | The unique key of the step in the automation graph. |
| `type` | The step type (e.g. `trigger`, `send_email`, `delay`). |
| `status` | The step's execution status: `completed`, `failed`, or `skipped`. |
| `started_at` | When the step started executing. |
| `completed_at` | When the step finished. |
| `output` | Output data from the step (if any). |
| `error` | Error details if the step failed. |

View the [Retrieve Automation Run API reference](https://www.mailblastr.com/docs/api/automations-get-run) for more details.

## Debugging failed runs

When a run fails, use the step-level details to identify the issue:

1. **List failed runs** — filter runs by `status=failed` to find problematic executions.
2. **Retrieve the run** — get the full run details, including the `steps` array.
3. **Find the failed step** — look for the step with a `failed` status.
4. **Check the error** — the `error` field on the failed step contains details about what went wrong.

Common failure scenarios:

- **Condition error** — a referenced field may not exist in the event payload. See [Condition](https://www.mailblastr.com/docs/automations/condition) for how conditions are evaluated.
- **Wait for event timeout** — the expected event was not received within the timeout window. See [Wait for Event](https://www.mailblastr.com/docs/automations/wait-for-event).
- **Send email failed** — the template may not be published, or the sender address may not be verified. See [Send Email](https://www.mailblastr.com/docs/automations/send-email).

## Stopping an automation

In the dashboard, click the **Stop** button to stop an automation. Over the API, stop it with `POST /automations/:id/stop` — this sets the status to `disabled`.

**Node.js**

```js
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.automations.stop('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd');
console.log({ data, error });
```

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

Mailblastr::Automations.stop("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd")
```

**PHP**

```php
$mailblastr = Mailblastr::client('mb_xxxxxxxxx');

$mailblastr->automations->stop('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd');
```

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

mailblastr.Automations.stop("c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd")
```

**Go**

```go
package main

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

func main() {
    req, _ := http.NewRequest("POST", "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/stop", nil)
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
}
```

**Rust**

```rust
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let res = Client::new()
        .post("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/stop")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .send()
        .await?;
    println!("{}", res.text().await?);
    Ok(())
}
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/stop"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .method("POST", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

**.NET**

```csharp
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/stop");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X POST 'https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/stop' \
  -H 'Authorization: Bearer mb_xxxxxxxxx'
```

**CLI**

```bash
mailblastr automations stop c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd
```

> **Note:** Stopping an automation prevents new runs from being created. Existing in-progress runs will continue to completion.

View the [Stop Automation API reference](https://www.mailblastr.com/docs/api/automations-stop) for more details.

## Viewing metrics

In the dashboard, you can view overall metrics for any automation. In the **Observability** panel for any automation, select **Metrics**.

> **Note:** The API currently does not support fetching metrics for an automation.
