Resource Job Actions
https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
Below are the various requests that can be performed against the Resource Job resource, as well as the expected parameters and the potential responses.
Cancel Execution
Marks a specific resource job execution for cancellation
Method And Url
POST https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
/cancelExecution
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.Application
, all.Organization
, all.User
, resourceJob.*
, or resourceJob.cancelExecution
.
Request Path Components
Path Component | Description | Example |
---|---|---|
APPLICATION_ID | ID associated with the application | 575ec8687ae143cd83dc4a97 |
RESOURCE_JOB_ID | ID associated with the resource job | 575ec8687ae143cd83dc4a97 |
Request Query Parameters
Name | Required | Description | Default | Example |
---|---|---|---|---|
executionId | Y | The ID of the execution to cancel | executionId=632e18632f59592e773a4153 |
Request Headers
Name | Required | Description | Default |
---|---|---|---|
Authorization | Y | The token for authenticating the request, prepended with Bearer |
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
https://api.losant.com/applications/APPLICATION_ID/resource-jobs/RESOURCE_JOB_ID/cancelExecution?executionId=632e18632f59592e773a4153
Successful Responses
Code | Type | Description |
---|---|---|
200 | Success | If the execution was successfully marked for cancellation |
Error Responses
Code | Type | Description |
---|---|---|
400 | Error | Error if malformed request |
404 | Error | Error if execution was not found |
Delete
Deletes a resource job
Method And Url
DELETE https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.Application
, all.Organization
, all.User
, resourceJob.*
, or resourceJob.delete
.
Request Path Components
Path Component | Description | Example |
---|---|---|
APPLICATION_ID | ID associated with the application | 575ec8687ae143cd83dc4a97 |
RESOURCE_JOB_ID | ID associated with the resource job | 575ec8687ae143cd83dc4a97 |
Request Query Parameters
Name | Required | Description | Default | Example |
---|---|---|---|---|
includeWorkflows | N | If the workflows that trigger from this resource job should also be deleted. | includeWorkflows=true |
Request Headers
Name | Required | Description | Default |
---|---|---|---|
Authorization | Y | The token for authenticating the request, prepended with Bearer |
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X DELETE \
https://api.losant.com/applications/APPLICATION_ID/resource-jobs/RESOURCE_JOB_ID
Successful Responses
Code | Type | Description |
---|---|---|
200 | Success | If resource job was successfully deleted |
Error Responses
Code | Type | Description |
---|---|---|
400 | Error | Error if malformed request |
404 | Error | Error if resource job was not found |
Execute
Queues the execution of a resource job
Method And Url
POST https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
/execute
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.Application
, all.Organization
, all.User
, resourceJob.*
, or resourceJob.execute
.
Request Path Components
Path Component | Description | Example |
---|---|---|
APPLICATION_ID | ID associated with the application | 575ec8687ae143cd83dc4a97 |
RESOURCE_JOB_ID | ID associated with the resource job | 575ec8687ae143cd83dc4a97 |
Request Headers
Name | Required | Description | Default |
---|---|---|---|
Authorization | Y | The token for authenticating the request, prepended with Bearer |
Request Body
The body of the request should be serialized JSON that validates against the Resource Job Execution Options schema. For example, the following would be a valid body for this request:
{
"templateContext": "{ \"myData\": 123 }"
}
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-d '{"templateContext":"{ \"myData\": 123 }"}' \
https://api.losant.com/applications/APPLICATION_ID/resource-jobs/RESOURCE_JOB_ID/execute
Successful Responses
Code | Type | Description |
---|---|---|
200 | Success With Execution ID | If the job was successfully queued |
Error Responses
Code | Type | Description |
---|---|---|
400 | Error | Error if malformed request |
404 | Error | Error if resource job was not found |
Get
Returns a resource job
Method And Url
GET https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.Application
, all.Application.read
, all.Organization
, all.Organization.read
, all.User
, all.User.read
, resourceJob.*
, or resourceJob.get
.
Request Path Components
Path Component | Description | Example |
---|---|---|
APPLICATION_ID | ID associated with the application | 575ec8687ae143cd83dc4a97 |
RESOURCE_JOB_ID | ID associated with the resource job | 575ec8687ae143cd83dc4a97 |
Request Headers
Name | Required | Description | Default |
---|---|---|---|
Authorization | Y | The token for authenticating the request, prepended with Bearer |
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/resource-jobs/RESOURCE_JOB_ID
Successful Responses
Code | Type | Description |
---|---|---|
200 | Resource Job | A single resource job |
Error Responses
Code | Type | Description |
---|---|---|
400 | Error | Error if malformed request |
404 | Error | Error if application was not found |
Logs
Retrieves information on resource job executions
Method And Url
GET https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
/logs
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.Application
, all.Application.read
, all.Organization
, all.Organization.read
, all.User
, all.User.read
, resourceJob.*
, or resourceJob.logs
.
Request Path Components
Path Component | Description | Example |
---|---|---|
APPLICATION_ID | ID associated with the application | 575ec8687ae143cd83dc4a97 |
RESOURCE_JOB_ID | ID associated with the resource job | 575ec8687ae143cd83dc4a97 |
Request Query Parameters
Name | Required | Description | Default | Example |
---|---|---|---|---|
limit | N | Max log entries to return (ordered by time descending) | 1 | limit=10 |
since | N | Look for log entries since this time (ms since epoch) | since=1465790400000 |
Request Headers
Name | Required | Description | Default |
---|---|---|---|
Authorization | Y | The token for authenticating the request, prepended with Bearer |
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/resource-jobs/RESOURCE_JOB_ID/logs
Successful Responses
Code | Type | Description |
---|---|---|
200 | Resource Job Execution Logs | Resource job execution information |
Error Responses
Code | Type | Description |
---|---|---|
400 | Error | Error if malformed request |
404 | Error | Error if resource job was not found |
Patch
Update a resource job
Method And Url
PATCH https://api.losant.com/applications/APPLICATION_ID
/resource-jobs/RESOURCE_JOB_ID
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.Application
, all.Organization
, all.User
, resourceJob.*
, or resourceJob.patch
.
Request Path Components
Path Component | Description | Example |
---|---|---|
APPLICATION_ID | ID associated with the application | 575ec8687ae143cd83dc4a97 |
RESOURCE_JOB_ID | ID associated with the resource job | 575ec8687ae143cd83dc4a97 |
Request Headers
Name | Required | Description | Default |
---|---|---|---|
Authorization | Y | The token for authenticating the request, prepended with Bearer |
Request Body
The body of the request should be serialized JSON that validates against the Resource Job Patch schema. For example, the following would be a valid body for this request:
{
"name": "Example Resource Job",
"queryJson": "{ \"name\": \"my device\"}"
}
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X PATCH \
-d '{"name":"Example Resource Job","queryJson":"{ \"name\": \"my device\"}"}' \
https://api.losant.com/applications/APPLICATION_ID/resource-jobs/RESOURCE_JOB_ID
Successful Responses
Code | Type | Description |
---|---|---|
201 | Resource Job | Successfully updated resource job |
Error Responses
Code | Type | Description |
---|---|---|
400 | Error | Error if malformed request |
404 | Error | Error if resource job was not found |
Schemas
Error
Schema for errors returned by the API
Error Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
Error Example
- ▶{} 2 keys
- "NotFound"
- "Application was not found"
Resource Job
Schema for a single resource job
Resource Job Schema
- ▶{} 4 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 19 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 3 keys
- ▶{} 3 keys
- false
Resource Job Example
- ▶{} 11 keys
- "Example Resource Job"
- 60
- 60000
- "{}"
- "6328c6c026517badf9142116"
- 1
- "2022-09-19T19:45:04.453Z"
- "2022-09-19T19:45:04.453Z"
- "6328c6c026517badf914211a"
- "device"
- "{ "name": "my device"}"
Resource Job Execution Logs
Schema for a set of Resource Job execution logs
Resource Job Execution Logs Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "array"
- ▶{} 6 keys
Resource Job Execution Logs Example
- ▶[] 1 item
- ▶{} 14 keys
Resource Job Execution Options
Schema for a resource job execution configuration
Resource Job Execution Options Schema
- ▶{} 4 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 1 key
- false
Resource Job Execution Options Example
- ▶{} 1 key
- "{ "myData": 123 }"
Resource Job Patch
Schema for a resource job update
Resource Job Patch Schema
- ▶{} 4 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 12 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 3 keys
- ▶{} 3 keys
- false
Resource Job Patch Example
- ▶{} 2 keys
- "Example Resource Job"
- "{ "name": "my device"}"
Success
Schema for reporting a successful operation
Success Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 1 key
- ▶{} 2 keys
Success Example
- ▶{} 1 key
- true
Success With Execution ID
Schema for reporting a successful operation with a corresponding execution ID
Success With Execution ID Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
Success With Execution ID Example
- ▶{} 2 keys
- true
- "575ed78e7ae143cd83dc4aab"
Was this page helpful?
Still looking for help? You can also search the Losant Forums or submit your question there.