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
RESOURCEJOBID 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
RESOURCEJOBID 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
RESOURCEJOBID 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
RESOURCEJOBID 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
RESOURCEJOBID 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
RESOURCEJOBID 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

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.