> ## Documentation Index
> Fetch the complete documentation index at: https://docs.asteragents.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a scheduled task

> Schedule an agent to run automatically on a cron schedule. The agent
must belong to your organization. The run executes the agent with
`prompt` as the user message, on the cadence in `schedule`.




## OpenAPI

````yaml /openapi.yaml post /scheduled-tasks/manage
openapi: 3.1.0
info:
  title: AsterAgents API
  version: 1.0.0
  description: >
    API for AsterAgents platform operations.


    - **Admin endpoints** (`/admin/*`) require organization admin privileges
    (`org:admin` role)

    - **Agent endpoints** (`/agents`) require agent management permissions or
    `org:admin` role

    - **Knowledge base endpoints** (`/kb/*`) require standard authentication

    - **Skills endpoints** (`/skills/*`) require standard authentication

    - **File endpoints** (`/upload/*`, `/kb/files`, `/skills/files`) require
    standard authentication
  contact:
    name: AsterAgents Support
    url: https://asteragents.com/support
servers:
  - url: https://asteragents.com/api
    description: Production
  - url: http://localhost:3000/api
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Users
    description: Manage active organization users
  - name: Invitations
    description: Manage organization invitations
  - name: Files
    description: Upload and manage files
  - name: Knowledge Bases
    description: Manage knowledge bases and their files
  - name: Knowledge Base Management
    description: Create, update, and delete knowledge bases
  - name: Agents
    description: Create, update, and delete agents
  - name: Agent Tags
    description: Organize agents with tags
  - name: Tools
    description: Discover the tool catalog available to your organization
  - name: Skills
    description: Manage agent skills
  - name: Skill Files
    description: Manage bundled files for skills
  - name: Conversations
    description: Invoke agents and retrieve conversation history and messages
  - name: Scheduled Tasks
    description: Schedule agents to run automatically on a cron schedule
paths:
  /scheduled-tasks/manage:
    post:
      tags:
        - Scheduled Tasks
      summary: Create a scheduled task
      description: |
        Schedule an agent to run automatically on a cron schedule. The agent
        must belong to your organization. The run executes the agent with
        `prompt` as the user message, on the cadence in `schedule`.
      operationId: createScheduledTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - prompt
                - schedule
                - agentId
              properties:
                name:
                  type: string
                  maxLength: 100
                  example: Weekly portfolio digest
                description:
                  type: string
                  nullable: true
                prompt:
                  type: string
                  description: The message sent to the agent on each run.
                  example: Summarize any new documents added this week.
                schedule:
                  type: string
                  description: Cron expression (UTC).
                  example: 0 13 * * 1
                agentId:
                  type: integer
                  example: 123
                enabled:
                  type: boolean
                  default: true
      responses:
        '201':
          description: Task created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduledTask'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Agent not found in your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    ScheduledTask:
      type: object
      properties:
        id:
          type: integer
          example: 42
        name:
          type: string
          example: Weekly portfolio digest
        description:
          type: string
          nullable: true
        prompt:
          type: string
          example: Summarize any new documents added this week.
        schedule:
          type: string
          description: Cron expression (UTC).
          example: 0 13 * * 1
        enabled:
          type: boolean
        agentId:
          type: integer
          example: 123
        agentName:
          type: string
          description: Present on list/get responses.
          example: Portfolio Monitor
        userId:
          type: string
        lastRunAt:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Bad Request
        details:
          type: array
          items:
            type: object
            additionalProperties: true
  responses:
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Internal Server Error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT token from Clerk authentication.

        Must be from a user with `org:admin` role.

````