# Scheduled Events

Source: https://docs.autessa.com/docs/api/poweruser/scheduled-events

> Poweruser endpoints for creating, managing, sharing, and auditing scheduled events that invoke agents, invoke tools, or update AutessaDB tables.

# Scheduled Events

Scheduled events run an action on a schedule — invoke an agent, invoke a tool, or update an AutessaDB table. Events fire on a fixed interval, a cron expression, or once at a specific time. These poweruser endpoints cover the full lifecycle: create, update, enable/disable, execution history, sharing, ownership transfer, and deletion.

> All endpoints are `POST` with a JSON body and require an `Authorization` header carrying your poweruser key. The acting user (for ownership, permissions, and sharing) is the user the poweruser key belongs to.

---

## Base URL

```
https://api.autessa.com/autessa_poweruser/scheduled-events
```

---

## Authentication

Pass your poweruser key in the `Authorization` header (no "Bearer" prefix):

```
Authorization: pwrusr:{id}:{secret}
```

Never embed a real key in code — read it from the environment.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/all \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

---

## Schedule expressions

Every event's timing is defined by a `scheduleSpec` object — a discriminated union over the `pattern` field. There are exactly three patterns; only the nested object matching the pattern is present. The spec is compiled into a schedule expression (`rate(...)`, `cron(...)`, or `at(...)`), which is echoed back in the read-only `cronExpression` response field.

### EVERY — fixed interval

Recurring at a fixed interval; maps to `rate(value unit)` (e.g. `rate(30 minutes)`, `rate(1 day)`). Timezone-independent.

```json title="Every 30 minutes"
{ "pattern": "EVERY", "every": { "value": 30, "unit": "MINUTES" } }
```

- `every.value` (integer, required) — Positive integer (>= 1). E.g. `5` for "every 5 minutes".
- `every.unit` (string, required) — One of `MINUTES`, `HOURS`, `DAYS`.

### CRON — recurring at specific times

Recurring on a cron expression evaluated in an IANA timezone; maps to `cron(...)`. The expression is the 6-field AWS cron format:

```
minute hour day-of-month month day-of-week year
```

Rules the backend validates and enforces:

- Exactly 6 space-separated fields — do NOT include the `cron(...)` wrapper.
- Use `?` in exactly one of day-of-month or day-of-week; `*` means "any".
- Day-of-week is `1`=Sunday through `7`=Saturday.
- `timezone` is required and must be a valid IANA name (e.g. `UTC`, `America/Los_Angeles`).

```json title="Daily at 9:00 AM UTC — compiles to cron(0 9 * * ? *)"
{ "pattern": "CRON", "cron": { "expression": "0 9 * * ? *", "timezone": "UTC" } }
```

```json title="Every Monday at 7:00 AM Pacific"
{ "pattern": "CRON", "cron": { "expression": "0 7 ? * 2 *", "timezone": "America/Los_Angeles" } }
```

```json title="First of every month at midnight UTC"
{ "pattern": "CRON", "cron": { "expression": "0 0 1 * ? *", "timezone": "UTC" } }
```

- `cron.expression` (string, required) — 6-field AWS cron expression (minute hour day-of-month month day-of-week year), without the `cron(...)` wrapper.
- `cron.timezone` (string, required) — IANA timezone the expression is evaluated in, e.g. `UTC`, `America/Los_Angeles`.

### ONCE — one-time execution

Fires exactly once at a local wall-clock time in a timezone; maps to `at(yyyy-mm-ddThh:mm:ss)` (the backend converts the local time to UTC before writing the AWS schedule). The time must be in the future.

```json title="One-time: Dec 31 2026, 11:59 PM UTC"
{ "pattern": "ONCE", "once": { "at": "2026-12-31T23:59:00", "timezone": "UTC" } }
```

- `once.at` (string, required) — Local wall-clock ISO-8601 datetime without offset, e.g. `2026-12-31T23:59:00`. Interpreted in `once.timezone`; must be in the future.
- `once.timezone` (string, required) — IANA timezone the wall-clock time is interpreted in.

---

## Action types

The `actionType` field selects what the event does when it fires. Set exactly ONE matching config object (`agentConfig`, `toolConfig`, or `autessaDbConfig`) — the backend rejects requests with zero or multiple configs, and validates the config against the action type.

