> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.athenaintel.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.athenaintel.com/_mcp/server.

# Replace automation definition

PUT https://api.athenaintel.com/api/v0/automations/{asset_id}/definition
Content-Type: application/json

Replace the automation's draft definition: the server-side counterpart of the Definition tab, written into the same collaborative document, so open editors converge on it live. The document is shape-validated (detail.issues lists every problem); tools, cron and expressions are checked at publish. The draft's last saved snapshot is re-pointed at the new draft so publish reads what was written. Nothing runs until the automation is published.

Reference: https://docs.athenaintel.com/api-reference/automations/update-definition

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Path parameters

- `asset_id` (string, required) — Unique identifier of the automation asset

### Body (application/json)

This endpoint expects an AutomationDefinitionUpdateRequestIn.

- `definition` (map from string to any, required) — The complete draft definition document (schema_version 2; a schema_version 1 document is read through the v1→v2 upgrader). Replaces the draft; nothing runs until the automation is published

## Response

### 200

Draft replaced

- `asset_id` (string, required)
- `snapshot_refreshed` (boolean, required) — Whether the draft's last saved snapshot was re-pointed at the new draft
- `updated_at` (datetime, required) — The updated_at stamp written into the draft
- `message` (string, optional, default: Automation draft updated successfully)
- `snapshot_version_id` (string, optional, nullable)
- `status` (string, optional, default: updated)

## Errors

### 400 Bad Request Error

The document is not a definition

- `detail` (InvalidDefinitionDetailOut, required) — ``detail`` of the 400 a shape-invalid definition returns.

### 403 Forbidden Error

The Automations gate denied, or no edit permission

- `detail` (AutomationsDenialDetailOut, required) — ``detail`` of the 403 the Automations gate returns.

### 404 Not Found Error

Not found, or not an automation

- `message` (string, required)

### 409 Conflict Error

Another server-side replacement of this draft is in progress; retry in a moment

- `any`

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

### 500 Internal Server Error

The draft could not be written; published versions are unaffected

- `any`

## Types

### InvalidDefinitionDetailOut

``detail`` of the 400 a shape-invalid definition returns.

- `issues` (list of DefinitionIssueOut, required) — Every shape problem the parser found, not only the first
- `message` (string, required)
- `code` ("INVALID_AUTOMATION_DEFINITION", optional, default: INVALID_AUTOMATION_DEFINITION)

### AutomationsDenialDetailOut

``detail`` of the 403 the Automations gate returns.

- `hint` (string, required) — The next step that lifts the denial
- `message` (string, required) — Human-readable denial
- `reason` (enum, required) — Which of the gate's three checks failed: the deployment has Automations off, the caller is not a member of the workspace, or the workspace is not enrolled
  - Allowed values: `not_provisioned`, `not_permitted`, `workspace_not_enrolled`
- `code` ("AUTOMATIONS_UNAVAILABLE", optional, default: AUTOMATIONS_UNAVAILABLE) — Stable code for a denial by the Automations gate

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### DefinitionIssueOut

One problem in a definition document, addressed by a JSONPath-like path.

- `message` (string, required) — What is wrong there
- `path` (string, required) — Where in the document

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "definition": {
    "home": {
      "project_asset_id": "asset_project_ops"
    },
    "name": "Nightly exceptions digest",
    "schema_version": 2,
    "steps": [
      {
        "id": "notify",
        "kind": "notify",
        "notify": {
          "body": "'Started by trigger ' & $trigger.id",
          "channels": [
            "email"
          ],
          "subject": "Nightly exceptions digest",
          "to": [
            "user_ops_lead"
          ]
        }
      },
      {
        "end": {
          "status": "succeeded"
        },
        "id": "finish",
        "kind": "end"
      }
    ],
    "triggers": [
      {
        "id": "nightly",
        "kind": "schedule",
        "schedule": {
          "cron": "0 6 * * 1-5",
          "timezone": "America/New_York"
        }
      }
    ]
  }
}
```

**Response**

```json
{
  "asset_id": "string",
  "snapshot_refreshed": true,
  "updated_at": "2024-01-15T09:30:00Z",
  "message": "Automation draft updated successfully",
  "snapshot_version_id": "string",
  "status": "updated"
}
```

**SDK Code**

```python
import requests

