Corezoid API
  • 17 Jun 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Corezoid API

  • Dark
    Light
  • PDF

Article summary

Expand your capabilities of working with Corezoid Actor Engine by using:

  • Corezoid's asynchronous API (Corezoid API reference) enables the automation of creating and modifying tasks, processes, and operations on objects like creating, uploading, and restoring folders, State Diagrams, and Dashboards.
  • Corezoid synchronous API (Sync API) enables the retrieval of task-invoked process outputs.

These features provide you with the flexibility to dynamically manage your Corezoid environment. Moreover, you can work with "real-time" processes that can be adjusted based on incoming data and predefined business logic.

postman Use our collection of Corezoid API queries for Postman as an example.

API protocol – use prerequisites

Before using the Corezoid API:

  1. Create an API key.
  2. Create a pre-request script.

Create API key

To create an API key and get an API login (authorization login) and a secret key, follow the path and see the video below:
Users & Groups -> Create -> API key -> enter name -> OK

create_api_key

Create pre-request script

To create a pre-request script to be able to generate signatures for the API requests you send (via Postman, for example):

  1. Copy the {API_LOGIN} authorization login, and {SECRET} secret key (by clicking the icon to the right in your API keys list), and use the following URL:

    https://api.corezoid.com/api/2/json/{API_LOGIN}/{TIMESTAMP}/{SIGNATURE}
    

    Where:

    • {API_LOGIN}: Is an authorization login of your API key;

    • {TIMESTAMP}: Is request time, a Unix timestamp (epoch time) by Greenwich (GMT+0) that requires an integer parameter.

    • {SIGNATURE}: Is a concatenated string generated from the following parts:

      hex( sha1({TIMESTAMP} + {SECRET} + {CONTENT} + {SECRET}) )
      where:

      • {TIMESTAMP}: Is a request time, a Unix timestamp (epoch time) by Greenwich (GMT+0); requires an integer input.
      • hex(): Converts binary data to hexadecimal form.
      • sha1(): Is a standard hash-function SHA-1 that must return binary data.
      • +: Is text string concatenation.
      • {SECRET}: Is the secret key for your API key.
      • {CONTENT}: Is a request body.
  2. Use the following script for signing your requests:

    var time = Math.floor(Date.now() / 1000);
    var secret = pm.environment.get("SECRET");
    var content = request.data;
    var signature = CryptoJS.enc.Hex.stringify(CryptoJS.SHA1(time + secret + content + secret));
    pm.environment.set("TIMESTAMP", time);
    pm.environment.set("SIGNATURE", signature);
    

    Note: The entire API request is an http-body described as the {CONTENT} in the {SIGNATURE} formula. All text is expected to be encoded as UTF-8.

  3. Send an API request with the following HTTP header:
    Content-type: application/json; charset=utf8

API operations on objects of a company different from the one which user you are currently using are forbidden. Sending an API request to perform an operation on an object in another company will result in the following error: Company of object does not match companyId of request.

Example of node creation request and response

The request body contains a list of operations (ops):

{
  "ops": [
    {
      "id": 1,
      "type": "create",
      "obj": "conv"
    },
    {
      "type": "modify",
      "obj": "node",
      "obj_id": "n1234"
    }
  ]
}

The id parameter ("string" format) is optional and is used for identifying operations in the ops array. If not specified, the parameter is returned with an empty value ("id": "") in the response.

Response

{
  "request_proc": "ok",
  "ops": [
    {
      "id": 1,
      "obj": "conv",
      "obj_id": "1234",
      "proc": "ok"
    },
    {
      "id": "",
      "obj": "node",
      "obj_id": "n1234",
      "proc": "obj_id_not_found"
    }
  ]
}
ParameterValueDescription
request_procok – successful request, error – other cases.Global status of whole package processing.
ops[]List of operations.
ops[n].procok – successful request, error – other cases.Status for a separate operation.

Examples of task adding and modification requests

When using the Corezoid API:


Was this article helpful?