- `INVOKE_AGENT` (agentConfig) — Execute an agent with predefined input. Runs in single-turn mode (no conversation context) using a system key for your company.
- `INVOKE_TOOL` (toolConfig) — Execute a tool with static parameters defined at schedule creation time.
- `UPDATE_AUTESSADB` (autessaDbConfig) — Perform an INSERT or UPDATE operation on an AutessaDB table with predefined values.

### agentConfig (INVOKE_AGENT)

- `agentExecutionRequest` (object, required) — The agent execution request, executed single-turn when the event fires.
- `agentExecutionRequest.agentId` (string, required) — The agent to execute, e.g. `"V1StGXR8Z5"`.
- `agentExecutionRequest.input` (array<object>, required) — Multimodal input array; must be non-empty. Text input: `{ "inputType": "TEXT", "content": "..." }`.
- `agentExecutionRequest.environmentVariables` (object) — Key-value environment variables passed to the execution.
- `agentExecutionRequest.promptTemplateVariables` (object) — Key-value pairs injected into the agent's prompt template (`@@{variableName}@@` syntax).
- `continueOnError` (boolean) — If `true`, an agent failure is logged but the execution is marked successful. Default `false` (execution marked FAILED on error).
- `description` (string) — Optional description of what this scheduled agent run does.

### toolConfig (INVOKE_TOOL)

- `toolExecutionRequest` (object, required) — The tool execution request, executed as-is when the event fires. No variable substitution from record data — parameters are static.
- `toolExecutionRequest.toolId` (string, required) — The tool to execute, e.g. `"kTn4vB2p9Q"`.
- `toolExecutionRequest.variables` (object) — Key-value tool input variables.
- `toolExecutionRequest.environmentVariables` (object) — Key-value environment variables for the tool run.
- `toolExecutionRequest.privateVariables` (object) — Key-value private variables (not logged).
- `continueOnError` (boolean) — If `true`, a tool failure is logged but the execution is marked successful. Default `false`.
- `description` (string) — Optional description of what this scheduled tool run does.

### autessaDbConfig (UPDATE_AUTESSADB)

- `operation` (string, required) — `INSERT` (add a record with predefined values) or `UPDATE` (modify existing records).
- `targetTableId` (string, required) — The AutessaDB table to write to, e.g. `"aB3xK9mQ2w"`.
- `values` (object, required) — Column values to insert/update. Map of column name to a typed value object, e.g. `{ "status": { "columnType": "SHORT_TEXT", "textValue": "archived" } }`. Value objects carry `columnType` plus the matching field: `textValue`, `integerValue`, `floatValue`, `booleanValue`, `multiSelectValue` (array of strings), or `filePath`.
- `recordId` (integer) — For single-row UPDATE: the specific record ID to update. Mutually exclusive with `whereGroups`. Not allowed for INSERT.
- `whereGroups` (array<object>) — For batch UPDATE: WHERE condition groups matching the records to update. Each group has a `logicalOperator` (`AND`/`OR`) and a `conditions` array. Mutually exclusive with `recordId`. Not allowed for INSERT. UPDATE requires either `recordId` or `whereGroups`.
- `groupsLogicalOperator` (string) — Logical operator between WHERE groups (`AND`/`OR`). Only used with `whereGroups`.
- `skipIfTargetTableMissing` (boolean) — If `true`, skip the execution with a warning when the target table no longer exists. Default `false` (fail).
- `description` (string) — Optional description of what this scheduled DB operation does.

---

## The scheduled event object

Endpoints that return an event (`/all`, `/get`, `/create`, `/update`) use this shape.

