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

# Create an automation

POST https://api.cloudraker.com/organization/automations
Content-Type: application/json

Creates an agent task: a stored prompt plus a cadence (`cron` with an IANA timezone, a `once` instant, or `manual` for trigger-only). When it fires it drops a message into a real thread you can join, nudge and correct — not a hidden pipeline. Omit `spaceId` for your own desk; a named space needs `space:contribute` for you AND for the owner the automation runs as. The inbound trigger secret is returned ONCE, here. Authorization: organization admin.

Reference: https://docs.cloudraker.com/api/cloud-raker-api/workspace/org-automations/create-automation

## Authentication

- `Authorization` header (bearer token, required)

## Request

### Body (application/json)

- `name` (string, required)
- `prompt` (string, required) — The user message injected into the thread when the automation fires.
- `schedule` (object or object or object, required)
  - object
    - `kind` ("cron", required)
    - `expression` (string, required)
    - `timezone` (string, required)
  - object
    - `kind` ("once", required)
    - `at` (datetime, required)
  - object
    - `kind` ("manual", required)
- `description` (string, optional)
- `playbookId` (string, optional)
- `fileIds` (list of string, optional)
- `spaceId` (string, optional)
- `threadPolicy` (enum, optional, default: reuse)
  - Allowed values: `reuse`, `new`
- `enabled` (boolean, optional, default: true)
- `triggerEnabled` (boolean, optional, default: false)
- `originThreadId` (string, optional)

## Response

### 201

The automation and its one-time trigger secret.

- `automation` (object, required)
  - `_id` (string, required)
  - `name` (string, required)
  - `kind` (enum, required)
    - Allowed values: `agent_task`
  - `enabled` (boolean, required)
  - `playbookId` (string, required)
  - `prompt` (string, required)
  - `spaceId` (string, required)
  - `threadPolicy` (enum, required)
    - Allowed values: `reuse`, `new`
  - `runAs` (string, required)
  - `createdBy` (string, required)
  - `organizationId` (string, required)
  - `schedule` (object or object or object, required)
    - object
      - `kind` ("cron", required)
      - `expression` (string, required)
      - `timezone` (string, required)
    - object
      - `kind` ("once", required)
      - `at` (datetime, required)
    - object
      - `kind` ("manual", required)
  - `nextRunAt` (string, required, nullable)
  - `trigger` (object, required)
    - `enabled` (boolean, required)
    - `secretPreview` (string, required)
    - `secretRotatedAt` (string, optional)
  - `createdAt` (string, required)
  - `updatedAt` (string, required)
  - `runtimeStatus` (enum, required)
    - Allowed values: `idle`, `disabled`, `needs_input`, `blocked`, `error`
  - `cadence` (string, required)
  - `triggerRef` (string, required)
  - `description` (string, optional)
  - `fileIds` (list of string, optional)
  - `threadId` (string, optional)
  - `lastFiredAt` (string, optional)
  - `lastRunStatus` (enum, optional)
    - Allowed values: `started`, `success`, `busy`, `needs_input`, `blocked`, `error`
  - `lastRunId` (string, optional)
  - `originThreadId` (string, optional)
- `secret` (string, required)

## Examples

**Request**

```json
{
  "name": "Monday inbox sweep",
  "prompt": "string",
  "schedule": {
    "kind": "string",
    "expression": "0 9 * * 1-5",
    "timezone": "Europe/Paris"
  }
}
```

**Response**

```json
{
  "automation": {
    "_id": "string",
    "name": "string",
    "kind": "agent_task",
    "enabled": true,
    "playbookId": "string",
    "prompt": "string",
    "spaceId": "string",
    "threadPolicy": "reuse",
    "runAs": "string",
    "createdBy": "string",
    "organizationId": "string",
    "schedule": {
      "kind": "string",
      "expression": "0 9 * * 1-5",
      "timezone": "Europe/Paris"
    },
    "nextRunAt": "string",
    "trigger": {
      "enabled": true,
      "secretPreview": "whsec_…9f3a",
      "secretRotatedAt": "string"
    },
    "createdAt": "string",
    "updatedAt": "string",
    "runtimeStatus": "idle",
    "cadence": "string",
    "triggerRef": "string",
    "description": "string",
    "fileIds": [
      "string"
    ],
    "threadId": "string",
    "lastFiredAt": "string",
    "lastRunStatus": "started",
    "lastRunId": "string",
    "originThreadId": "string"
  },
  "secret": "string"
}
```

**SDK Code**

```typescript
import { CloudRakerClient } from "@cloudraker/api";

async function main() {
    const client = new CloudRakerClient({
        token: "YOUR_TOKEN_HERE",
    });
    await client.orgAutomations.createAutomation({
        name: "Monday inbox sweep",
        prompt: "string",
    });
}
main();

```

```python
from cloudraker import CloudRaker

client = CloudRaker(
    token="YOUR_TOKEN_HERE",
)

client.org_automations.create_automation(
    name="Monday inbox sweep",
    prompt="string",
)

```

```go
package main

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

func main() {

	url := "https://api.cloudraker.com/organization/automations"

	payload := strings.NewReader("{\n  \"name\": \"Monday inbox sweep\",\n  \"prompt\": \"string\",\n  \"schedule\": {\n    \"kind\": \"string\",\n    \"expression\": \"0 9 * * 1-5\",\n    \"timezone\": \"Europe/Paris\"\n  }\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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.cloudraker.com/organization/automations")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Monday inbox sweep\",\n  \"prompt\": \"string\",\n  \"schedule\": {\n    \"kind\": \"string\",\n    \"expression\": \"0 9 * * 1-5\",\n    \"timezone\": \"Europe/Paris\"\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.post("https://api.cloudraker.com/organization/automations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Monday inbox sweep\",\n  \"prompt\": \"string\",\n  \"schedule\": {\n    \"kind\": \"string\",\n    \"expression\": \"0 9 * * 1-5\",\n    \"timezone\": \"Europe/Paris\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/organization/automations', [
  'body' => '{
  "name": "Monday inbox sweep",
  "prompt": "string",
  "schedule": {
    "kind": "string",
    "expression": "0 9 * * 1-5",
    "timezone": "Europe/Paris"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/organization/automations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Monday inbox sweep\",\n  \"prompt\": \"string\",\n  \"schedule\": {\n    \"kind\": \"string\",\n    \"expression\": \"0 9 * * 1-5\",\n    \"timezone\": \"Europe/Paris\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Monday inbox sweep",
  "prompt": "string",
  "schedule": [
    "kind": "string",
    "expression": "0 9 * * 1-5",
    "timezone": "Europe/Paris"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/organization/automations")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```