API functions

An API function is a CJ block exposed as HTTP resource. Use API functions to perform operations not provided by data types REST API.


An API function is exposed at:

POST https://app.url/api/URLpath

Where

  • app.url is the application alias (by default it's app{appID}.codejig.com, for example: app1234.codejig.com)
  • URLpath is the API function URL path


Input has to be provided inside request body encoded as JSON. If the body is empty we will pass null as an argument to the function.

Output will be encoded as JSON as well.


Application API uses HTTP Basic Authentication. Authorization header must be constructed from login and password of app-only users (credentials of Codejig users will be rejected).

Resources that do not have any permission restrictions are accessible without authorization HTTP header.


Example request:
POST /api/calculateBalance HTTP/1.1
Host: app1234.codejig.com
Authorization: Basic dXNlcjpwYXNzd29yZA==
Content-Type: application/json
Accept: application/json
Content-Length: 67
{
    "field2500000020896417328": {
        "id": "4611686018427392048"
    }
}