- `eventId` (string) — Unique event identifier (UUID string).
- `eventName` (string) — Display name of the event.
- `description` (string) — Description of what the event does.
- `resourceType` (string) — Target resource type derived from the action: `AGENT`, `TOOL`, or `TABLE`.
- `resourceId` (string) — ID of the target resource (the agent, tool, or table the action operates on).
- `isRecurring` (boolean) — `true` for EVERY/CRON schedules, `false` for one-time (ONCE) events.
- `enabled` (boolean) — Whether the schedule is currently active.
- `completed` (boolean) — `true` once a one-time (ONCE) event has fired. Completed events cannot be updated.
- `cronExpression` (string) — Read-only compiled schedule expression, e.g. `cron(0 9 * * ? *)`, `rate(30 minutes)`, or `at(2026-12-31T23:59:00)`.
- `scheduleSpec` (object) — The schedule as submitted — see [Schedule expressions](#schedule-expressions).
- `timezone` (string) — IANA timezone of the schedule (`null` for EVERY schedules, which are timezone-independent).
- `nextExecutionAt` (string) — ISO-8601 timestamp of the next planned execution.
- `lastExecutedAt` (string) — ISO-8601 timestamp of the most recent execution, or `null` if never fired.
- `executionCount` (integer) — Number of times the event has executed.
- `sharingLevel` (string) — `PRIVATE`, `SPECIFIC_MEMBER`, or `COMPANY`. New events start `PRIVATE`.
- `companyPermissionLevel` (string) — Access level granted company-wide when `sharingLevel` is `COMPANY` (`READ`, `WRITE`, `PUBLISH`, or `ADMIN`); otherwise `null`.
- `createdAt` (string) — ISO-8601 creation timestamp.
- `updatedAt` (string) — ISO-8601 last-modified timestamp.
- `userPermission` (string) — Your access level on this event: `READ`, `WRITE`, `PUBLISH`, or `ADMIN`.
- `actionType` (string) — `INVOKE_AGENT`, `INVOKE_TOOL`, or `UPDATE_AUTESSADB` — see [Action types](#action-types).
- `agentConfig` (object) — Present when `actionType` is `INVOKE_AGENT`.
- `toolConfig` (object) — Present when `actionType` is `INVOKE_TOOL`.
- `autessaDbConfig` (object) — Present when `actionType` is `UPDATE_AUTESSADB`.

```json title="JSON"
{
  "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
  "eventName": "Daily summary",
  "description": "Runs the reporting agent every morning",
  "resourceType": "AGENT",
  "resourceId": "V1StGXR8Z5",
  "isRecurring": true,
  "enabled": true,
  "completed": false,
  "cronExpression": "cron(0 9 * * ? *)",
  "scheduleSpec": {
    "pattern": "CRON",
    "cron": { "expression": "0 9 * * ? *", "timezone": "UTC" }
  },
  "timezone": "UTC",
  "nextExecutionAt": "2026-07-02T09:00:00",
  "lastExecutedAt": "2026-07-01T09:00:00",
  "executionCount": 42,
  "sharingLevel": "PRIVATE",
  "companyPermissionLevel": null,
  "createdAt": "2026-05-14T18:22:10",
  "updatedAt": "2026-06-30T08:15:44",
  "userPermission": "ADMIN",
  "actionType": "INVOKE_AGENT",
  "agentConfig": {
    "agentExecutionRequest": {
      "agentId": "V1StGXR8Z5",
      "input": [
        { "inputType": "TEXT", "content": "Generate the daily summary report." }
      ]
    },
    "continueOnError": false,
    "description": "Daily summary agent run"
  }
}
```

---

## List All Events **POST** `/all`

Returns every scheduled event visible to you in the current company scope, split into three buckets: events you own, events shared company-wide, and events shared with you individually.

### Request Body

- `(none)` (object) — Send an empty JSON object `{}`.

### Response

- `ownedEvents` (array<object>) — Events you own. Each entry is a [scheduled event object](#the-scheduled-event-object); `userPermission` is `ADMIN`.
- `companySharedEvents` (array<object>) — Events shared with the whole company; `userPermission` reflects the company-wide access level.
- `sharedWithMeEvents` (array<object>) — Events shared with you specifically; `userPermission` reflects your individual grant.
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/all \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```json title="JSON"
{
  "ownedEvents": [
    {
      "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
      "eventName": "Daily summary",
      "resourceType": "AGENT",
      "resourceId": "V1StGXR8Z5",
      "isRecurring": true,
      "enabled": true,
      "completed": false,
      "cronExpression": "cron(0 9 * * ? *)",
      "scheduleSpec": {
        "pattern": "CRON",
        "cron": { "expression": "0 9 * * ? *", "timezone": "UTC" }
      },
      "timezone": "UTC",
      "nextExecutionAt": "2026-07-02T09:00:00",
      "executionCount": 42,
      "sharingLevel": "PRIVATE",
      "userPermission": "ADMIN",
      "actionType": "INVOKE_AGENT",
      "agentConfig": {
        "agentExecutionRequest": {
          "agentId": "V1StGXR8Z5",
          "input": [
            { "inputType": "TEXT", "content": "Generate the daily summary report." }
          ]
        },
        "continueOnError": false
      }
    }
  ],
  "companySharedEvents": [],
  "sharedWithMeEvents": []
}
```

---

## Get Event **POST** `/get`

Fetches a single scheduled event by ID. You must have at least READ access (owner, individual share, or company share); otherwise the call returns `401` with an error.

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID) to fetch.

### Response

- `permission` (string) — Your access level on the event: `READ`, `WRITE`, `PUBLISH`, or `ADMIN`.
- `scheduledEvent` (object) — The [scheduled event object](#the-scheduled-event-object).
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/get \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c"
  }'
```

```json title="JSON"
{
  "permission": "ADMIN",
  "scheduledEvent": {
    "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "eventName": "Daily summary",
    "description": "Runs the reporting agent every morning",
    "resourceType": "AGENT",
    "resourceId": "V1StGXR8Z5",
    "isRecurring": true,
    "enabled": true,
    "completed": false,
    "cronExpression": "cron(0 9 * * ? *)",
    "scheduleSpec": {
      "pattern": "CRON",
      "cron": { "expression": "0 9 * * ? *", "timezone": "UTC" }
    },
    "timezone": "UTC",
    "nextExecutionAt": "2026-07-02T09:00:00",
    "lastExecutedAt": "2026-07-01T09:00:00",
    "executionCount": 42,
    "sharingLevel": "PRIVATE",
    "companyPermissionLevel": null,
    "createdAt": "2026-05-14T18:22:10",
    "updatedAt": "2026-06-30T08:15:44",
    "userPermission": "ADMIN",
    "actionType": "INVOKE_AGENT",
    "agentConfig": {
      "agentExecutionRequest": {
        "agentId": "V1StGXR8Z5",
        "input": [
          { "inputType": "TEXT", "content": "Generate the daily summary report." }
        ]
      },
      "continueOnError": false
    }
  }
}
```

---

## Create Event **POST** `/create`

Creates a scheduled event. Creation is all-or-nothing — if any part of it fails, nothing is created and the error is returned. You become the event's owner with `ADMIN` permission; new events start with `PRIVATE` sharing.

Set `actionType` and exactly ONE matching config object — see [Action types](#action-types) for each config's fields.

### Request Body

- `eventName` (string, required) — Display name for the event. Must be non-blank.
- `description` (string) — Description of what the event does.
- `scheduleSpec` (object, required) — When the event fires — see [Schedule expressions](#schedule-expressions).
- `enabled` (boolean) — Whether the event is active immediately. Default `true`.
- `actionType` (string, required) — `INVOKE_AGENT`, `INVOKE_TOOL`, or `UPDATE_AUTESSADB`.
- `agentConfig` (object) — Required when `actionType` is `INVOKE_AGENT` — see [agentConfig](#agentconfig-invoke_agent).
- `toolConfig` (object) — Required when `actionType` is `INVOKE_TOOL` — see [toolConfig](#toolconfig-invoke_tool).
- `autessaDbConfig` (object) — Required when `actionType` is `UPDATE_AUTESSADB` — see [autessaDbConfig](#autessadbconfig-update_autessadb).

### Response

- `scheduledEvent` (object) — The created [scheduled event object](#the-scheduled-event-object).
- `eventId` (string) — The new event's ID (UUID).
- `scheduleArn` (string) — ARN of the underlying schedule.
- `errors` (array<string>) — Error messages; absent on success.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/scheduled-events/create \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "eventName": "Daily summary",
    "description": "Runs the reporting agent every morning",
    "scheduleSpec": {
      "pattern": "CRON",
      "cron": { "expression": "0 9 * * ? *", "timezone": "UTC" }
    },
    "enabled": true,
    "actionType": "INVOKE_AGENT",
    "agentConfig": {
      "agentExecutionRequest": {
        "agentId": "V1StGXR8Z5",
        "input": [
          { "inputType": "TEXT", "content": "Generate the daily summary report." }
        ],
        "promptTemplateVariables": { "team": "Sales" }
      },
      "continueOnError": false,
      "description": "Daily summary agent run"
    }
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/scheduled-events/create',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      eventName: 'Daily summary',
      description: 'Runs the reporting agent every morning',
      scheduleSpec: {
        pattern: 'CRON',
        cron: { expression: '0 9 * * ? *', timezone: 'UTC' }
      },
      enabled: true,
      actionType: 'INVOKE_AGENT',
      agentConfig: {
        agentExecutionRequest: {
          agentId: 'V1StGXR8Z5',
          input: [
            { inputType: 'TEXT', content: 'Generate the daily summary report.' }
          ],
          promptTemplateVariables: { team: 'Sales' }
        },
        continueOnError: false,
        description: 'Daily summary agent run'
      }
    })
  }
);

const data = await response.json();
console.log(data.eventId);
```

**Python:**

```python
import os
import requests

response = requests.post(
    "https://api.autessa.com/autessa_poweruser/scheduled-events/create",
    headers={"Authorization": os.environ["POWERUSER_KEY"]},
    json={
        "eventName": "Daily summary",
        "description": "Runs the reporting agent every morning",
        "scheduleSpec": {
            "pattern": "CRON",
            "cron": {"expression": "0 9 * * ? *", "timezone": "UTC"},
        },
        "enabled": True,
        "actionType": "INVOKE_AGENT",
        "agentConfig": {
            "agentExecutionRequest": {
                "agentId": "V1StGXR8Z5",
                "input": [
                    {"inputType": "TEXT", "content": "Generate the daily summary report."}
                ],
                "promptTemplateVariables": {"team": "Sales"},
            },
            "continueOnError": False,
            "description": "Daily summary agent run",
        },
    },
)

data = response.json()
print(data["eventId"])
```

```json title="JSON"
{
  "scheduledEvent": {
    "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "eventName": "Daily summary",
    "description": "Runs the reporting agent every morning",
    "resourceType": "AGENT",
    "resourceId": "V1StGXR8Z5",
    "isRecurring": true,
    "enabled": true,
    "completed": false,
    "cronExpression": "cron(0 9 * * ? *)",
    "scheduleSpec": {
      "pattern": "CRON",
      "cron": { "expression": "0 9 * * ? *", "timezone": "UTC" }
    },
    "timezone": "UTC",
    "nextExecutionAt": "2026-07-02T09:00:00",
    "executionCount": 0,
    "sharingLevel": "PRIVATE",
    "userPermission": "ADMIN",
    "actionType": "INVOKE_AGENT",
    "agentConfig": {
      "agentExecutionRequest": {
        "agentId": "V1StGXR8Z5",
        "input": [
          { "inputType": "TEXT", "content": "Generate the daily summary report." }
        ],
        "promptTemplateVariables": { "team": "Sales" }
      },
      "continueOnError": false,
      "description": "Daily summary agent run"
    }
  },
  "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
  "scheduleArn": "arn:aws:scheduler:us-east-1:123456789012:schedule/default/3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c"
}
```

---

## Update Event **POST** `/update`

Replaces an event's definition. This is a full replacement, not a patch: `scheduleSpec`, `actionType`, and the matching action config are re-validated and must all be supplied. Requires `WRITE` or `ADMIN` access. Completed one-time events and deleted events cannot be updated.

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID) to update.
- `eventName` (string) — New display name.
- `description` (string) — New description.
- `scheduleSpec` (object, required) — The new schedule — see [Schedule expressions](#schedule-expressions). The next execution time is recalculated when the schedule changes.
- `actionType` (string, required) — `INVOKE_AGENT`, `INVOKE_TOOL`, or `UPDATE_AUTESSADB`.
- `agentConfig` (object) — Required when `actionType` is `INVOKE_AGENT` — see [agentConfig](#agentconfig-invoke_agent).
- `toolConfig` (object) — Required when `actionType` is `INVOKE_TOOL` — see [toolConfig](#toolconfig-invoke_tool).
- `autessaDbConfig` (object) — Required when `actionType` is `UPDATE_AUTESSADB` — see [autessaDbConfig](#autessadbconfig-update_autessadb).

### Response

- `scheduledEvent` (object) — The updated [scheduled event object](#the-scheduled-event-object).
- `errors` (array<string>) — Error messages; absent on success.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/scheduled-events/update \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "eventName": "CRM sync",
    "description": "Sync CRM records every 30 minutes",
    "scheduleSpec": {
      "pattern": "EVERY",
      "every": { "value": 30, "unit": "MINUTES" }
    },
    "actionType": "INVOKE_TOOL",
    "toolConfig": {
      "toolExecutionRequest": {
        "toolId": "kTn4vB2p9Q",
        "variables": { "mode": "incremental" }
      },
      "continueOnError": true
    }
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/scheduled-events/update',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      scheduledEventId: '3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c',
      eventName: 'CRM sync',
      description: 'Sync CRM records every 30 minutes',
      scheduleSpec: {
        pattern: 'EVERY',
        every: { value: 30, unit: 'MINUTES' }
      },
      actionType: 'INVOKE_TOOL',
      toolConfig: {
        toolExecutionRequest: {
          toolId: 'kTn4vB2p9Q',
          variables: { mode: 'incremental' }
        },
        continueOnError: true
      }
    })
  }
);

const data = await response.json();
```

**Python:**

```python
import os
import requests

response = requests.post(
    "https://api.autessa.com/autessa_poweruser/scheduled-events/update",
    headers={"Authorization": os.environ["POWERUSER_KEY"]},
    json={
        "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
        "eventName": "CRM sync",
        "description": "Sync CRM records every 30 minutes",
        "scheduleSpec": {
            "pattern": "EVERY",
            "every": {"value": 30, "unit": "MINUTES"},
        },
        "actionType": "INVOKE_TOOL",
        "toolConfig": {
            "toolExecutionRequest": {
                "toolId": "kTn4vB2p9Q",
                "variables": {"mode": "incremental"},
            },
            "continueOnError": True,
        },
    },
)

data = response.json()
```

```json title="JSON"
{
  "scheduledEvent": {
    "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "eventName": "CRM sync",
    "description": "Sync CRM records every 30 minutes",
    "resourceType": "TOOL",
    "resourceId": "kTn4vB2p9Q",
    "isRecurring": true,
    "enabled": true,
    "completed": false,
    "cronExpression": "rate(30 minutes)",
    "scheduleSpec": {
      "pattern": "EVERY",
      "every": { "value": 30, "unit": "MINUTES" }
    },
    "timezone": null,
    "nextExecutionAt": "2026-07-01T12:30:00",
    "executionCount": 42,
    "sharingLevel": "PRIVATE",
    "userPermission": "ADMIN",
    "actionType": "INVOKE_TOOL",
    "toolConfig": {
      "toolExecutionRequest": {
        "toolId": "kTn4vB2p9Q",
        "variables": { "mode": "incremental" }
      },
      "continueOnError": true
    }
  }
}
```

---

## Toggle Event **POST** `/toggle`

Enables or disables an event without changing its definition. Disabled events stay in place (schedule, config, history) but do not fire. Requires `WRITE` or `ADMIN` access.

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID) to toggle.
- `enabled` (boolean, required) — `true` to enable, `false` to disable.

### Response

- `eventId` (string) — The toggled event's ID.
- `enabled` (boolean) — The new enabled state.
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/toggle \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "enabled": false
  }'
```

```json title="JSON"
{
  "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
  "enabled": false
}
```

---

## Get Execution History **POST** `/history`

Returns paginated execution history plus monthly statistics. Pass `scheduledEventId` to scope to one event (requires at least READ access to it), or omit it for history across all of your company's events. Results cover one calendar month (defaults to the current month), sorted newest first, 50 per page.

### Request Body

- `scheduledEventId` (string) — Optional event ID (UUID). When omitted, history for all company events is returned.
- `page` (integer) — Zero-based page number. Default `0`. Page size is fixed at 50.
- `month` (integer) — Calendar month 1-12. Both `month` and `year` must be set to select a month; otherwise the current month is used.
- `year` (integer) — Calendar year, e.g. `2026`.

### Response

- `executions` (array<object>) — Execution records for the page — fields below.
- `totalElements` (integer) — Number of executions returned after filtering.
- `totalPages` (integer) — Total pages available for the month.
- `currentPage` (integer) — Zero-based index of this page.
- `pageSize` (integer) — Page size (50).
- `hasNext` (boolean) — Whether a next page exists.
- `hasPrevious` (boolean) — Whether a previous page exists.
- `successCount` (integer) — Number of `SUCCESS` executions in the month (for the selected scope).
- `failedCount` (integer) — Number of `FAILED` executions in the month.
- `successRate` (float) — Fraction of month executions that succeeded, `0.0`-`1.0`.
- `averageDurationMs` (float) — Average execution duration in milliseconds. Only populated when `scheduledEventId` is provided; `null` for company-wide queries.
- `errors` (array<string>) — Error messages; absent on success.

#### Execution record fields

- `id` (string) — Unique execution record ID (UUID).
- `scheduledEventId` (string) — ID of the scheduled event that fired.
- `eventName` (string) — Event name at execution time.
- `resourceType` (string) — Target resource type: `AGENT`, `TOOL`, or `TABLE`.
- `resourceId` (string) — ID of the target resource.
- `startedAt` (string) — ISO-8601 timestamp when execution started.
- `endedAt` (string) — ISO-8601 timestamp when execution finished.
- `durationMs` (integer) — Execution duration in milliseconds.
- `status` (string) — `SUCCESS` or `FAILED`.
- `errorMessage` (string) — Failure reason when `status` is `FAILED`; `null` otherwise.
- `scheduledFireTime` (string) — ISO-8601 timestamp the event was scheduled to fire.
- `actualFireTime` (string) — ISO-8601 timestamp the event actually fired.
- `attemptNumber` (integer) — Retry attempt number (1 for the first attempt).
- `payloadJson` (string) — JSON string of the action payload that was executed.
- `responseJson` (string) — JSON string of the action's response.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/scheduled-events/history \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "page": 0,
    "month": 6,
    "year": 2026
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/scheduled-events/history',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      scheduledEventId: '3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c',
      page: 0,
      month: 6,
      year: 2026
    })
  }
);

