Jobs API reference

Detailed documentation on the jobs API

Note

The jobs API is currently in alpha.

With the jobs API, you can schedule jobs and tasks in the future.

The HTTP APIs are intended for development and testing only. For production scenarios, the use of the SDKs is strongly recommended as they implement the gRPC APIs providing higher performance and capability than the HTTP APIs.

Schedule a job

Schedule a job with a name.

  1. POST http://localhost:3500/v1.0-alpha1/jobs/<name>

URL parameters

Note

At least one of schedule or dueTime must be provided, but they can also be provided together.

ParameterDescription
nameName of the job you’re scheduling
dataA JSON serialized value or object.
scheduleAn optional schedule at which the job is to be run. Details of the format are below.
dueTimeAn optional time at which the job should be active, or the “one shot” time, if other scheduling type fields are not provided. Accepts a “point in time” string in the format of RFC3339, Go duration string (calculated from creation time), or non-repeating ISO8601.
repeatsAn optional number of times in which the job should be triggered. If not set, the job runs indefinitely or until expiration.
ttlAn optional time to live or expiration of the job. Accepts a “point in time” string in the format of RFC3339, Go duration string (calculated from job creation time), or non-repeating ISO8601.

schedule

schedule accepts both systemd timer-style cron expressions, as well as human readable ‘@’ prefixed period strings, as defined below.

Systemd timer style cron accepts 6 fields:

secondsminuteshoursday of monthmonthday of week
0-590-590-231-311-12/jan-dec0-6/sun-sat
Example 1

“0 30 * * * *” - every hour on the half hour

Example 2

“0 15 3 * * *” - every day at 03:15

Period string expressions:

EntryDescriptionEquivalent To
@everyRun every (e.g. ‘@every 1h30m’)N/A
@yearly (or @annually)Run once a year, midnight, Jan. 1st0 0 0 1 1
@monthlyRun once a month, midnight, first of month0 0 0 1
@weeklyRun once a week, midnight on Sunday0 0 0 0
@daily (or @midnight)Run once a day, midnight0 0 0
@hourlyRun once an hour, beginning of hour0 0

Request body

  1. {
  2. "data": "some data",
  3. "dueTime": "30s"
  4. }

HTTP response codes

CodeDescription
204Accepted
400Request was malformed
500Request formatted correctly, error in dapr code or Scheduler control plane service

Response content

The following example curl command creates a job, naming the job jobforjabba and specifying the schedule, repeats and the data.

  1. $ curl -X POST \
  2. http://localhost:3500/v1.0-alpha1/jobs/jobforjabba \
  3. -H "Content-Type: application/json" \
  4. -d '{
  5. "data": "{\"value\":\"Running spice\"}",
  6. "schedule": "@every 1m",
  7. "repeats": 5
  8. }'

Get job data

Get a job from its name.

  1. GET http://localhost:3500/v1.0-alpha1/jobs/<name>

URL parameters

ParameterDescription
nameName of the scheduled job you’re retrieving

HTTP response codes

CodeDescription
200Accepted
400Request was malformed
500Request formatted correctly, Job doesn’t exist or error in dapr code or Scheduler control plane service

Response content

After running the following example curl command, the returned response is JSON containing the name of the job, the dueTime, and the data.

  1. $ curl -X GET http://localhost:3500/v1.0-alpha1/jobs/jobforjabba -H "Content-Type: application/json"
  1. {
  2. "name": "jobforjabba",
  3. "schedule": "@every 1m",
  4. "repeats": 5,
  5. "data": 123
  6. }

Delete a job

Delete a named job.

  1. DELETE http://localhost:3500/v1.0-alpha1/jobs/<name>

URL parameters

ParameterDescription
nameName of the job you’re deleting

HTTP response codes

CodeDescription
204Accepted
400Request was malformed
500Request formatted correctly, error in dapr code or Scheduler control plane service

Response content

In the following example curl command, the job named test1 with app-id sub will be deleted

  1. $ curl -X DELETE http://localhost:3500/v1.0-alpha1/jobs/jobforjabba -H "Content-Type: application/json"

Next steps

Jobs API overview

Last modified October 11, 2024: Fixed typo (#4389) (fe17926)