mirror of https://github.com/dapr/docs.git
3.2 KiB
3.2 KiB
type | title | linkTitle | description | weight |
---|---|---|---|---|
docs | Jobs API reference | Jobs API | Detailed documentation on the jobs API | 1300 |
{{% alert title="Note" color="primary" %}} The jobs API is currently in alpha. {{% /alert %}}
With the jobs API, you can schedule jobs and tasks in the future.
Schedule a job
Schedule a job with a name.
POST http://localhost:3500/v1.0-alpha1/jobs/<name>
URL parameters
Parameter | Description |
---|---|
name |
Name of the job you're scheduling |
data |
A string value and can be any related content. Content is returned when the reminder expires. For example, this may be useful for returning a URL or anything related to the content. |
dueTime |
Specifies the time after which this job is invoked. Its format should be time.ParseDuration |
Request body
{
"job": {
"data": {
"@type": "type.googleapis.com/google.type.Expr",
"expression": "<expression>"
},
"dueTime": "30s"
}
}
HTTP response codes
Code | Description |
---|---|
202 |
Accepted |
400 |
Request was malformed |
500 |
Request 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 dueTime
and the data
.
$ curl -X POST \
http://localhost:3500/v1.0-alpha1/jobs/jobforjabba \
-H "Content-Type: application/json"
-d '{
"job": {
"data": {
"@type": "type.googleapis.com/google.type.Expr",
},
"dueTime": "30s"
}
}'
Get job data
Get a job from its name.
GET http://localhost:3500/v1.0-alpha1/jobs/<name>
URL parameters
Parameter | Description |
---|---|
name |
Name of the scheduled job you're retrieving |
HTTP response codes
Code | Description |
---|---|
202 |
Accepted |
400 |
Request was malformed |
500 |
Request formatted correctly, 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
.
$ curl -X GET http://localhost:3500/v1.0-alpha1/jobs/jobforjabba -H "Content-Type: application/json"
{
"name":"test1",
"dueTime":"30s",
"data": {
"@type":"type.googleapis.com/google.type.Expr",
"expression":"expression1"
}
}
Delete a job
Delete a named job.
DELETE http://localhost:3500/v1.0-alpha1/jobs/<name>
URL parameters
Parameter | Description |
---|---|
name |
Name of the job you're deleting |
HTTP response codes
Code | Description |
---|---|
202 |
Accepted |
400 |
Request was malformed |
500 |
Request 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
$ curl -X DELETE http://localhost:3500/v1.0-alpha1/jobs/jobforjabba -H "Content-Type: application/json"
Next steps
[Jobs API overview]({{< ref jobs-overview.md >}})