const data = await response.json();
console.log(`${data.successCount} succeeded, ${data.failedCount} failed`);
```

**Python:**

```python
import os
import requests

response = requests.post(
    "https://api.autessa.com/autessa_poweruser/scheduled-events/history",
    headers={"Authorization": os.environ["POWERUSER_KEY"]},
    json={
        "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
        "page": 0,
        "month": 6,
        "year": 2026,
    },
)

data = response.json()
print(f"{data['successCount']} succeeded, {data['failedCount']} failed")
```

```json title="JSON"
{
  "executions": [
    {
      "id": "9c4d1e7f-2a3b-4c5d-8e9f-0a1b2c3d4e5f",
      "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
      "eventName": "Daily summary",
      "resourceType": "AGENT",
      "resourceId": "V1StGXR8Z5",
      "startedAt": "2026-06-30T09:00:01",
      "endedAt": "2026-06-30T09:00:14",
      "durationMs": 13204,
      "status": "SUCCESS",
      "errorMessage": null,
      "scheduledFireTime": "2026-06-30T09:00:00",
      "actualFireTime": "2026-06-30T09:00:01",
      "attemptNumber": 1,
      "payloadJson": "{\"agentExecutionRequest\":{\"agentId\":\"V1StGXR8Z5\"}}",
      "responseJson": "{\"output\":[{\"outputType\":\"TEXT\",\"content\":\"Summary sent.\"}]}"
    }
  ],
  "totalElements": 30,
  "totalPages": 1,
  "currentPage": 0,
  "pageSize": 50,
  "hasNext": false,
  "hasPrevious": false,
  "successCount": 29,
  "failedCount": 1,
  "successRate": 0.9666666666666667,
  "averageDurationMs": 12841.5
}
```

---

## Delete Event **POST** `/delete`

Deletes a scheduled event. The AWS schedule is removed first, then the event is soft-deleted (execution history is retained). Requires `ADMIN` access. The operation is idempotent with respect to the AWS schedule.

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID) to delete.

### Response

- `eventId` (string) — The deleted event's ID.
- `deletedAt` (string) — ISO-8601 timestamp of the deletion.
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/delete \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c"
  }'
```

