Time Entries

Actions

Link Description Condition
updateImmediately Directly perform edits on this time entry Permission: ‘edit time entries’ or 'edit own time entries if the time entry belongs to the user
delete Delete this time entry Permission: ‘edit time entries’ or 'edit own time entries if the time entry belongs to the user

Linked Properties

Link Description Type Constraints Supported operations Condition
self This time entry TimeEntry not null READ
project The project the time entry is bundled in. The project might be different from the work package’s project once the workPackage is moved. Project not null READ / WRITE
workPackage The work package the time entry is created on WorkPackage not null READ
user The user the time entry tracks expenditures for User not null READ
activity The time entry activity the time entry is categorized as TimeEntriesActivity not null READ

Depending on custom fields defined for time entries, additional links might exist.

Local Properties

Property Description Type Constraints Supported operations Condition
id Time entries’ id Integer x > 0 READ
comment A text provided by the user detailing the time entry String max 255 characters READ
spentOn The date the expenditure is booked for Date READ
hours The time quantifiying the expenditure Time READ
createdAt The time the time entry was created DateTime READ
updatedAt The time the time entry was last updated DateTime READ

Depending on custom fields defined for time entries, additional properties might exist.

Time entry 

View time entry
/api/v3/time_entries/{id}
  • Parameters
  • id
    integer (required) Example: 1

    time entry id

  • Response  200
  • Headers
    Content-Type: application/hal+json
    Body
    {
        "_type": "TimeEntry",
        "id": 1,
        "comment": {
            "format": "plain",
            "raw": "Some text explaining why the time entry was created",
            "html": "<p>Some text explaining why the time entry was created</p>"
        },
        "spentOn": "2015-03-20",
        "hours": "PT5H",
        "createdAt": "2015-03-20T12:56:56Z",
        "updatedAt": "2015-03-20T12:56:56Z",
        "customField12": 5,
        "_embedded": {
            "project": {
              ...
            },
            "workPackage": {
              ...
            },
            "user": {
              ...
            },
            "activity": {
              ...
            }
        },
        "_links": {
            "self": {
                "href": "/api/v3/time_entries/1"
            },
            "updateImmediately": {
                "href": "/api/v3/time_entries/1",
                "method": "patch"
            },
            "delete": {
                "href": "/api/v3/time_entries/1",
                "method": "delete"
            },
            "project": {
                "href": "/api/v3/projects/1",
                "title": "Some project"
            },
            "workPackage": {
                "href": "/api/v3/work_packages/1",
                "title": "Some work package"
            },
            "user": {
                "href": "/api/v3/users/2",
                "title": "Some user"
            },
            "activity": {
                "href": "/api/v3/time_entries/activities/18",
                "title": "Some time entry activity"
            },
            "customField4": {
                "href": "/api/v3/users/5",
                "title" "Some other user"
        }
    }
    
  • Response  404
  • Returned if the time entry does not exist or if the user does not have permission to view them.

    Required permission view time entries in the project the time entry is assigned to

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:NotFound",
      "message": "The requested resource could not be found."
    }
Delete time entry
/api/v3/time_entries/{id}

Permanently deletes the specified time entry.

  • Parameters
  • id
    integer (required) Example: 1

    Time entry id

  • Response  204
  • Returned if the time entry was deleted successfully.

  • Response  403
  • Returned if the client does not have sufficient permissions

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:MissingPermission",
      "message": "You are not authorized to access this resource."
    }
  • Response  404
  • Returned if the time entry does not exist.

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:NotFound",
      "message": "The requested resource could not be found."
    }

Time entries 

List Time entries
/api/v3/time_entries{?offset,pageSize,filters,sortBy}

