Create activity definition

Creates a new activity definition record.

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

Headers: Authorization: Bearer {token}, User-Agent: {agent} Scope: connector-protimeapi-activity-definitions.write

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

Field Type Required Writable Description
name.default string Yes Yes Default name value of the activity definition. Shown to users if no translation is available.
name.translations object No Yes A list of translated names by language code. Allows localization for different languages.
parent.id Guid No Yes Unique identifier of the parent activity definition in a hierarchy set-up.
parent.externalReferences object No Yes External references to resolve the parent activity definition.
shortCode string No Yes Short code for the activity definition. Maximum 50 characters.
dataEntryCode string No Yes 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 No Yes 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 No Yes Additional information about the activity definition. Can be used for notes or extra details.
activeFrom date No Yes Start date (YYYY-MM-DD) when the activity definition is active. Controls when the definition becomes available for registrations.
activeUntil date No Yes End date (YYYY-MM-DD) when the activity definition is no longer active. Must be greater than or equal to activeFrom when both are specified.
externalReferenceIdentifier object No Yes A single key-value pair identifying the activity definition in an external system. Also acts as the duplicate guard. See External reference identifier.

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.

Warning

Tenants using Planning Flex cannot assign validity dates (activeFrom / activeUntil) on workspace or work-area levels (levels 2 and 3). Only the top-level (company) supports validity dates in this configuration. Sending activeFrom or activeUntil on a lower level returns a 400 Bad Request with reason CannotAssignValidityPeriodOnWorkspaceOrWorkarea.

External references

This endpoint takes its references from the request body. An externalReferences query parameter sent to this endpoint has no effect.

Body property Purpose Predefined Custom
parent.externalReferences Resolves an existing parent activity definition @data-entry-code, @external-reference Supported
externalReferenceIdentifier Identifies the new activity definition; described below @data-entry-code, @external-reference Supported

See the external references page for details.

External reference identifier

externalReferenceIdentifier holds exactly one key-value pair. The key is either a predefined reference (@data-entry-code, @external-reference) or a custom reference name; the value is the identifier the activity definition carries in the external system.

Key type Behaviour
Predefined Duplicate guard only. The value must equal the dataEntryCode (for @data-entry-code) or externalReference (for @external-reference) sent in the same request. Nothing is stored. The duplicate check is scoped to the structure version and level in the URL.
Custom Stored as an external reference on the activity-definitions collection after the activity definition is created. The duplicate check covers the whole activity-definitions collection.

Any key starting with @ is treated as predefined; only @data-entry-code and @external-reference are valid. When an existing activity definition already carries the same reference, the request returns 409 and the activity definition is not created. Omitting the property skips this check.

Success response

Returns 201 Created with a Location header pointing to the new activity definition. The response body is empty.

Error responses

Status code Description
400 Bad request. Validation failed or the external reference is invalid.
400 externalReferenceIdentifier is empty, holds more than one entry, or its predefined value does not match dataEntryCode or externalReference.
400 The key of externalReferenceIdentifier starts with @ but is not @data-entry-code or @external-reference.
400 CannotAssignValidityPeriodOnWorkspaceOrWorkarea — validity dates are not allowed on workspace or work-area levels for Planning Flex tenants.
401 Unauthorized. The bearer token is missing, expired, or invalid.
409 An activity definition with the same external reference identifier already exists.

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. The reference name is supplied inside parent.externalReferences; no externalReferences query parameter is needed on this endpoint:

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

{
  "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 with a custom external reference identifier

The pair is stored for the activity-definitions collection, so the activity definition can afterwards be addressed as ?externalReferences=(activity-definitions,erp-activity-id).

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

{
  "name": {
    "default": "Logistics"
  },
  "shortCode": "LOG",
  "dataEntryCode": "3003",
  "externalReferenceIdentifier": {
    "erp-activity-id": "ERP-4711"
  }
}

Create activity definition with a predefined external reference identifier

The value of @data-entry-code must match the dataEntryCode field. Nothing is stored: the entry only guarantees that no other activity definition on this structure version and level already uses data entry code 3004.

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

{
  "name": {
    "default": "Maintenance"
  },
  "shortCode": "MNT",
  "dataEntryCode": "3004",
  "externalReferenceIdentifier": {
    "@data-entry-code": "3004"
  }
}

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"
}