# Scheduled Events API

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

> Complete API reference for creating, managing, and scheduling automated events for agents, tools, and database operations.

# Scheduled Events API

The Scheduled Events API allows you to create and manage automated recurring or one-time events that execute agents, tools, or database operations on a schedule. All events created via the client API are automatically shared company-wide with ADMIN permissions.
> All Scheduled Events API requests require an `Authorization` header with your API key. Events created through this API are automatically set to COMPANY-WIDE access with ADMIN permissions.

---

## Base URL

```
REST API:   https://api.autessa.com/clients/scheduled-events
```

---

## Authentication

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

```
Authorization: your_api_key_here
```

> The API key must have permissions to access the target resources (agents, tools, or tables) that the scheduled event will interact with.

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

---

## Schedule Specs

The schedule is described by the `scheduleSpec` object — a tagged union over the `pattern` field. There are exactly three patterns; only the nested object matching the pattern is present:

### EVERY
For recurring events at a fixed interval. `every.value` is a positive integer and `every.unit` is one of `MINUTES`, `HOURS`, or `DAYS`. Timezone-independent.
```json
{ "pattern": "EVERY", "every": { "value": 6, "unit": "HOURS" } }
```

### CRON
For recurring events at specific times, evaluated in an IANA timezone. `cron.expression` is a 6-field AWS cron expression (`minute hour day-of-month month day-of-week year`) without the `cron(...)` wrapper; use `?` in exactly one of day-of-month or day-of-week. `cron.timezone` is required.
```json
{ "pattern": "CRON", "cron": { "expression": "0 9 * * ? *", "timezone": "America/New_York" } }
```

### ONCE
For one-time execution at a local wall-clock time in an IANA timezone. `once.at` is a local ISO-8601 datetime without offset and must be in the future.
```json
{ "pattern": "ONCE", "once": { "at": "2026-12-31T23:59:59", "timezone": "UTC" } }
```

---

## Action Types

Scheduled events can perform three types of actions:

- `INVOKE_AGENT` — Execute an agent with predefined input. The agent runs in single-turn mode with no conversation context.
- `INVOKE_TOOL` — Execute a tool with static parameters defined at schedule creation time.
- `UPDATE_AUTESSADB` — Perform INSERT or UPDATE operations on AutessaDB tables with predefined values.

---

## REST API Endpoints

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

Retrieves all scheduled events for your company. Returns all active (non-deleted) scheduled events that belong to your company.

### Request Body

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

### Response

- `ownedEvents` — "> All scheduled events owned by your company.
  - `companySharedEvents` — "> Always empty for client API (all events are in ownedEvents).
    - `sharedWithMeEvents` — "> Always empty for client API.
      - `errors` — "> Array of error messages if any occurred.
    
  
  
  

**cURL:**

```bash
  curl -X POST https://api.autessa.com/clients/scheduled-events/all \
    -H "Authorization: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{}'
```

**JavaScript:**

```javascript
const response = await fetch('https://api.autessa.com/clients/scheduled-events/all', {
method: 'POST',
headers: {
  'Authorization': 'your_api_key',
  'Content-Type': 'application/json'
},
body: JSON.stringify({})
});

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

```json title="Response"
{
  "ownedEvents": [
    {
      "eventId": "8f14e45f-ceea-4e07-8c65-9d2f9a1b3c4d",
      "eventName": "Daily Summary Agent",
      "description": "Runs every day at 9 AM",
      "scheduleSpec": {
        "pattern": "CRON",
        "cron": {
          "expression": "0 9 * * ? *",
          "timezone": "America/New_York"
        }
      },
      "enabled": true,
      "actionType": "INVOKE_AGENT",
      "sharingLevel": "COMPANY",
      "companyPermissionLevel": "ADMIN",
      "userPermission": "ADMIN"
    }
  ],
  "companySharedEvents": [],
  "sharedWithMeEvents": []
}
```
  

---

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

Retrieves a specific scheduled event by its ID.

### Request Body

- `scheduledEventId` (string, required) — The unique ID of the scheduled event.

### Response

- `scheduledEvent` (ScheduledEventTriggerDto) — The scheduled event details.
- `permission` (EAccessLevel) — Your access level (always ADMIN for client API).
- `errors` — "> Array of error messages if any occurred.
  
  
  
  

**cURL:**

```bash
  curl -X POST https://api.autessa.com/clients/scheduled-events/get \
    -H "Authorization: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"scheduledEventId": "8f14e45f-ceea-4e07-8c65-9d2f9a1b3c4d"}'
