# Update Automation

> PATCH /automations/:id — rename, enable or disable, re-point the domain or trigger, or replace the connection graph.

`PATCH /automations/:id`

Updates an automation. Set `status` to `enabled` to start creating runs for matching events, or `disabled` to stop new runs. You can also rename via `name`, re-point the sending `domain` or the `trigger` event, and replace the connection graph via `connections`. Returns the full updated automation object, including steps and connections.

**Body parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | A new name for the automation. |
| `status` | string | No | One of `enabled` or `disabled`. Enabling requires at least one step besides the trigger. |
| `domain` | string | No | Re-point the automation at another of your sending domains. Only allowed while the automation is `disabled`. Re-pointing also moves the contact pool to the new domain's. |
| `trigger` | string | No | Re-point the trigger at a different event name. Only allowed while the automation is `disabled`. Must not start with the reserved `mailblastr:` prefix. |
| `trigger_key` | string | No | Optional key for the trigger step in the graph (used by the canvas editor). Only meaningful alongside `trigger`; defaults to the existing key, or `trigger`. |
| `connections` | array | No | Replaces the [connections](https://www.mailblastr.com/docs/automations/connections) between steps. Only allowed while the automation is `disabled`. Cyclic graphs are rejected. |

> **Note:** Structural edits — steps, connections, `trigger`, and `domain` — require the automation to be **disabled**. Disable it first, make your changes, then re-enable it.

**Node.js**

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

const mb = new MailBlastr('mb_xxxxxxxxx');

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

**Ruby**

```ruby
require "mailblastr"

Mailblastr.api_key = "mb_xxxxxxxxx"

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

**PHP**

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

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

**Python**

```python
import mailblastr

mailblastr.api_key = "mb_xxxxxxxxx"

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

**Go**

```go
package main

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

func main() {
    req, _ := http.NewRequest("PATCH", "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd", strings.NewReader(`{ "status": "enabled" }`))
    req.Header.Set("Authorization", "Bearer mb_xxxxxxxxx")
    req.Header.Set("Content-Type", "application/json")
    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()
        .patch("https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd")
        .header("Authorization", "Bearer mb_xxxxxxxxx")
        .header("Content-Type", "application/json")
        .body(r#"{ "status": "enabled" }"#)
        .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"))
    .header("Authorization", "Bearer mb_xxxxxxxxx")
    .header("Content-Type", "application/json")
    .method("PATCH", HttpRequest.BodyPublishers.ofString("""
{ "status": "enabled" }
"""))
    .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.Patch, "https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd");
request.Headers.Add("Authorization", "Bearer mb_xxxxxxxxx");
request.Content = new StringContent(@"{ ""status"": ""enabled"" }", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

**cURL**

```bash
curl -X PATCH 'https://api.mailblastr.com/automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{ "status": "enabled" }'
```

**CLI**

```bash
mailblastr automations update c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd \
  --status 'enabled'
```

### Response

```json
{
  "object": "automation",
  "id": "c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd",
  "audience_id": "aud_3b1c...",
  "domain": "yourdomain.com",
  "name": "Welcome series",
  "trigger": "user.created",
  "status": "enabled",
  "steps": [
    {
      "key": "start",
      "type": "trigger",
      "config": { "event_name": "user.created" }
    },
    {
      "id": "9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
      "key": "welcome",
      "type": "send_email",
      "position": 0,
      "config": {
        "template": { "id": "34a080c9-b17d-4187-ad80-5af20266e535" }
      }
    }
  ],
  "connections": [
    { "from": "start", "to": "welcome", "type": "default" }
  ],
  "created_at": "2026-06-23T10:00:00.000Z",
  "updated_at": "2026-06-23T10:01:00.000Z"
}
```
