Minimum Software Version8.15.0
Solution(s)Cases International Cases US Institutions

Third party software vendors can integrate with Opus 2 via REST API. Once set up, a user can get a token from the application and then they can give that to a third party application that has been set up to read and write content via the API as an alternative to logging in and viewing and editing content through the user interface.

For the Documents API, there are two types of connections, inbound and outbound. This article describes the INBOUND Documents API for integrations whereby third-party vendors can control users and data in the Platform v8 environment.  

To see examples of requests and responses using cURL for each endpoint, see the attached PDF of the Swagger output for this API at the bottom of this article. 

Prerequisites

To use the Inbound Documents REST API,  an Operator must switch on the following settings:  

System-wide setting:              Allowing access to the integrations API

Project specific setting:          Download docs via API

Create a user (token owner) who has Read Write access to the project containing the resource being read or written.

Structure of the API URL

The API URL is structured as follows:

{tenant url}/ENDPOINT -i -X VERB \  -H ‘X-API-Token:TOKEN -d {data}

where:

{tenant URL}RequiredThe tenant URL for to accessing the server. Example: https://xyz.api-example.com
EndpointRequiredExamples: Users
See table of endpoints.

-iRequiredCurl syntax option to request that the response to the request is included along with the headers.
-XRequiredCurl syntax option to specify that an HTTP verb follows.
HTTP verbRequiredExample: GET. See table of HTTP verbs.
-HRequiredCurl syntax option for sending a header value.
X-API-tokenRequiredThe authentication token. Example: 'X-Tenant-Token: abcdefGI1NiJ9.eyJsYXN0TG9naW4iOiIyMDIxLTA3LTAxIDE
yOjAxOjAxIiwidGVhbXMiOlsidGVhbSJdLCJ0ZW5hbnRJZC
I6InRlbmFudElkIiwic3VwZXJhZ etc
-dVerb dependentCurl syntax option for sending data, for example, when using POST.

Client codes

400 Bad Request response: You sent invalid JSON or the incorrect type of JSON values. Example: Invalid timestamp format. Use format xxxxx.

409 You cannot delete the only version of a document

Error codes

403: You do not have permission to delete this file

404: Request for a non-existent entity. Example: Document version not found.

500: Backend error

Return codes

CodeDescription
200Success
201Create Success
401Unauthorised. Example: The provided API token is invalid.
400Validation failed. Example: Invalid version ID Format

HTTP verbs

VerbDescription
HEADCan be issued against any resource to get just the HTTP header info.
GETUsed for retrieving resources.
POSTUsed for retrieving resources.
PATCHUsed for updating resources with partial JSON data. For instance, an Issue resource has title and body attributes. A PATCH request may accept one or more of the attributes to update the resource. PATCH is a relatively new and uncommon HTTP verb, so resource endpoints also accept POST requests.
PUTUsed for replacing resources or collections. For PUT requests with no body attribute, be sure to set the Content-Length header to zero.
DELETEUsed for deleting resources.

Working with tokens and making requests

The token should be sent as the X-Api-Token header. This identifies the user making the request and determines if the request will be accepted.  Once the user making the request (the owner of the token) has been identified, then the request proceeds with the permissions and access rights of that user. Not all API requests are accessible to all users.

For a request to complete successfully, the token owner must have access to the project containing the resource being read or written and must have the appropriate capabilities within that project to create, read, or update the resource according to the operation being performed. Therefore, this user should be created by default on each project created within Opus 2 as part of the project template settings as per the Prerequisites above.


Payload fields for token API

Path

Type

Description

Name

String

The name of the token

userId

String

The Platform user ID that the token was generated for.


Payload JSON for token API

{"userId":"userId","name":"ATokenName"}

APIActionEndpoint and HTTP Verb
TokensAdd a token to a requesttokens + POST

Get all token detailstokens + GET

Delete a tokentokens + DELETE

Inbound documents API endpoints

APIActionEndpoint and HTTP Verb
UsersQuery (Read) all roles in the documentroles + GET

Query all users in the documentusers + GET

Query a user in the document by Iduser/id/userId + GET

Query a user in the document by emailuser/byemail?email=user@user.com + GET

Add a user(s)users + POST
APIActionEndpoint and HTTP Verb
User teamsQuery (Read) all teams in the documentteams + GET

Query all users in a teamteams/teamId/users + GET

Add a new user to a teamteams/teamId/users/email + PUT

Delete a user from a teamteams/teamId/users/email + DELETE
APIActionEndpoint and HTTP Verb
ProjectsQuery (Read) all projectsprojects + GET

Query a single projectprojects/projectId/ + GET

Add a projectprojects + POST

Query teams in a project (user groups)projects/projectId/teams + GET

Add a project teamprojects/projectId/teams/teamId + PUT

Delete a project teamprojects/projectId/teams/teamId + DELETE

Query all project usersprojects/projectId/users +GET

Add a user to a projectprojects/projectId/users/email + PUT

Delete a user from a projectprojects/projectId/users/email + DELETE
APIActionEndpoint and HTTP Verb
TemplatesQuery all templates in a documenttemplates + GET
APIActionEndpoint and HTTP Verb
FoldersQuery (Read) all folders in the projectprojects/projectId/folders + GET

Query a single folder in the projectprojects/projectId/folders/the%20folder + GET

Add a folder to a projectprojects/projectId/folders + POST

Delete a folder from a projectprojects/projectId/folders/folderId/ + DELETE
APIActionEndpoint and HTTP Verb
DocumentsQuery (Read) all documents in a projectprojects/projectId/documents + GET

Query documents using a date filterprojects/projectId/documents?afterDate= + GET

Add a document to a project, avoiding duplicatesprojects/projectId/documents?rejectDuplicate=true + POST

Query documents in a specific folderprojects/projectId/documents/folder/folderId + GET

Query documents in a folder using a date filterprojects/projectId/documents/folder/folderId?afterDate= + GET

Query a single document in a folderprojects/projectId/documents/documentID + GET

Move document into another folderprojects/projectId/documents/documentID/folderId + PUT

Replace document with a new version of the documentprojects/projectId/documents/documentID/replace + POST

APIActionEndpoint and HTTP Verb
FieldsRead metadata fields in a projectprojects/projectId/fields + GET


Update metadata fields in a documentprojects/projectId/documents/documentId/fields/fieldId + PUT

Performance considerations

There are no API-specific performance considerations. Operations resulting from calls to the API are handled by the same back-end services as interactive events from users accessing the system via the web interface, and have the same performance profile as the application as a whole.

API rate limiting

The system supports API rate limiting to prevent applications using the API from overwhelming the system and harming the interactive user experience. This is configurable on a per-client basis with a  initial default rate limit of 50 requests per minute.

The API follows a conventional REST model but does not implement any particular specification. Pagination is supported on all the endpoints that can return significant volumes of data (documents, folders, worksheet record etc). 

Related articles

Features only accessible in Operator mode

Obtaining a REST API authentication token

If you require functionality not provided by the existing REST API, contact Opus 2 Platform Support.