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

CreateLog

Return Type

Log

Types for the Request Body

CreateLog (root level)

KeyDescriptionTypesRestrictions
severityThe severity of the log.stringrequired
not null
messageThe message to be recorded.stringrequired
not null
min length is 1
payloadAdditional data to be stored against the message.objectnot null
task_idThe ID of the related task.stringnot null
match is /^[0-9a-z-]{36}$/
serviceWhich service wrote the log message.stringnot null
incident_bindingsBindings for the incident to be created.CreateLogIncidentBindingnot null

CreateLogIncidentBinding

KeyDescriptionTypesRestrictions
userUser ID.numbernot null
companyCompany ID.numbernot null
organisationOrganisation ID.numbernot null
order_goodsoutOrder goodsout ID.numbernot null
order_channelOrder channel ID.numbernot null
product_channelProduct channel ID.numbernot null
product_variationProduct variation ID.numbernot null
product_componentProduct component ID.numbernot null
listingListing ID.numbernot null
vendor_orderVendor order ID.numbernot null
purchase_orderPurchase order ID.numbernot 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

Task

Return Type

Tasks

Types for the Request Body

Task (root level)

KeyDescriptionTypesRestrictions
taskTask code.stringrequired
not null
min length is 1
endpointEndpoint to be hit.Endpointrequired
not null
metadataMetadata.map<string, string>required
not null
min length is 0
payloadPayload.boolean
or number
or object
or string
required
not null
applicationDefinition of the application the task belongs to.Applicationrequired
not null

Application

KeyDescriptionTypesRestrictions
idThe ID of the application.numberrequired
not null
nameThe name of the application.stringrequired
not null
min length is 1
instance_idThe ID of the application’s instance.numberrequired
not null

Endpoint

KeyDescriptionTypesRestrictions
urlURL.stringrequired
not null
min length is 1
methodHTTP method.stringrequired
not null
match 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

FailTask

Return Type

Tasks

Types for the Request Body

FailTask (root level)

KeyDescriptionTypesRestrictions
summaryA summary of why the task failed.stringrequired
not null
min 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

CompleteTask

Return Type

Tasks

Types for the Request Body

CompleteTask (root level)

KeyDescriptionTypesRestrictions
summaryA summary of the task’s outcome.stringrequired
not null
min length is 1
warningMark the task with a warning flag.booleannot 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

Tasks

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"
    }
}