Please note that we intend to keep this specification as accurate and stable as possible, however work on the API v3 is still ongoing and not all resources and actions in OpenProject are yet accessible through the API.

This document will be subject to changes as we add more endpoints and functionality to the API. The development version of this document may have breaking changes while we work on new endpoints for the application.

We try to keep stable releases of OpenProject with changes to this API backwards compatible whenever possible.

Hypermedia REST API

The APIv3 is a hypermedia REST API, a shorthand for “Hypermedia As The Engine Of Application State” (HATEOAS). This means that each endpoint of this API will have links to other resources or actions defined in the resulting body.

These related resources and actions for any given resource will be context sensitive. For example, only actions that the authenticated user can take are being rendered. This can be used to dynamically identify actions that the user might take for any given response.

As an example, if you fetch a work package through the Work Package endpoint, the update link will only be present when the user you authenticated has been granted a permission to update the work package in the assigned project.

HAL+JSON

HAL is a simple format that gives a consistent and easy way to hyperlink between resources in your API. Read more in the following specification: https://tools.ietf.org/html/draft-kelly-json-hal-08

OpenProject API implementation of HAL+JSON format enriches JSON and introduces a few meta properties:

  • _type - specifies the type of the resource (e.g.: WorkPackage, Project)
    • _links - contains all related resource and action links available for the resource
    • _embedded - contains all embedded objects

HAL does not guarantee that embedded resources are embedded in their full representation, they might as well be partially represented (e.g. some properties can be left out). However in this API you have the guarantee that whenever a resource is embedded, it is embedded in its full representation.

API response structure

All API responses contain a single HAL+JSON object, even collections of objects are technically represented by a single HAL+JSON object that itself contains its members. More details on collections can be found in the Collections Section.

Authentication

The API supports the following authentication schemes: OAuth2, session based authentication, and basic auth.

Depending on the settings of the OpenProject instance many resources can be accessed without being authenticated. In case the instance requires authentication on all requests the client will receive an HTTP 401 status code in response to any request.

Otherwise unauthenticated clients have all the permissions of the anonymous user.

Session-based Authentication

This means you have to login to OpenProject via the Web-Interface to be authenticated in the API. This method is well-suited for clients acting within the browser, like the Angular-Client built into OpenProject.

In this case, you always need to pass the HTTP header X-Requested-With "XMLHttpRequest" for authentication.

API Key through Basic Auth

Users can authenticate towards the API v3 using basic auth with apikey (as a string, NOT your API key) as the user name and their API key as the password. Users can find their API key on their account page.

Example:

API_KEY=2519132cdf62dcf5a66fd96394672079f9e9cad1
curl -u apikey:$API_KEY https://community.openproject.com/api/v3/users/42

OAuth2.0 authentication

OpenProject allows authentication and authorization with OAuth2 with Authorization code flow, as well as Client credentials operation modes.

To get started, you first need to register an application in the OpenProject OAuth administration section of your installation. This will save an entry for your application with a client unique identifier (client_id) and an accompanying secret key (client_secret).

You can then use one the following guides to perform the supported OAuth 2.0 flows:

Why not username and password?

The simplest way to do basic auth would be to use a user’s username and password naturally. However, OpenProject already has supported API keys in the past for the API v2, though not through basic auth.

Using username and password directly would have some advantages:

  • It is intuitive for the user who then just has to provide those just as they would when logging into OpenProject.

  • No extra logic for token managment necessary.

On the other hand using API keys has some advantages too, which is why we went for that:

  • If compromised while saved on an insecure client the user only has to regenerate the API key instead of changing their password, too.

  • They are naturally long and random which makes them invulnerable to dictionary attacks and harder to crack in general.

Most importantly users may not actually have a password to begin with. Specifically when they have registered through an OpenID Connect provider.

Allowed HTTP methods

  • GET - Get a single resource or collection of resources

  • POST - Create a new resource or perform

  • PATCH - Update a resource

  • DELETE - Delete a resource

Compression

Responses are compressed if requested by the client. Currently gzip and deflate are supported. The client signals the desired compression by setting the Accept-Encoding header. If no Accept-Encoding header is send, Accept-Encoding: identity is assumed which will result in the API responding uncompressed.