Lists time entries. The time entries returned depend on the filters provided and also on the permission of the requesting user.

  • Parameters
  • offset
    integer (optional) Default: 1 Example: 25

    Page number inside the requested collection.

    pageSize
    integer (optional) Example: 25

    Number of elements to display per page.

    sortBy
    string (optional) Default: ["spent_on", "asc"] Example: [["spent_on", "asc"]]

    JSON specifying sort criteria. Accepts the same format as returned by the queries endpoint. Currently supported sorts are:

    • id: Sort by primary key

    • hours: Sort by logged hours

    • spent_on: Sort by spent on date

    • created_on: Sort by time entry creation datetime

    filters
    string (optional) Example: [{ "work_package": { "operator": "=", "values": ["1", "2"] } }, { "project": { "operator": "=", "values": ["1"] } }]

    JSON specifying filter conditions. Accepts the same format as returned by the queries endpoint. Currently supported filters are:

    • work_package: Filter time entries by work package

    • project: Filter time entries by project

    • user: Filter time entries by users

    • spent_on: Filter time entries by spent on date

    • created_on: Filter time entries by creation datetime

    • activity: Filter time entries by time entry activity

  • Response  200
  • Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Collection",
      "total": 39,
      "count": 2,
      "pageSize": 2,
      "offset": 1,
      "_embedded": {
        "elements": [
          {
            "_type": "TimeEntry",
            "id": 5,
            "comment": {
              "format": "plain",
              "raw": "Some comment",
              "html": "<p>Some comment</p>"
            },
            "spentOn": "2015-03-20",
            "hours": "PT5H",
            "createdAt": "2015-03-20T12:56:56Z",
            "updatedAt": "2015-03-20T12:56:56Z",
            "_links": {
              "self": {
                "href": "/api/v3/time_entries/1"
              },
              "updateImmediately": {
                "href": "/api/v3/time_entries/1",
                "method": "patch"
              },
              "delete": {
                "href": "/api/v3/time_entries/1",
                "method": "delete"
              },
              "project": {
                "href": "/api/v3/projects/1",
                "title": "Some project"
              },
              "workPackage": {
                "href": "/api/v3/work_packages/1",
                "title": "Some work package"
              },
              "user": {
                "href": "/api/v3/users/2",
                "title": "Some user"
              },
              "activity": {
                "href": "/api/v3/time_entries/activities/18",
                "title": "Some time entry activity"
              }
            }
          },
          {
            "_type": "TimeEntry",
            "id": 10,
            "comment": {
              "format": "plain",
              "raw": "Another comment",
              "html": "<p>Another comment</p>"
            },
            "spentOn": "2015-03-21",
            "hours": "PT7H",
            "createdAt": "2015-03-20T12:56:56Z",
            "updatedAt": "2015-03-20T12:56:56Z",
            "_links": {
              "self": {
                "href": "/api/v3/time_entries/2"
              },
              "project": {
                "href": "/api/v3/projects/42",
                "title": "Some other project"
              },
              "workPackage": {
                "href": "/api/v3/work_packages/541",
                "title": "Some other work package"
              },
              "user": {
                "href": "/api/v3/users/6",
                "title": "Some other project"
              },
              "activity": {
                "href": "/api/v3/time_entries/activities/14",
                "title": "some other time entry activity"
              }
            }
          }
        ]
      },
      "_links": {
        "self": {
          "href": "/api/v3/time_entries?offset=1&pageSize=2"
        },
        "jumpTo": {
          "href": "/api/v3/time_entries?offset=%7Boffset%7D&pageSize=2",
          "templated": true
        },
        "changeSize": {
          "href": "/api/v3/time_entries?offset=1&pageSize=%7Bsize%7D",
          "templated": true
        },
        "nextByOffset": {
          "href": "/api/v3/time_entries?offset=2&pageSize=2"
        }
      }
    }
  • Response  400
  • Returned if the client sends invalid request parameters e.g. filters

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:InvalidQuery",
      "message": [
        "Filters Invalid filter does not exist."
      ]
    }
  • Response  403
  • Returned if the client is not logged in and login is required.

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:MissingPermission",
      "message": "You are not authorized to view this resource."
    }
Create Time entry
/api/v3/time_entries{?offset,pageSize,filters,sortBy}

Creates a new time entry applying the attributes provided in the body. Please note that while there is a fixed set of attributes, custom fields can extend a time entries’ attributes and are accepted by the endpoint.