```

**JavaScript:**

```javascript
const response = await fetch('https://api.autessa.com/clients/scheduled-events/get', {
method: 'POST',
headers: {
  'Authorization': 'your_api_key',
  'Content-Type': 'application/json'
},
body: JSON.stringify({
  scheduledEventId: '8f14e45f-ceea-4e07-8c65-9d2f9a1b3c4d'
})
});
```

```json title="Response"
{
  "scheduledEvent": {
    "eventId": "8f14e45f-ceea-4e07-8c65-9d2f9a1b3c4d",
    "eventName": "Daily Summary Agent",
    "enabled": true,
    "sharingLevel": "COMPANY",
    "companyPermissionLevel": "ADMIN"
  },
  "permission": "ADMIN"
}
```
  

---

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

Creates a new scheduled event. The event is automatically set to COMPANY-WIDE access with ADMIN permissions.

> Your API key must have permission to access the target resource (agent, tool, or table) that will be executed by this scheduled event.

### Request Body - Common Fields

- `eventName` (string, required) — User-friendly name for the scheduled event.
- `description` (string) — Optional description of what this event does.
- `scheduleSpec` (object, required) — Schedule specification — see [Schedule Specs](#schedule-specs). One of the EVERY, CRON, or ONCE shapes.
- `enabled` (boolean) — Whether the event should be enabled. Defaults to true.
- `actionType` (EScheduledEventActionType, required) — Type of action: INVOKE_AGENT, INVOKE_TOOL, or UPDATE_AUTESSADB.

### For INVOKE_AGENT

- `agentConfig` (object, required) — Configuration for agent invocation. - `agentExecutionRequest.agentId` (string, required): The agent's ID - `agentExecutionRequest.input` (array, required): Multimodal input items, e.g. `[{"inputType": "TEXT", "content": "Generate daily summary"}]` - `agentExecutionRequest.environmentVariables` (object): String key-value pairs - `continueOnError` (boolean): Whether to continue if execution fails. Defaults to false - `description` (string): Optional description of this scheduled execution

### For INVOKE_TOOL

- `toolConfig` (object, required) — Configuration for tool execution. - `toolExecutionRequest.toolId` (string, required): The tool's ID - `toolExecutionRequest.variables` (object): Tool input variables. String key-value pairs - `toolExecutionRequest.environmentVariables` (object): String key-value pairs - `continueOnError` (boolean): Whether to continue if execution fails. Defaults to false - `description` (string): Optional description of this scheduled execution

### For UPDATE_AUTESSADB

- `autessaDbConfig` (object, required) — Configuration for database operation. - `operation` (DbOperation, required): INSERT or UPDATE - `targetTableId` (string, required): The AutessaDB table's ID - `values` (object, required): Column name to typed column value mappings, e.g. `{"status": {"columnType": "SHORT_TEXT", "textValue": "inactive"}}` - `recordId` (integer): For single-row UPDATE — the specific record ID to update. Mutually exclusive with `whereGroups` - `whereGroups` (array): For batch UPDATE — groups of WHERE conditions. Each group has a `logicalOperator` ("AND"/"OR") and `conditions` (array of `{columnName, operator, value}`). Mutually exclusive with `recordId` - `groupsLogicalOperator` (string): "AND" or "OR" — how to combine multiple WHERE groups - `skipIfTargetTableMissing` (boolean): If true, skip execution when the target table doesn't exist instead of failing. Defaults to false - `description` (string): Optional description of this scheduled operation

### Response

- `scheduledEvent` (ScheduledEventTriggerDto) — The created scheduled event details.
- `eventId` (string) — The unique ID of the created event.
- `scheduleArn` (string) — The schedule ARN.
- `errors` — "> Array of error messages if any occurred.
  
  
  
  

**Agent Example:**

```bash
  curl -X POST https://api.autessa.com/clients/scheduled-events/create \
    -H "Authorization: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "eventName": "Daily Summary Agent",
      "description": "Runs every day at 9 AM",
      "cronExpression": "cron(0 9 * * ? *)",
      "timezone": "America/New_York",
      "enabled": true,
      "actionType": "INVOKE_AGENT",
      "agentConfig": {
        "agentExecutionRequest": {
          "agentId": "aB3xK9pQ",
          "input": "Generate daily summary",
          "environmentVariables": {}
        },
        "continueOnError": false
      }
    }'
