Tasks
Working with tasks in BladePRO’s I/O system.
Log message
POST /v1/log
Saves a log entry and update the heartbeat of a task.
Request Body
Return Type
Types for the Request Body
CreateLog (root level)
| Key | Description | Types | Restrictions |
|---|---|---|---|
severity | The severity of the log. | string | requirednot null |
message | The message to be recorded. | string | requirednot nullmin length is 1 |
payload | Additional data to be stored against the message. | object | not null |
task_id | The ID of the related task. | string | not nullmatch is /^[0-9a-z-]{36}$/ |
service | Which service wrote the log message. | string | not null |
incident_bindings | Bindings for the incident to be created. | CreateLogIncidentBinding | not null |
CreateLogIncidentBinding
| Key | Description | Types | Restrictions |
|---|---|---|---|
user | User ID. | number | not null |
company | Company ID. | number | not null |
organisation | Organisation ID. | number | not null |
order_goodsout | Order goodsout ID. | number | not null |
order_channel | Order channel ID. | number | not null |
product_channel | Product channel ID. | number | not null |
product_variation | Product variation ID. | number | not null |
product_component | Product component ID. | number | not null |
listing | Listing ID. | number | not null |
vendor_order | Vendor order ID. | number | not null |
purchase_order | Purchase order ID. | number | not null |
Rate limit cost
Each call to this endpoint deducts 1 credit from your request bucket.
Scopes
This endpoint is only available for users with scope APP::MISC.
<?php
// Instantiate a GuzzleHttp client
$client = new \GuzzleHttp\Client();
// Make the request
$response = $client->request("POST", "https://public-api.bladepro.io/v1/log", [
"body" => json_encode([
"severity" => "warning",
"message" => "This is a message worth saving to our logs.",
"payload" => [
"x" => 0,
"y" => 0,
"z" => 4,
],
"incident_bindings" => [
"user" => 116,
"vendor_order" => 1546,
],
]),
"headers" => [
"Content-Type" => "application/json",
"Access-Token" => "my-token-from-login",
],
]);
// Process the response
$responseBody = json_decode($response->getBody(), true);require 'rest-client'
require 'json'
# Make the request
response = RestClient.post 'https://public-api.bladepro.io/v1/log', {
severity: "warning",
message: "This is a message worth saving to our logs.",
payload: {
x: 0,
y: 0,
z: 4,
},
incident_bindings: {
user: 116,
vendor_order: 1546,
},
}, {
access_token: 'my-token-from-login',
content_type: :json,
accept: :json
}
# Process the response
puts response.body// Require the node HTTP module
var request = require("request");
// Make the request
request({
method: "POST",
json: true,
uri: "https://public-api.bladepro.io/v1/log",
body: {
"severity": "warning",
"message": "This is a message worth saving to our logs.",
"payload": {
"x": 0,
"y": 0,
"z": 4
},
"incident_bindings": {
"user": 116,
"vendor_order": 1546
}
},
headers: {
"Access-Token": "my-token-from-login",
"Content-Type": "application/json",
},
(error, response, body) => {
// Process the response
console.log(body);
},
});# Make the request
curl --location --request POST 'https://public-api.bladepro.io/v1/log' \
--header 'Content-Type: application/json' \
--header 'Access-Token: my-token-from-login' \
--data-raw '{
"severity": "warning",
"message": "This is a message worth saving to our logs.",
"payload": {
"x": 0,
"y": 0,
"z": 4
},
"incident_bindings": {
"user": 116,
"vendor_order": 1546
}
}'Example result:
{
"meta": {
"request_reference": "235chjz9h-c893v86"
},
"data": {
"success": true
}
}Create task
POST /v1/tasks
Calls the task system to create a new task.
Request Body
Return Type
Types for the Request Body
Task (root level)
| Key | Description | Types | Restrictions |
|---|---|---|---|
task | Task code. | string | requirednot nullmin length is 1 |
endpoint | Endpoint to be hit. | Endpoint | requirednot null |
metadata | Metadata. | map<string, string> | requirednot nullmin length is 0 |
payload | Payload. | booleanor numberor objector string | requirednot null |
application | Definition of the application the task belongs to. | Application | requirednot null |
Application
| Key | Description | Types | Restrictions |
|---|---|---|---|
id | The ID of the application. | number | requirednot null |
name | The name of the application. | string | requirednot nullmin length is 1 |
instance_id | The ID of the application’s instance. | number | requirednot null |
Endpoint
| Key | Description | Types | Restrictions |
|---|---|---|---|
url | URL. | string | requirednot nullmin length is 1 |
method | HTTP method. | string | requirednot nullmatch is ``/^(POST |
Rate limit cost
Each call to this endpoint deducts 1 credit from your request bucket.
Scopes
This endpoint is only available for users with scope APP::MISC.
<?php
// Instantiate a GuzzleHttp client
$client = new \GuzzleHttp\Client();
// Make the request
$response = $client->request("POST", "https://public-api.bladepro.io/v1/tasks", [
"body" => json_encode([
"task" => "MYAPP:VENDOR:CREATE",
"endpoint" => [
"url" => "https://my-url.com/endpoint",
"method" => "POST",
],
"metadata" => [
"meta1" => "value1",
"meta2" => "value2",
"meta3" => "value3",
],
"payload" => true,
"application" => [
"id" => 1,
"name" => "Application name",
"instance_id" => 1,
],
]),
"headers" => [
"Content-Type" => "application/json",
"Access-Token" => "my-token-from-login",
],
]);
// Process the response
$responseBody = json_decode($response->getBody(), true);require 'rest-client'
require 'json'
# Make the request
response = RestClient.post 'https://public-api.bladepro.io/v1/tasks', {
task: "MYAPP:VENDOR:CREATE",
endpoint: {
url: "https://my-url.com/endpoint",
method: "POST",
},
metadata: {
meta1: "value1",
meta2: "value2",
meta3: "value3",
},
payload: true,
application: {
id: 1,
name: "Application name",
instance_id: 1,
},
}, {
access_token: 'my-token-from-login',
content_type: :json,
accept: :json
}
# Process the response
puts response.body// Require the node HTTP module
var request = require("request");
// Make the request
request({
method: "POST",
json: true,
uri: "https://public-api.bladepro.io/v1/tasks",
body: {
"task": "MYAPP:VENDOR:CREATE",
"endpoint": {
"url": "https://my-url.com/endpoint",
"method": "POST"
},
"metadata": {
"meta1": "value1",
"meta2": "value2",
"meta3": "value3"
},
"payload": true,
"application": {
"id": 1,
"name": "Application name",
"instance_id": 1
}
},
headers: {
"Access-Token": "my-token-from-login",
"Content-Type": "application/json",
},
(error, response, body) => {
// Process the response
console.log(body);
},
});# Make the request
curl --location --request POST 'https://public-api.bladepro.io/v1/tasks' \
--header 'Content-Type: application/json' \
--header 'Access-Token: my-token-from-login' \
--data-raw '{
"task": "MYAPP:VENDOR:CREATE",
"endpoint": {
"url": "https://my-url.com/endpoint",
"method": "POST"
},
"metadata": {
"meta1": "value1",
"meta2": "value2",
"meta3": "value3"
},
"payload": true,
"application": {
"id": 1,
"name": "Application name",
"instance_id": 1
}
}'Example result:
{
"meta": {
"request_reference": "235chjz9h-c893v86"
},
"data": {
"task_reference": "12345678-abcd-9qwe-zx01-123456789abc"
}
}Mark task as failed
PUT /v1/tasks/:task/failed
Reports a task to have failed.
Parameter Regular Expressions
- :task: [0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}
Request Body
Return Type
Types for the Request Body
FailTask (root level)
| Key | Description | Types | Restrictions |
|---|---|---|---|
summary | A summary of why the task failed. | string | requirednot nullmin length is 1 |
Rate limit cost
Each call to this endpoint deducts 1 credit from your request bucket.
Scopes
This endpoint is only available for users with scope APP::MISC.
<?php
// Instantiate a GuzzleHttp client
$client = new \GuzzleHttp\Client();
// Make the request
$response = $client->request("PUT", "https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/failed", [
"body" => json_encode([
"summary" => "Failed to update order, reference could not be matched on marketplace.",
]),
"headers" => [
"Content-Type" => "application/json",
"Access-Token" => "my-token-from-login",
],
]);
// Process the response
$responseBody = json_decode($response->getBody(), true);require 'rest-client'
require 'json'
# Make the request
response = RestClient.put 'https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/failed', {
summary: "Failed to update order, reference could not be matched on marketplace.",
}, {
access_token: 'my-token-from-login',
content_type: :json,
accept: :json
}
# Process the response
puts response.body// Require the node HTTP module
var request = require("request");
// Make the request
request({
method: "PUT",
json: true,
uri: "https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/failed",
body: {
"summary": "Failed to update order, reference could not be matched on marketplace."
},
headers: {
"Access-Token": "my-token-from-login",
"Content-Type": "application/json",
},
(error, response, body) => {
// Process the response
console.log(body);
},
});# Make the request
curl --location --request PUT 'https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/failed' \
--header 'Content-Type: application/json' \
--header 'Access-Token: my-token-from-login' \
--data-raw '{
"summary": "Failed to update order, reference could not be matched on marketplace."
}'Example result:
{
"meta": {
"request_reference": "235chjz9h-c893v86"
},
"data": {
"task_reference": "12345678-abcd-9qwe-zx01-123456789abc"
}
}Mark task as completed
PUT /v1/tasks/:task/complete
Reports a task to have completed.
Parameter Regular Expressions
- :task: [0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}
Request Body
Return Type
Types for the Request Body
CompleteTask (root level)
| Key | Description | Types | Restrictions |
|---|---|---|---|
summary | A summary of the task’s outcome. | string | requirednot nullmin length is 1 |
warning | Mark the task with a warning flag. | boolean | not null |
Rate limit cost
Each call to this endpoint deducts 1 credit from your request bucket.
Scopes
This endpoint is only available for users with scope APP::MISC.
<?php
// Instantiate a GuzzleHttp client
$client = new \GuzzleHttp\Client();
// Make the request
$response = $client->request("PUT", "https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/complete", [
"body" => json_encode([
"summary" => "Updated stock for 134 products.",
"warning" => true,
]),
"headers" => [
"Content-Type" => "application/json",
"Access-Token" => "my-token-from-login",
],
]);
// Process the response
$responseBody = json_decode($response->getBody(), true);require 'rest-client'
require 'json'
# Make the request
response = RestClient.put 'https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/complete', {
summary: "Updated stock for 134 products.",
warning: true,
}, {
access_token: 'my-token-from-login',
content_type: :json,
accept: :json
}
# Process the response
puts response.body// Require the node HTTP module
var request = require("request");
// Make the request
request({
method: "PUT",
json: true,
uri: "https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/complete",
body: {
"summary": "Updated stock for 134 products.",
"warning": true
},
headers: {
"Access-Token": "my-token-from-login",
"Content-Type": "application/json",
},
(error, response, body) => {
// Process the response
console.log(body);
},
});# Make the request
curl --location --request PUT 'https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/complete' \
--header 'Content-Type: application/json' \
--header 'Access-Token: my-token-from-login' \
--data-raw '{
"summary": "Updated stock for 134 products.",
"warning": true
}'Example result:
{
"meta": {
"request_reference": "235chjz9h-c893v86"
},
"data": {
"task_reference": "12345678-abcd-9qwe-zx01-123456789abc"
}
}Record task heartbeat
PUT /v1/tasks/:task/heartbeat
Notifies BladePRO the processing of the task is still underway.
Parameter Regular Expressions
- :task: [0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}
Request Body
Ignored.
Return Type
Rate limit cost
Each call to this endpoint deducts 1 credit from your request bucket.
Scopes
This endpoint is only available for users with scope APP::MISC.
<?php
// Instantiate a GuzzleHttp client
$client = new \GuzzleHttp\Client();
// Make the request
$response = $client->request("PUT", "https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/heartbeat", [
"body" => "{}",
"headers" => [
"Content-Type" => "application/json",
"Access-Token" => "my-token-from-login",
],
]);
// Process the response
$responseBody = json_decode($response->getBody(), true);require 'rest-client'
require 'json'
# Make the request
response = RestClient.put 'https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/heartbeat', {}, {
access_token: 'my-token-from-login',
content_type: :json,
accept: :json
}
# Process the response
puts response.body// Require the node HTTP module
var request = require("request");
// Make the request
request({
method: "PUT",
json: true,
uri: "https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/heartbeat",
headers: {
"Access-Token": "my-token-from-login",
"Content-Type": "application/json",
},
(error, response, body) => {
// Process the response
console.log(body);
},
});# Make the request
curl --location --request PUT 'https://public-api.bladepro.io/v1/tasks/12345678-abcd-9qwe-zx01-123456789abc/heartbeat' \
--header 'Content-Type: application/json' \
--header 'Access-Token: my-token-from-login'Example result:
{
"meta": {
"request_reference": "235chjz9h-c893v86"
},
"data": {
"task_reference": "12345678-abcd-9qwe-zx01-123456789abc"
}
}