There is no form and schema resource for time entries, yet.

  • Request  Create time entry
  • Body
    {
        "_links": {
          "project": {
            "href": "/api/v3/projects/34"
          },
          "activity": {
            "href": "/api/v3/time_entries/activities/18",
          },
          "workPackage": {
            "href": "/api/v3/work_packages/5"
          },
          "customField4": {
            "href": "/api/v3/users/5"
          },
          "customField51": {
            "href": "/api/v3/custom_options/11"
          }
        },
        "hours": 'PT5H',
        "comment": {
            "raw": "Some comment",
        },
        "spentOn": "2017-07-28",
        "customField1": {
          raw: 'some text custom field value'
        },
        "customField8": 5
    }
  • Response  201
  • Body
    {
        "_type": "TimeEntry",
        "id": 1,
        "comment": {
            "format": "plain",
            "raw": "Some text explaining why the time entry was created",
            "html": "<p>Some text explaining why the time entry was created</p>"
        },
        "spentOn": "2015-03-20",
        "hours": "PT5H",
        "createdAt": "2015-03-20T12:56:56Z",
        "updatedAt": "2015-03-20T12:56:56Z",
        "customField12": 5,
        "_embedded": {
            "project": {
              ...
            },
            "workPackage": {
              ...
            },
            "user": {
              ...
            },
            "activity": {
              ...
            }
        },
        "_links": {
            "self": {
                "href": "/api/v3/time_entries/1"
            },
            "updateImmediately": {
                "href": "/api/v3/time_entries/1",
                "method": "patch"
            },
            "delete": {
                "href": "/api/v3/time_entries/1",
                "method": "delete"
            },
            "project": {
                "href": "/api/v3/projects/1",
                "title": "Some project"
            },
            "workPackage": {
                "href": "/api/v3/work_packages/1",
                "title": "Some work package"
            },
            "user": {
                "href": "/api/v3/users/2",
                "title": "Some user"
            },
            "activity": {
                "href": "/api/v3/time_entries/activities/18",
                "title": "Some time entry activity"
            },
            "customField4": {
                "href": "/api/v3/users/5",
                "title" "Some other user"
        }
    }
    
  • Response  400
  • Occurs when the client did not send a valid JSON object in the request body.

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:InvalidRequestBody",
      "message": "The request body was not a single JSON object."
    }
  • Response  403
  • Returned if the client does not have sufficient permissions.

    Required permission: Log time

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:MissingPermission",
      "message": "You are not authorized to access this resource."
    }
  • Response  422
  • Returned if:

    • a constraint for a property was violated (PropertyConstraintViolation)
    Headers
    Content-Type: application/hal+json
    Body
    {
        "_type": "Error",
        "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",
        "message": "Work package is invalid.",
        "_embedded": {
            "details": {
                "attribute"=>"workPackage"
            }
        }
    }
Update Time entry
/api/v3/time_entries{?offset,pageSize,filters,sortBy}

Updates the given time entry by applying the attributes provided in the body. Please note that while there is a fixed set of attributes, custom fields can extend a time entries’ attributes and are accepted by the endpoint.

There is no form and schema resource for time entries, yet.

  • Request  Update time entry
  • Body
    {
        "_links": {
          "activity": {
            "href": "/api/v3/time_entries/activities/18",
          },
          "workPackage": {
            "href": "/api/v3/work_packages/5"
          },
          "customField4": {
            "href": "/api/v3/users/5"
          },
          "customField51": {
            "href": "/api/v3/custom_options/11"
          }
        },
        "hours": 'PT5H',
        "comment": {
          "raw": "Some comment",
        },
        "spentOn": "2017-07-28",
        "customField1": {
          raw: 'some text custom field value'
        },
        "customField8": 5
    }
  • Response  200
  • Body
    {
        "_type": "TimeEntry",
        "id": 1,
        "comment": {
            "format": "plain",
            "raw": "Some text explaining why the time entry was created",
            "html": "<p>Some text explaining why the time entry was created</p>"
        },
        "spentOn": "2015-03-20",
        "hours": "PT5H",
        "createdAt": "2015-03-20T12:56:56Z",
        "updatedAt": "2015-03-20T12:56:56Z",
        "customField12": 5,
        "_embedded": {
            "project": {
              ...
            },
            "workPackage": {
              ...
            },
            "user": {
              ...
            },
            "activity": {
              ...
            }
        },
        "_links": {
            "self": {
                "href": "/api/v3/time_entries/1"
            },
            "updateImmediately": {
                "href": "/api/v3/time_entries/1",
                "method": "patch"
            },
            "delete": {
                "href": "/api/v3/time_entries/1",
                "method": "delete"
            },
            "project": {
                "href": "/api/v3/projects/1",
                "title": "Some project"
            },
            "workPackage": {
                "href": "/api/v3/work_packages/1",
                "title": "Some work package"
            },
            "user": {
                "href": "/api/v3/users/2",
                "title": "Some user"
            },
            "activity": {
                "href": "/api/v3/time_entries/activities/18",
                "title": "Some time entry activity"
            },
            "customField4": {
                "href": "/api/v3/users/5",
                "title" "Some other user"
        }
    }
    
  • Response  400
  • Occurs when the client did not send a valid JSON object in the request body.

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:InvalidRequestBody",
      "message": "The request body was not a single JSON object."
    }
  • Response  403
  • Returned if the client does not have sufficient permissions.

    Required permission: Edit (own) time entries, depending on what time entry is being modified.

    Headers
    Content-Type: application/hal+json
    Body
    {
      "_type": "Error",
      "errorIdentifier": "urn:openproject-org:api:v3:errors:MissingPermission",
      "message": "You are not authorized to access this resource."
    }
  • Response  422
  • Returned if:

    • a constraint for a property was violated (PropertyConstraintViolation)
    Headers
    Content-Type: application/hal+json
    Body
    {
        "_type": "Error",
        "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",
        "message": "Work package is invalid.",
        "_embedded": {
            "details": {
                "attribute"=>"workPackage"
            }
        }
    }