```json title="JSON"
{
  "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
  "deletedAt": "2026-07-01T15:42:07"
}
```

---

## Share Event **POST** `/share`

Updates an event's sharing settings. Requires `ADMIN` access. Set `level` to `COMPANY` with an `accessLevel` to share company-wide, or `SPECIFIC_MEMBER` with `usersToAdd`/`usersToRemove` for individual grants, or `PRIVATE` to unshare.

> This endpoint changes the same sharing as the [Share dialog](/docs/guide/platform/sharing.md). Sharing with `COMPANY` adds a company-wide grant and keeps everyone already shared individually at their own level. People get the highest level from any grant that covers them.

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID) to share.
- `level` (string, required) — Target sharing level: `PRIVATE`, `SPECIFIC_MEMBER`, or `COMPANY`.
- `accessLevel` (string) — Company-wide access level when `level` is `COMPANY`: `READ`, `WRITE`, `PUBLISH`, or `ADMIN`.
- `usersToAdd` (array<object>) — Users to grant access to. Each entry: `userEmail` (string), `userId` (string, e.g. `"uK4pT7vB1z"`), `accessLevel` (string).
- `usersToRemove` (array<object>) — Users whose access to revoke; same entry shape as `usersToAdd`.

### Response

- `eventId` (string) — The event's ID.
- `sharingLevel` (string) — The event's sharing level after the update.
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/share \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "level": "SPECIFIC_MEMBER",
    "usersToAdd": [
      {
        "userEmail": "teammate@example.com",
        "userId": "uK4pT7vB1z",
        "accessLevel": "WRITE"
      }
    ],
    "usersToRemove": []
  }'
