---
title: "Create scheduled task"
method: POST
path: "/aapi/project/{projectId}/tasks"
tags: ["Scheduling"]
---

# Create scheduled task

`POST /aapi/project/{projectId}/tasks`

## Request

- Base URL: `https://api.websitepublisher.ai`
- URL: `https://api.websitepublisher.ai/aapi/project/{projectId}/tasks`
- Auth: OAuth 2 (authorization code, authorization URL `https://api.websitepublisher.ai/dapi/oauth/authorize`, token URL `https://api.websitepublisher.ai/dapi/oauth/token`, scopes: `read`, `write`)

Create a task that runs automatically at a cron schedule. Use run_once=true for one-time actions (e.g. publish a page at a specific date/time). Supports publish_page, unpublish_page, and webhook actions.

## Path parameters

- `projectId` integer, required

## Request body

- ScheduledTaskCreate
  - `name` string, required: Human-readable task name
  - `action_type` 'publish_page' | 'unpublish_page' | 'webhook', required: Action type. publish/unpublish require page_id in payload. webhook requires url in payload.
  - `action_payload` object, required: Action parameters. publish_page/unpublish_page: {"page_id": 123}. webhook: {"url": "https://...", "body": {}}
  - `schedule` string, required: Cron expression (e.g. "0 9 * * 1" = Monday 9am)
  - `timezone` string: Timezone (default: Europe/Amsterdam)
  - `run_once` boolean: Run once at next matching time then deactivate (default: false)

## Response `201`

Scheduled task created

## Other responses

- `429`: Task limit reached (upgrade plan)

---

[API](https://skmtc.dev/websitepublisher/apis/websitepublisher-ai-api.md) · [All operations](https://skmtc.dev/websitepublisher/apis/websitepublisher-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/websitepublisher/apis/websitepublisher-ai-api/revisions/e9df1ef10551?raw)
