---
title: "Create scheduled job"
method: POST
path: "/orgs/{organization}/servers/{server}/scheduled-jobs"
tags: ["Scheduled Jobs"]
---

# Create scheduled job

`POST /orgs/{organization}/servers/{server}/scheduled-jobs`

## Request

- Base URL: `https://forge.laravel.com/api`
- URL: `https://forge.laravel.com/api/orgs/{organization}/servers/{server}/scheduled-jobs`
- Auth: OAuth 2
  - Authorization code: `https://forge.laravel.com/oauth/authorize`
  - Token URL: `https://forge.laravel.com/oauth/token` scopes: `server:view`
- TypeScript: <https://skmtc.dev/mfullbrook/apis/forge/docs/orgs/:organization/servers/:server/scheduled-jobs/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a specific scheduled job.

Processing mode: <small><code>async</code></small>

## Path parameters

- `organization` string, required
- `server` integer, required

## Request body

- CreateScheduledJobRequest
  - `name` string, nullable: The name of the command.
  - `command` string, required: The command to run.
  - `user` string, required: The user to run the scheduled job as.
  - `frequency` 'minutely' | 'hourly' | 'nightly' | 'weekly' | 'monthly' | 'reboot' | 'custom', required
  - `cron` string, nullable: The cron expression to use for the scheduled job. Only used if frequency is set to Custom.
  - `heartbeat` boolean, nullable: Whether a heartbeat should be created for the scheduled job.
  - `grace_period` 1 | 2 | 5 | 10 | 30 | 60

## Response `202`

`JobResource`

- object
  - `data` JobResource, required
    - `id` string, required
    - `type` 'scheduledJobs', required
    - `attributes` object
      - `name` string, nullable, required
      - `command` string, required
      - `status` string, required
      - `user` string, required
      - `frequency` string, required
      - `cron` string, required
      - `next_run_time` string, required
      - `created_at` string, date-time, nullable, required
      - `updated_at` string, date-time, nullable, required
    - `links` object, required
      - `self` Link, required
        - `href` string, uri, required
        - `rel` string
        - `describedby` string
        - `title` string
        - `type` string
        - `hreflang` union
          - string
          - string[]
        - `meta` object

## Other responses

- `403`: Authorization error
- `404`: Not found
- `422`: Validation error

---

[API](https://skmtc.dev/mfullbrook/apis/forge.md) - [All operations](https://skmtc.dev/mfullbrook/apis/forge/llms.txt) - [OpenAPI document](https://skmtc.dev/mfullbrook/apis/forge/revisions/24ad66d99f93?raw)
