Skip to main content

Enabling API access

Instructions for creating an API key and connecting All Hours to external tools.

Written by Gregor Bercic

All Hours lets you import, export and modify data via API calls. To get access, first create an API key.

  1. Open Settings > Advanced and expand the API section.

  2. Click Create API key, enter a name, select the authorization role and confirm.

  3. The system generates a Client ID and Client Secret. Store them in a secure place, as you will not be able to view them again.

  4. The key is then listed in the API section. Delete a key to revoke access; you can create several keys for different applications.

    Note: All supported API calls are described on the API4 website.

API Access and Example Use Case

All Hours uses a REST API (JSON) at https://api4.allhours.com, where you will also find the documentation (Swagger) describing the data structures and queries.

Authentication uses the OAuth2 protocol. Obtain a token at https://login.spica.com/connect/token (grant type client_credentials, scope api) using your Client ID and Client Secret.

Example Use Case: Retrieving Annual Leave Information

  1. Retrieve the absence ID.

    The ID is shown in the URL of the absence page in Settings > Event Definitions, or it can be retrieved with an API query.

  2. Run an API call that returns:

    • the total annual leave,

    • annual leave for a specific time period,

    • leave for a specific user.

  3. Absence status codes

    The absence status field has the following values:

    0 – automatically approved (no approval workflow)

    1 – pending approval

    2 – approved

    3 – rejected

    4 – automatically approved, other approvers receive a notification of the automatic approval

Did this answer your question?