Introduction

This document describes common usage of the Performio APIs, including authentication, HTTP verbs, expected error codes and responses. You will also find links to further documentation regarding the specific APIs available.

Overview

HTTP verbs

Performio APIs attempt to adhere as closely to REST standards and conventions as possible in regards to HTTP verbs. PATCH is not supported and all PUT operations are considered as a full update.

Verb Usage

GET

Used to retrieve a resource

POST

Used to create a new resource

PATCH

Not supported

PUT

Used to update an existing resource, full updates only

DELETE

Used to delete an existing resource

HTTP status codes

Performio APIs attempt to adhere as closely to REST standards and conventions as possible in regards to HTTP status codes.

Status code Usage

200 OK

The request is successful. The response body is variable (e.g. a JSON representation of a resource). Commonly returned by GET methods.

201 Created

The request is successful. A new resource has been created. Commonly returned by POST methods.

204 No Content

The request is successful but there is not content to be returned. Commonly returned by DELETE methods.

400 Bad Request

The request is incorrect or malformed based on the clients input. The server has refused to process the request. The client should not repeat this request without modification.

401 Unauthorized

The request is incorrect as it is either missing a valid authentication header. The server has refused to accept your request.

404 Not Found

The request is well-formed, but part or all of the requested resource could not be found.

409 Conflict

The request is well-formed, but an internal condition is preventing its execution.

422 Unprocessable Entity

The request has been deemed incorrect generally due to validation issues. The client should not repeat this request without modification.

429 Too Many Requests

The called has made too many requests in a specific time period. The client should wait and repeat this request without modification.

500 Server Error

The server has encountered an unexpected error and cannot respond more meaningfully.

Authentication

Performio APIs utilise OAuth 2.0 as an authentication method. In order to utilise the API the Client Credentials grant type is supported, which as defined by the OAuth 2.0 spec is used by clients to obtain an access token outside of the context of a user. In order to access a secure API, you must first obtain an authenticated token and then provide it with every subsequent request to the endpoints.

Before you get started

The first step of calling any API is to be issued with the appropriate API keys. You can request API keys for your instance from Performio support via Zendesk.

You will receive:

  • URL for your gateway (entry point to the APIs), i.e.

https://gateway-domain.performio.co/gateway
  • ClientID, i.e.

5s5OQ61ATFZf2FWjSrdJ9A4Qs
  • ClientSecret, i.e.

yFxRUxXKKLaLFjlvWE5QcG035bMLw4Ht5ldFQxsb17xFDQ8NSL

Obtaining a token

First step is to generate a bearer token. As mentioned, we use the Client Credentials grant which provides a bearer token valid for a certain amount of time, after which a new bearer token needs to be generated. No refresh token is supplied or required.

In order to obtain a token, follow these steps:

  1. Obtain a ClientID and ClientSecret (credentials)

  2. Base64 encode the ClientID and ClientSecret together as "<ClientID:ClientSecret>"

  3. POST to the /oauth/token endpoint with your credentials as Basic HTTP Authentication header

For example, assuming that

  • Client id is 5s5OQ61ATFZf2FWjSrdJ9A4Qs

  • Client secret is yFxRUxXKKLaLFjlvWE5QcG035bMLw4Ht5ldFQxsb17xFDQ8NSL

  • Basic Authentication string is NXM1T1E2MUFURlpmMkZXalNyZEo5QTRRczp5RnhSVXhYS0tMYUxGamx2V0U1UWNHMDM1Yk1MdzRIdDVsZEZReHNiMTd4RkRROE5TTA==

Then your request would be:

$ curl 'https://gateway-domain.performio.co/gateway/oauth/token' -i -X POST \
    -H 'Accept: application/json' \
    -H 'Authorization: Basic NXM1T1E2MUFURlpmMkZXalNyZEo5QTRRczp5RnhSVXhYS0tMYUxGamx2V0U1UWNHMDM1Yk1MdzRIdDVsZEZReHNiMTd4RkRROE5TTA==' \
    -d 'grant_type=client_credentials'

If successful, you will get a response that includes an authenticated access token, similar to:

{
  "access_token" : "e9036e38-d67e-11e8-9f8b-f2801f1b9fd1",
  "token_type" : "bearer",
  "expires_in" : 86399,
  "scope" : "read write trust"
}

Using a token

Once you have obtained a token you must provide it with each request as a Bearer Authentication header to the API endpoints to gain access.

For example, assuming that

  • Access token is e9036e38-d67e-11e8-9f8b-f2801f1b9fd1

  • You wish to get a list of periods

Then your request would be:

$ curl 'https://gateway-domain.performio.co/gateway/calculation/v1/periods' -i -X GET \
    -H 'Accept: application/json' \
    -H 'Authorization: Bearer e9036e38-d67e-11e8-9f8b-f2801f1b9fd1' \

In the event of attempting to use an expired token, you will get a response that is similar to:

{
    "error": "invalid_token",
    "error_description": "Access token expired: e9036e38-d67e-11e8-9f8b-f2801f1b9fd1"
}

Error Responses

Request exceptions produced from within the API will adhere to the following format:

HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
Content-Length: 154

{
  "timestamp" : 1617843928603,
  "status" : 404,
  "error" : "Not Found",
  "message" : "Example exception text.",
  "path" : "/v1/exception/standard"
}
Path Type Description

timestamp

Number

Number representing the timestamp of the caught exception.

status

Number

Number representing the HTTP code of the exception.

error

String

String representing the short hand error message associated with the exception.

message

String

String representing the details of the exception.

path

String

String representing the path to the resource causing the exception.

Validation based exceptions produced form within the API will adhere to the following format:

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json;charset=UTF-8
Content-Length: 246

{
  "timestamp" : 1617843928669,
  "status" : 422,
  "error" : "Unprocessable Entity",
  "message" : "Example exception text.",
  "details" : [ "Description of first issue", "Description of second issue" ],
  "path" : "/v1/exception/validation"
}
Path Type Description

timestamp

Number

Number representing the timestamp of the caught exception.

status

Number

Number representing the HTTP code of the exception.

error

String

String representing the short hand error message associated with the exception.

message

String

String representing the details of the exception.

path

String

String representing the path to the resource causing the exception.

details

Array

Array of Strings representing details for the exception.

Transition from Calculation API

In order to clarify and standardise Performio’s API offering, the Calculation API has been split into three new APIs:

  • Metadata API is responsible for base resources

  • Errand API is responsible for what was called Jobs under the Calculation API, now Errands

  • Document API is responsible for file management

All legacy endpoints are accounted for in the new APIs, and following is a guide on how to transition over.

Calculation API

Replacement

Notes

GET /calculation/v1/batch-processes/{batchId}

GET /errand/v1/errands/{errandId}

Batch Processes (the results of Jobs in the legacy Calculation API) have been wrapped in a new Errand resource. Request and response have been standardised across all Errand types.

GET /calculation/v1/calculations

GET /metadata/v1/batches
GET /metadata/v1/calculations/plan-templates
GET /metadata/v1/calculations/leader-boards
GET /metadata/v1/calculations/scripts

Batches have been separated from Calculations, and each Calculation type has its own endpoint. Results are paginated.

POST /calculation/v1/calculation-jobs

POST /errand/v1/batches
POST /errand/v1/calculations
POST /errand/v2/batches
POST /errand/v2/calculations

Calculation Jobs are now known as Calculation / Batch Errands. If you want to run a Calculation, create a Calculation Errand. If you want to run a Batch, create a Batch Errand. Request and response have been standardised across all Errand types; periodNumber request property has been replaced with periodRange, participantId request property has been replaced with participantIds or participantEids in the case of v2.

GET /calculation/v1/calculation-jobs/logs/{logId}

GET /errand/v1/errands/{errandId}/logs

Request and response have been standardised across all Errand types. Results are paginated.

POST /zuul/calculation/v1/files

POST /zuul/document/v1/import-files

No changes.

GET /calculation/v1/files

GET /document/v1/import-files

No changes.

GET /calculation/v1/files/{id}

GET /document/v1/import-files/{importFileId}

No changes.

GET /calculation/v1/files/{id}/contents

GET /document/v1/import-files/{importFileId}/content

No changes.

GET /calculation/v1/import-file-types/standard

GET /metadata/v1/import-file-types/standard

Response has been standardised.

GET /calculation/v1/import-file-types/custom

GET /metadata/v1/import-file-types/custom

Response has been standardised.

POST /calculation/v1/import-jobs/file

POST /errand/v1/imports/file

Import Jobs are now known as Import Errands. Request and response have been standardised; periodNumber request property has been replaced with periodRange.

POST /calculation/v1/import-jobs/record

POST /errand/v1/imports/records

Import Jobs are now known as Import Errands. Request and response have been standardised; periodNumber request property has been replaced with periodRange.

GET /calculation/v1/participants

GET /metadata/v1/participants

Results are paginated.

GET /calculation/v1/periods

GET /metadata/v1/periods

Results are paginated.

APIs

Metadata API

The Metadata API provides access to the basic resources found within Performio, i.e. Custom Tables, Participants, Periods etc. Further documentation is available here.

Document API

The Document API provides mechanisms to upload and manage files in Performio. Further documentation is available here.

Errand API

The Errand API provides mechanisms to send requests to the Calculation Engine to execute Calculations, Imports and Imported Data Deletes asynchronously. Further documentation is available here.

Extract API

The Extract API provides mechanisms to extract rows from Custom Tables utilising filters. Further documentation is available here.

Calculation API (Legacy)

The Calculation API has been deprecated, all endpoints have been replicated and improved in other APIs. Further documentation is available here.