url = "https://api.athenaintel.com/api/v0/automations/asset_id/definition"

payload = { "definition": {
        "home": { "project_asset_id": "asset_project_ops" },
        "name": "Nightly exceptions digest",
        "schema_version": 2,
        "steps": [
            {
                "id": "notify",
                "kind": "notify",
                "notify": {
                    "body": "'Started by trigger ' & $trigger.id",
                    "channels": ["email"],
                    "subject": "Nightly exceptions digest",
                    "to": ["user_ops_lead"]
                }
            },
            {
                "end": { "status": "succeeded" },
                "id": "finish",
                "kind": "end"
            }
        ],
        "triggers": [
            {
                "id": "nightly",
                "kind": "schedule",
                "schedule": {
                    "cron": "0 6 * * 1-5",
                    "timezone": "America/New_York"
                }
            }
        ]
    } }
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.athenaintel.com/api/v0/automations/asset_id/definition';
const options = {
  method: 'PUT',
  headers: {'X-API-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"definition":{"home":{"project_asset_id":"asset_project_ops"},"name":"Nightly exceptions digest","schema_version":2,"steps":[{"id":"notify","kind":"notify","notify":{"body":"\'Started by trigger \' & $trigger.id","channels":["email"],"subject":"Nightly exceptions digest","to":["user_ops_lead"]}},{"end":{"status":"succeeded"},"id":"finish","kind":"end"}],"triggers":[{"id":"nightly","kind":"schedule","schedule":{"cron":"0 6 * * 1-5","timezone":"America/New_York"}}]}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.athenaintel.com/api/v0/automations/asset_id/definition"

	payload := strings.NewReader("{\n  \"definition\": {\n    \"home\": {\n      \"project_asset_id\": \"asset_project_ops\"\n    },\n    \"name\": \"Nightly exceptions digest\",\n    \"schema_version\": 2,\n    \"steps\": [\n      {\n        \"id\": \"notify\",\n        \"kind\": \"notify\",\n        \"notify\": {\n          \"body\": \"'Started by trigger ' & $trigger.id\",\n          \"channels\": [\n            \"email\"\n          ],\n          \"subject\": \"Nightly exceptions digest\",\n          \"to\": [\n            \"user_ops_lead\"\n          ]\n        }\n      },\n      {\n        \"end\": {\n          \"status\": \"succeeded\"\n        },\n        \"id\": \"finish\",\n        \"kind\": \"end\"\n      }\n    ],\n    \"triggers\": [\n      {\n        \"id\": \"nightly\",\n        \"kind\": \"schedule\",\n        \"schedule\": {\n          \"cron\": \"0 6 * * 1-5\",\n          \"timezone\": \"America/New_York\"\n        }\n      }\n    ]\n  }\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("X-API-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.athenaintel.com/api/v0/automations/asset_id/definition")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"definition\": {\n    \"home\": {\n      \"project_asset_id\": \"asset_project_ops\"\n    },\n    \"name\": \"Nightly exceptions digest\",\n    \"schema_version\": 2,\n    \"steps\": [\n      {\n        \"id\": \"notify\",\n        \"kind\": \"notify\",\n        \"notify\": {\n          \"body\": \"'Started by trigger ' & $trigger.id\",\n          \"channels\": [\n            \"email\"\n          ],\n          \"subject\": \"Nightly exceptions digest\",\n          \"to\": [\n            \"user_ops_lead\"\n          ]\n        }\n      },\n      {\n        \"end\": {\n          \"status\": \"succeeded\"\n        },\n        \"id\": \"finish\",\n        \"kind\": \"end\"\n      }\n    ],\n    \"triggers\": [\n      {\n        \"id\": \"nightly\",\n        \"kind\": \"schedule\",\n        \"schedule\": {\n          \"cron\": \"0 6 * * 1-5\",\n          \"timezone\": \"America/New_York\"\n        }\n      }\n    ]\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.athenaintel.com/api/v0/automations/asset_id/definition")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"definition\": {\n    \"home\": {\n      \"project_asset_id\": \"asset_project_ops\"\n    },\n    \"name\": \"Nightly exceptions digest\",\n    \"schema_version\": 2,\n    \"steps\": [\n      {\n        \"id\": \"notify\",\n        \"kind\": \"notify\",\n        \"notify\": {\n          \"body\": \"'Started by trigger ' & $trigger.id\",\n          \"channels\": [\n            \"email\"\n          ],\n          \"subject\": \"Nightly exceptions digest\",\n          \"to\": [\n            \"user_ops_lead\"\n          ]\n        }\n      },\n      {\n        \"end\": {\n          \"status\": \"succeeded\"\n        },\n        \"id\": \"finish\",\n        \"kind\": \"end\"\n      }\n    ],\n    \"triggers\": [\n      {\n        \"id\": \"nightly\",\n        \"kind\": \"schedule\",\n        \"schedule\": {\n          \"cron\": \"0 6 * * 1-5\",\n          \"timezone\": \"America/New_York\"\n        }\n      }\n    ]\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.athenaintel.com/api/v0/automations/asset_id/definition', [
  'body' => '{
  "definition": {
    "home": {
      "project_asset_id": "asset_project_ops"
    },
    "name": "Nightly exceptions digest",
    "schema_version": 2,
    "steps": [
      {
        "id": "notify",
        "kind": "notify",
        "notify": {
          "body": "\'Started by trigger \' & $trigger.id",
          "channels": [
            "email"
          ],
          "subject": "Nightly exceptions digest",
          "to": [
            "user_ops_lead"
          ]
        }
      },
      {
        "end": {
          "status": "succeeded"
        },
        "id": "finish",
        "kind": "end"
      }
    ],
    "triggers": [
      {
        "id": "nightly",
        "kind": "schedule",
        "schedule": {
          "cron": "0 6 * * 1-5",
          "timezone": "America/New_York"
        }
      }
    ]
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.athenaintel.com/api/v0/automations/asset_id/definition");
var request = new RestRequest(Method.PUT);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"definition\": {\n    \"home\": {\n      \"project_asset_id\": \"asset_project_ops\"\n    },\n    \"name\": \"Nightly exceptions digest\",\n    \"schema_version\": 2,\n    \"steps\": [\n      {\n        \"id\": \"notify\",\n        \"kind\": \"notify\",\n        \"notify\": {\n          \"body\": \"'Started by trigger ' & $trigger.id\",\n          \"channels\": [\n            \"email\"\n          ],\n          \"subject\": \"Nightly exceptions digest\",\n          \"to\": [\n            \"user_ops_lead\"\n          ]\n        }\n      },\n      {\n        \"end\": {\n          \"status\": \"succeeded\"\n        },\n        \"id\": \"finish\",\n        \"kind\": \"end\"\n      }\n    ],\n    \"triggers\": [\n      {\n        \"id\": \"nightly\",\n        \"kind\": \"schedule\",\n        \"schedule\": {\n          \"cron\": \"0 6 * * 1-5\",\n          \"timezone\": \"America/New_York\"\n        }\n      }\n    ]\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["definition": [
    "home": ["project_asset_id": "asset_project_ops"],
    "name": "Nightly exceptions digest",
    "schema_version": 2,
    "steps": [
      [
        "id": "notify",
        "kind": "notify",
        "notify": [
          "body": "'Started by trigger ' & $trigger.id",
          "channels": ["email"],
          "subject": "Nightly exceptions digest",
          "to": ["user_ops_lead"]
        ]
      ],
      [
        "end": ["status": "succeeded"],
        "id": "finish",
        "kind": "end"
      ]
    ],
    "triggers": [
      [
        "id": "nightly",
        "kind": "schedule",
        "schedule": [
          "cron": "0 6 * * 1-5",
          "timezone": "America/New_York"
        ]
      ]
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.athenaintel.com/api/v0/automations/asset_id/definition")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```