# POST /users/{name}/cron/jobs

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the cron group.

Add a job to a customer's crontab

- Who may call it: administrator, reseller, customer
- Token scope, any of: files, all
- Answers: 201 Created

Cron runs the command as the customer with /bin/sh, regardless of whether the customer has shell access. If the crontab has no MAILTO line, UrbeStack adds MAILTO="" at the top to suppress email from cron.

For schedule, use a cron keyword such as @daily or supply five fields in order: minute, hour, day of the month, month, and day of the week. The fields support *, numbers, ranges, lists, and steps. You can use a three-letter month or weekday name on its own in the corresponding field. The schedule can be up to 200 characters after the API trims and collapses whitespace.

Supply a nonblank command on one line. Cron treats % as a line break. Use \% for a literal percent sign.

UrbeStack refuses the request if the customer's package disallows cron. The API returns 409 if the package's job limit has been reached or the crontab is set aside. It returns 400 if schedule or command is missing or invalid, or if name identifies an administrator. If crontab rejects the line, the API returns 400 with the crontab error.

Customers can add their own jobs, resellers can add jobs for their customers, and administrators can add jobs for any customer. The token must have the files scope.

## As a command

- [urbestack-cron-job-add](https://urbestack.com/docs/commands/urbestack-cron-job-add.md): Adds a job to a customer's crontab.

## Parameters

- `name` (path, Username, required)

## Request body

JSON, the type [CronJobCreate](https://urbestack.com/docs/api/types/CronJobCreate.md).

- `command` (string, up to 998 characters, required): Single-line command run as the customer with /bin/sh, up to Ubuntu cron's limit of 998 characters. Cron treats % as a line break unless it is written as \%.
- `schedule` (string, up to 200 characters, required): Cron schedule in five fields, ordered by minute, hour, day of the month, month and day of the week, or one of @reboot, @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly. Each field accepts an asterisk, a number, a range or a list with an optional step, and a month or weekday can also be given by its three-letter name on its own.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/users/alice/cron/jobs" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "command": "text",
    "schedule": "text"
  }'
```

Response, 201 Created:

```
{
  "job": {
    "command": "text",
    "day": "2026-09-09",
    "hour": "text",
    "id": 1,
    "line": 1,
    "minute": "text",
    "month": "text",
    "schedule": "text",
    "weekday": "text"
  }
}
```

## Errors

- 400: --command-stdin is required: the command comes on standard input
- 400: --schedule is required
- 400: --user is required
- 400: <name> is an administrator: administrators have no system account, so no cron jobs
- 400: <what> must be text
- 400: A schedule is five fields (minute, hour, day of the month, month, day of the week) or a keyword such as @daily
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: The command is one line: no line breaks
- 400: Username '<value>' is reserved
- 400: command is required
- 401: Authentication required
- 403: The package <p.name> does not include <SWITCH_WHAT>{<switch>}
- 404: User '<user>' not found
- 409: The package <p.name> allows <limit> 