```

**Tool Example:**

```bash
curl -X POST https://api.autessa.com/clients/scheduled-events/create \
-H "Authorization: your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "eventName": "Hourly Data Sync",
  "cronExpression": "rate(1 hour)",
  "timezone": "UTC",
  "enabled": true,
  "actionType": "INVOKE_TOOL",
  "toolConfig": {
    "toolExecutionRequest": {
      "toolId": "tQ7mZ2wX",
      "variables": {
        "source": "production",
        "destination": "warehouse"
      }
    }
  }
}'
```

**Database Example:**

```bash
curl -X POST https://api.autessa.com/clients/scheduled-events/create \
-H "Authorization: your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "eventName": "Daily Cleanup",
  "cronExpression": "cron(0 0 * * ? *)",
  "enabled": true,
  "actionType": "UPDATE_AUTESSADB",
  "autessaDbConfig": {
    "operation": "UPDATE",
    "targetTableId": "dR4nV8kL",
    "values": {
      "status": "inactive"
    },
    "whereConditions": "{...}"
  }
}'
```

```json title="Response"
{
  "scheduledEvent": {
    "eventId": "evt_abc123",
    "eventName": "Daily Summary Agent",
    "enabled": true,
    "sharingLevel": "COMPANY",
    "companyPermissionLevel": "ADMIN"
  },
  "eventId": "evt_abc123",
  "scheduleArn": "arn:aws:scheduler:..."
}
```
  

---

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

Updates an existing scheduled event. You can modify the schedule, configuration, or any other field.

### Request Body

- `scheduledEventId` (string, required) — The ID of the event to update.
- `eventName` (string) — Updated event name.
- `description` (string) — Updated description.
- `cronExpression` (string) — Updated schedule expression.
- `timezone` (string) — Updated timezone.
- `actionType` (EScheduledEventActionType) — Updated action type (requires corresponding config).
- `agentConfig / toolConfig / autessaDbConfig` (object) — Updated configuration (based on action type).

> If you change the action type or target resource, your API key must have permission to access the new target resource.

### Response

- `scheduledEvent` (ScheduledEventTriggerDto) — The updated scheduled event details.
- `errors` — "> Array of error messages if any occurred.
  
  
  
  

**cURL:**

```bash
  curl -X POST https://api.autessa.com/clients/scheduled-events/update \
    -H "Authorization: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "scheduledEventId": "evt_abc123",
      "eventName": "Updated Event Name",
      "cronExpression": "rate(2 hours)"
    }'
```

**JavaScript:**

```javascript
const response = await fetch('https://api.autessa.com/clients/scheduled-events/update', {
method: 'POST',
headers: {
  'Authorization': 'your_api_key',
  'Content-Type': 'application/json'
},
body: JSON.stringify({
  scheduledEventId: 'evt_abc123',
  cronExpression: 'rate(2 hours)'
})
});
```

```json title="Response"
{
  "scheduledEvent": {
    "eventId": "evt_abc123",
    "eventName": "Updated Event Name",
    "cronExpression": "rate(2 hours)"
  }
}
```
  

---

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

Enables or disables a scheduled event. Disabled events will not execute until re-enabled.

### Request Body

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

### Response

- `eventId` (string) — The ID of the toggled event.
- `enabled` (boolean) — The new enabled state.
- `errors` — "> Array of error messages if any occurred.
  
  
  
  

**cURL:**

```bash
  curl -X POST https://api.autessa.com/clients/scheduled-events/toggle \
    -H "Authorization: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "scheduledEventId": "evt_abc123",
      "enabled": false
    }'
```

**JavaScript:**

```javascript
const response = await fetch('https://api.autessa.com/clients/scheduled-events/toggle', {
method: 'POST',
headers: {
  'Authorization': 'your_api_key',
  'Content-Type': 'application/json'
},
body: JSON.stringify({
  scheduledEventId: 'evt_abc123',
  enabled: false
})
});
```

```json title="Response"
{
  "eventId": "evt_abc123",
  "enabled": false
}
```
  

---

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

Soft-deletes a scheduled event. The event will be marked as deleted and will no longer execute.

### Request Body

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

### Response

- `eventId` (string) — The ID of the deleted event.
- `deletedAt` (string) — ISO timestamp of when the event was deleted.
- `errors` — "> Array of error messages if any occurred.
  
  
  
  

**cURL:**

```bash
  curl -X POST https://api.autessa.com/clients/scheduled-events/delete \
    -H "Authorization: your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"scheduledEventId": "evt_abc123"}'
```

**JavaScript:**

```javascript
const response = await fetch('https://api.autessa.com/clients/scheduled-events/delete', {
method: 'POST',
headers: {
  'Authorization': 'your_api_key',
  'Content-Type': 'application/json'
},
body: JSON.stringify({
  scheduledEventId: 'evt_abc123'
})
});
```

```json title="Response"
{
  "eventId": "evt_abc123",
  "deletedAt": "2025-11-04T12:00:00Z"
}
```
  

---

## Error Handling

All endpoints return errors in a consistent format:

```json
{
  "errors": [
    "API key does not have permission to access the target agent (ID: 123)",
    "Event name is required"
  ]
}
```

### Common Error Messages

- `Event name is required` (required) — The `eventName` field is missing or empty.
- `API key does not have permission to access the target X (ID: Y)` — Your API key doesn't have permission to the specified agent, tool, or table.
- `Target resource does not belong to your company` — The specified resource doesn't exist or belongs to a different company.
- `Agent/Tool/Table ID is required for X action` (required) — The configuration for the specified action type is missing required fields.
- `Scheduled event not found` — The specified event ID doesn't exist or doesn't belong to your company.
- `Scheduled event does not belong to your company` — You're trying to access an event from a different company.

---

## Important Notes

> **Company-Wide Access**: All scheduled events created via the client API are automatically set to COMPANY-WIDE sharing with ADMIN permissions. This means all members of your company can view, edit, and manage these scheduled events.

> **Permission Validation**: Your API key must have explicit permission to access the target resources (agents, tools, or tables) that the scheduled event will interact with. The API will reject creation/updates if you don't have access.

> **Owner Assignment**: Scheduled events created via the client API are owned by your company's primary admin user, not by the API key itself.