```

```json title="JSON"
{
  "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
  "sharingLevel": "SPECIFIC_MEMBER"
}
```

---

## Get Sharing Details **POST** `/get-sharing-details`

Returns the current sharing configuration for an event. You must have at least READ access.

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID).

### Response

- `sharingLevel` (string) — `PRIVATE`, `SPECIFIC_MEMBER`, or `COMPANY`.
- `companyPermissionLevel` (string) — Company-wide access level when shared with the company; `null` otherwise.
- `sharedWith` (array<object>) — Individual grants. Each entry: `userEmail` (string), `userId` (string), `accessLevel` (string).
- `userAccessLevel` (string) — Your access level on the event.
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/get-sharing-details \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c"
  }'
```

```json title="JSON"
{
  "sharingLevel": "SPECIFIC_MEMBER",
  "companyPermissionLevel": null,
  "sharedWith": [
    {
      "userEmail": "teammate@example.com",
      "userId": "uK4pT7vB1z",
      "accessLevel": "WRITE"
    }
  ],
  "userAccessLevel": "ADMIN"
}
```

---

## Transfer Ownership **POST** `/transfer-ownership`

Transfers ownership of an event to another user. Only the current owner can transfer, and the new owner must already have access to the event (share it with them first via [/share](#share-event-)).

### Request Body

- `scheduledEventId` (string, required) — The event ID (UUID).
- `newOwnerId` (string, required) — ID of the user receiving ownership, e.g. `"uK4pT7vB1z"`.

### Response

- `eventId` (string) — The event's ID.
- `newOwnerId` (string) — ID of the new owner.
- `errors` (array<string>) — Error messages; absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/scheduled-events/transfer-ownership \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduledEventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
    "newOwnerId": "uK4pT7vB1z"
  }'
```

```json title="JSON"
{
  "eventId": "3f8a2c1e-9b4d-4a7e-b2c5-6d1e8f0a9b3c",
  "newOwnerId": "uK4pT7vB1z"
}
```

---

## Errors

Failures return the `errors` array (`array<string>` of human-readable messages); it is absent on success. Server-side exceptions are caught and folded into `errors` rather than surfacing as raw stack traces. When `errors` is present the HTTP status is non-2xx.

- `401` — invalid or missing poweruser key, or insufficient access to the event (e.g. updating without WRITE, deleting or sharing without ADMIN, transferring when you are not the owner).
- Validation failures (blank `eventName`, malformed `scheduleSpec`, missing/mismatched action config, cron expression not 6 fields, `once.at` in the past, invalid IANA timezone, UPDATE without `recordId` or `whereGroups`) return the specific message in `errors`.
- Update/delete of a missing, deleted, or completed one-time event returns `errors` with the reason.

```json title="Error response"
{
  "errors": [
    "User does not have write access to this scheduled event"
  ]
}
```

---

## Related

- [Poweruser API overview](/docs/api/poweruser.md)
- [Scheduled Events client API](/docs/api/scheduled-events.md)
- [Scheduled jobs guide](/docs/guide/scheduled-jobs.md)
- [Poweruser Agents API](/docs/api/poweruser/agents.md)
- [Poweruser Tools API](/docs/api/poweruser/tools.md)
- [Poweruser AutessaDB Tables API](/docs/api/poweruser/autessadb-tables.md)

