Create or update activity definitions

Create or update activity definitions

Introduction

You can use this endpoint to create a new or update an existing activity definition. This behavior depends on the use of the reference, as follows:

  • If the external reference corresponds to an existing activity definition, that definition will be updated.
  • If the external reference does not match any existing activity definition, a new one will be created.
  • Creating or updating activity definitions is only possible using an external reference.

When using an internal ID as a reference, only an update is supported since these ID’s are generated during creations and can’t be provided. An update of the activity definition will happen when it already exists, or a “404: not found” error will be responded when the internal ID is not known in our system.

Tip

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

Caution

If some other required fields are missing from the request, they will be left empty.

Endpoint details

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

URL parameters

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

Parameter Description
<structureVersionId> The ID of the activity structure. The ID can be found in the configuration in myProtime.
<level> Defines the level in the structure.
<activityDefinitionReference> The internal ID (GUID) or an external reference of the activity definition.

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.
changeVersion integer Version number that increments with each change to the activity definition. Used for tracking updates and delta synchronization. Read-only

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.

Caution

There are some restrictions on the characters allowed in URL requests. See the fetching resources page for more information.

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.

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.

Parent in hierarchy

If the ID matches an existing activity definition and it has a parent, the parent should be included in the request. Otherwise, a “Bad Request” response will be returned. It’s possible to use an external reference for the parent.

Examples

Create activity definition

Example creating an activity definition using custom external reference Cleaning:

PUT
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/b2347a7a-d60d-446f-b03b-7es2cc8c3281/levels/3/activity-definitions/Cleaning?externalReferences=(activity-definitions,CustomActivityReference)

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

Update activity definition with data entry code

Example updating an activity definition using data entry code 20003:

PUT
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/b2347a7a-d60d-446f-b03b-7es2cc8c3281/levels/3/activity-definitions/20003?externalReferences=(activity-definitions,@data-entry-code)

{
  "name": {
    "default": "Cleaning"
  },
  "shortCode": "A003",
  "dataEntryCode": "20003",
  "externalReference": "CL01",
  "info": "Updating Activity Definition",
  "activeFrom": "2025-01-01",
  "activeUntil": "2025-09-30"
}

Create activity definition with hierarchy

Example creating an activity definition with hierarchy using custom external reference Maintenance:

PUT
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/b2347a7a-d60d-446f-b03b-7es2cc8c3281/levels/2/activity-definitions/Maintenance?externalReferences=(activity-definitions,CustomActivityReference)

{
  "name": {
    "default": "Cleaning",
    "translations": {
      "nl": "Schoonmaken",
      "fr": "Nettoyer"
    }
  },
  "parent": {
    "id": "0b3642ae-16c9-4914-b099-2ba4b99d5ee9"
  },
  "shortCode": "CL_002",
  "dataEntryCode": "00026",
  "externalReference": "Cleaning",
  "info": "Cleaning activities under maintenance",
  "activeFrom": "2025-01-01",
  "activeUntil": "2026-01-01"
}

Update with custom external reference

Example updating with custom external reference 122456:

PUT
https://<tenant>.myprotime.eu/connector/protimeapi/api/v1/activity-structure-versions/b2347a7a-d60d-446f-b03b-7es2cc8c3281/levels/3/activity-definitions/122456?externalReferences=(activity-definitions,CustomActivityReference)

{
  "name": {
    "default": "Sales Activities",
    "translations": {
      "nl": "Verkoopactiviteiten",
      "fr": "Activités de vente"
    }
  },
  "shortCode": "SA_001",
  "dataEntryCode": "10001",
  "externalReference": "122456",
  "info": "All sales related activities",
  "activeFrom": "2025-01-01"
}