REST API Documentation
REST API Documentation
OpenL Studio publishes a REST API under {context-path}/rest, and OpenL Rule Services publishes a management API under
{context-path}/admin. These pages describe the parts of the API that need more than the generated reference.
Reference
- OpenAPI document —
GET /rest/openapi.json. It needs no sign-in and lists every endpoint of OpenL Studio. - API documentation page —
/api-docsin OpenL Studio, linked from the Help page as Internal REST API Documentation. It shows the OpenAPI document. - WebSocket —
/ws. The server pushes the changes of projects, compilation, comparison, and trace sessions; see WebSocket Change Notifications.
Pages
OpenL Studio
- Data Tables API — read, replace, and append the rows of a Data table.
- Test Tables API — read, replace, and append the test cases of a Test table.
- Lookup Tables API — read, replace, and append the rows of a SmartLookup or a SimpleLookup table.
- Raw Tables API — read and edit any table as a matrix of cells: values, merges, styles, rows, and columns.
- Projects Merge API — check and perform the merge of Git branches, and resolve the conflicts. Architecture.
- Project Local History API — read, restore, compare, and clear the unsaved versions of a module.
- Project Localization API — read the localization messages of a project by pages of keys, change them in one write, and check the files.
- Personal Access Token API — create and revoke the tokens for programs. Architecture.
- Projects Trace API — the interactive debugger of a table. Architecture.
OpenL Rule Services
- Rule Services Admin API — the deployed services, the health probes, and the deployment of projects.
Conventions
Authentication
single— the user modesinglehas no authentication.- Other user modes — a request carries the credentials that the mode accepts: the browser session, HTTP Basic in
adandmulti, an OAuth2 bearer token inoauth2, or a personal access token in every mode exceptsingle. - Public paths —
/rest/openapi.json,/rest/settings, and/rest/public/**need no credentials.
Projects
{projectId} in a path is the project id GET /rest/projects hands out: 13 upper-case characters of Crockford’s Base32, computed
from the repository and the folder that hold the project, so it stays the same when the project is opened, closed,
renamed in rules.xml or switched to another branch. An id that matches no project answers 404 Not Found, and so do
a project name and an id of OpenL Studio 6.x. While the server runs, the id a project had before its folder moved
outside OpenL Studio still names it: the request is served for the project, and the Content-Location header gives
the address under its current id. The id of a deleted project answers 410 with
openl.error.410.project.deleted.message. See Stable Project Ids.
The status of a project tells changedOnDisk when another program changed the files of the project since the session
compiled it. A client asks it in short before working with the tables,
GET /rest/projects/{projectId}?include=status&fields=compileStatus(compileState,changedOnDisk), and compiles the
module again with POST /rest/projects/{projectId}/modules/{module}/compile?reset=true when the files changed.
Pages of Results
A list endpoint takes size (the page size, 50 by default) and either page (the zero-based page number) or offset
(the zero-based index of the first item), or unpaged=true for all the results. It answers
{"content": [...], "pageNumber": 0, "pageSize": 50, "numberOfElements": 50, "total": 120}. total is absent when the
total is not known.
Response Fields
A response carries the fields of its type, minus the empty values. The query parameter fields keeps only some of them:
fields=name,owner(email) keeps name and the email of owner. An unknown field is dropped. A malformed selection, or
one longer than 4096 characters, deeper than 16 levels, or with more than 256 names, answers 400, and a request that
creates or changes data then changes nothing.
A field left out may cost nothing. GET /rest/projects/{projectId} looks for the projects using this one (usedBy),
reading the descriptor of every other project, only when the selection keeps them. It resolves the messages of the
status to their tables (compileStatus.compilation.messages.items), which waits for a compilation under way, only when
the selection keeps them or the names of the compiled modules. Such a status of an opened project nobody compiled yet
holds the messages of the check of its localization files, which needs no compilation, while compileState stays
idle.
Errors
An error answers with a body of this form, where <key> is the message code, and message is its localized text:
{
"code": "openl.error.404.table.message",
"message": "The table is not found."
}
400 Bad Request— the request is malformed or refused by a rule of the endpoint. A request body that fails validation answers{"message": "Bad Request", "fields": [{"code": "...", "message": "...", "field": "...", "rejectedValue": ...}]}. A body field or a request parameter that breaks a constraint is coded by the constraint, such asopenl.error.NotBlankoropenl.error.Size, whatever message the endpoint gives it.401 Unauthorized— the request has no valid credentials.403 Forbidden— the user may not do it, or the endpoint is closed to personal access tokens. A refusal by a security rule answers{"message": "Access Denied"}.404 Not Found— the project, the table, or another resource does not exist.409 Conflict— the state of the project does not allow it: the project is not opened, is locked by another user, or has unresolved merge conflicts.410 Gone— the project or the table an id named was deleted.412 Precondition Failed— the version named inIf-Matchis not the current one: the table or the file changed since it was read, and nothing is written.
Table Endpoints
The tables of a project have one set of endpoints for every table type. The table types differ in the JSON model that the
endpoints read and write, and in tableType that selects it.
GET /rest/projects/{projectId}/tables— a page of the tables of the project, with theidof each. The filters arekind,name,module,scope,header,text, andproperties.<name>, andincludeOther=trueadds the tables that OpenL does not recognize.GET /rest/projects/{projectId}/types— the datatypes and vocabularies the rules of the project may name, as the compiler resolved them, those of the projects it depends on included: each datatype with all its fields, the inherited ones first, each vocabulary with its values. A type whose own table did not compile is missing.POST /rest/projects/{projectId}/tables— creates a table in a module and answers201 Createdwith its summary.GET /rest/projects/{projectId}/tables/{tableId}— reads the table in the model of its type, or, withraw=true, as a matrix of cells.PUT /rest/projects/{projectId}/tables/{tableId}— replaces the content of the table.POST /rest/projects/{projectId}/tables/{tableId}/lines— appends lines to the table.POST /rest/projects/{projectId}/tables/{tableId}/actionsand.../actions/batch— edit the raw source; see Raw Tables API.PATCH /rest/projects/{projectId}/tables/{tableId}/properties— updates the properties of the table.DELETE /rest/projects/{projectId}/tables/{tableId}— deletes the table.
Table types: Datatype, Vocabulary, Spreadsheet, SimpleSpreadsheet, SimpleRules, SmartRules, SmartLookup,
SimpleLookup, Data, Test, and RawSource. The write endpoints take the model of the type in tableType.
Rules for every table endpoint:
- Opened project — the project is opened first with
PATCH /rest/projects/{projectId}and{"status": "OPENED"}. Otherwise the answer is409withopenl.error.409.project.not.opened.message. - Table id —
{tableId}is an opaqueidfrom the table list, made of the module, the kind and the name of the table, or itsidproperty. A table keeps it when it moves, on its sheet or to another sheet, and gets a new one when it is renamed or itsidproperty changes. An id the table had before a rename still names it while the server runs: the request is served for the table, and theContent-Locationheader gives the address under the current id. An id of a table OpenL Studio deleted answers410withopenl.error.410.table.deleted.message; see Stable Table Ids. - Module — the optional query parameter
modulereads or writes the table through one module. The answer is ready once that module is compiled, without waiting for the rest of the project. Without it the endpoint waits for the whole project. - Responses of a write —
204 No Contentwhen the table keeps its id, also when it had no room to grow and moved.200 OKwith{"id": "<new id>"}and aLocationheader when the write renamed the table or changed itsidproperty, or when the request named the table by an id it had before. - Lock — a write locks the project for the user, and a write by another user answers
409withopenl.error.409.project.locked.by.message; see The Project Editing Lock. - Partial tables — a table that is written as several partial tables is read, and a write to it answers
400withopenl.error.400.table.partial.message. Excel edits such a table. - Version — a read tells the version of the table in the
ETagheader; the body carries none. A write that names it in theIf-Matchheader is refused with412andopenl.error.412.table.changed.since.read.messagewhen the table changed since the read, on disk or through another client, and nothing is written. A write without the header, or with*, is made over any version; a weak tag matches none. A write of a workbook whose file another program changed since OpenL Studio read it answers409withopenl.error.409.workbook.changed.outside.message; see Changes Made Outside OpenL Studio.
Read-only fields of every table model:
messages— the compilation messages of the table. A message has anid, asummary, aseverity(INFO,WARN, orERROR), alocation(thetypemoduleortable, and where it is), andstacktrace: truewhen a stack trace is available, whichGET /rest/projects/{projectId}/messages/{messageId}/stacktracereads.runState— withrunState=true:can-run,can-run-module(runs against the module that holds the table only), orcannot-run.partial—truefor a table that is written as several partial tables.
The version of the table read is not a field of the model: the ETag header of the read answers it, and a write names
it in If-Match. It changes whenever the text of a cell of the table changes.
Cell values in the models are a string, a number, a boolean, or null. A date is an ISO 8601 string.