Create activity definition

Introduction

Create a new activity definition using the POST endpoint. The ID of the newly created activity definition will be available in the Location header of the response.

Tip

Check the Swagger page for more technical information on the endpoints.

Endpoint details

POST
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/{structureVersionId}/levels/{level}/activity-definitions

URL parameters

These parameters need to be filled in when calling this endpoint.

Parameter Description
<structureVersionId> The ID of the activity structure. Can be found in the configuration in myProtime.
<level> Defines the level in the structure.

Body properties

This list of properties is applicable for this endpoint.

Property Type Description
name.default string Default name value of the activity definition. Shown to users if no translation is available. Required
name.translations object A list of translated names by language code. Allows localization for different languages.
parent.id string Unique identifier of the parent activity definition in a hierarchy set-up. Can only be set during creation!
shortCode string Short code for the activity definition.
dataEntryCode string Data entry code for the activity definition, mostly used on hardware devices. Mandatory or optional depending on configuration. Can only be 16 characters long!
externalReference string External reference identifier for the activity definition. Needs to be unique within the structure and level when used! Can only be 16 characters long!
info string Additional information about the activity definition. Can be used for notes or extra details.
activeFrom string Start date (YYYY-MM-DD) when the activity definition is active. Controls when the definition becomes available for registrations.
activeUntil string End date (YYYY-MM-DD) when the activity definition is no longer active. Controls when the definition is no longer available.

Tip

If your configuration requires users to manually enter the data entry code when creating an activity definition, the dataEntryCode field is mandatory and must be provided in the request body. It cannot be null or omitted. If this field is missing, the API will return a 400 Bad Request error. Please ensure you include dataEntryCode when required by your configuration.

External references

It’s possible to use predefined external references and custom external references. More information can be found on the External References Page.

For a list of predefined external references, see the external reference options section.

Note

Check the query options below the endpoint on the Swagger page for the relevant external references.

Good to Know

Data entry code configuration

The dataEntryCode field behavior depends on your Protime configuration:

  • Auto-generated: Protime automatically generates data entry codes when creating activity definitions.
  • Manual entry: When configured to require manual entry, you must provide the dataEntryCode in your request. The field becomes mandatory and the API will return a 400 Bad Request error if it’s missing or null.

Data entry codes are primarily used on hardware devices for quick activity selection. See the property table above for field constraints.

Understanding hierarchy

A hierarchy is a structured way to organize and manage complex data by adding order and relationships. For instance, in a multinational organization, tracking an activity might become challenging when every country has a “Sales” department. Instead of using overly detailed names (e.g., “Country - City - Sales”), a hierarchy allows the user to define levels such as Company > Country > Location > Department. This ensures uniqueness and simplifies tasks like filtering reports (e.g., selecting all activities for “Country” with one filter).

Add hierarchy

If you want to add a hierarchy, a parent ID must be included in the request. This ID is available in the location header after a successful POST call for an activity definition. It’s possible to use predefined or custom external references for the parent.

Hierarchy can only be used when an activity definition is created. Updating a hierarchy isn’t possible.

Note

If you need to update the parent because it was created incorrectly:

  • Set an end date on the current activity definition to close it.
  • Create a new activity definition with the correct parent.
  • Ensure that the necessary references remain unique.

Default usage

When your activity structure contains hierarchical levels, you can enable “default usage” in the activity structure configuration. This automatically adds a usage with an infinite period for the organizational chart group(s) to whom the structure is assigned for any activity definition created in the top level of your hierarchy.

This can be useful as you no longer need to assign usages to hierarchies manually. Manual usage configuration is still possible if you need to limit access to specific circles, groups, or people.

Examples

Create basic activity definition

Example creating a basic activity definition:

POST
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/1604fc20-8bf2-449f-83d9-1f3092283646/levels/2/activity-definitions

{
  "name": {
    "default": "Cleaning",
    "translations": {
      "nl": "Schoonmaken",
      "fr": "Nettoyer"
    }
  },
  "shortCode": "CL_001",
  "dataEntryCode": "00025",
  "externalReference": "Cleaning",
  "info": "Cleaning the main building",
  "activeFrom": "2025-01-01",
  "activeUntil": "2026-01-01"
}

Create activity definition with hierarchy

Example creating an activity definition with a parent hierarchy:

POST
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/1604fc20-8bf2-449f-83d9-1f3092283646/levels/3/activity-definitions

{
  "name": {
    "default": "Cleaning",
    "translations": {
      "nl": "Schoonmaken",
      "fr": "Nettoyer"
    }
  },
  "parent": {
    "id": "0b3642ae-16c9-4914-b099-2ba4b99d5ee9"
  },
  "shortCode": "CL_001",
  "dataEntryCode": "00025",
  "externalReference": "Cleaning",
  "info": "Cleaning the main building",
  "activeFrom": "2025-01-01",
  "activeUntil": "2026-01-01"
}

Create activity definition with external reference for parent

Example creating an activity definition using an external reference for the parent:

POST
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/1604fc20-8bf2-449f-83d9-1f3092283646/levels/2/activity-definitions?externalReferences=(activity-definitions,@data-entry-code)

{
  "name": {
    "default": "Sales Activities",
    "translations": {
      "nl": "Verkoopactiviteiten",
      "fr": "Activités de vente"
    }
  },
  "parent": {
    "externalReferences": {
      "@data-entry-code": "10000"
    }
  },
  "shortCode": "SA_001",
  "dataEntryCode": "10001",
  "externalReference": "SALES01",
  "info": "All sales related activities",
  "activeFrom": "2025-01-01"
}

Create activity definition without end date

Example creating an activity definition without an end date:

POST
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/1604fc20-8bf2-449f-83d9-1f3092283646/levels/1/activity-definitions

{
  "name": {
    "default": "HR"
  },
  "shortCode": "HR",
  "dataEntryCode": "2002",
  "externalReference": "HR00002",
  "info": "Human Resource department",
  "activeFrom": "2025-01-01"
}