Using REST API To Create And Approve Timesheets And Timesheet Entries
search cancel

Using REST API To Create And Approve Timesheets And Timesheet Entries

book

Article ID: 388005

calendar_today

Updated On: 02-12-2025

Products

Clarity PPM SaaS Clarity PPM On Premise

Issue/Introduction

Is there a way to automatically create timesheets and timesheet entries with REST API?

What are the general steps to get started?

Environment

Clarity 16.3.0

Resolution

Given the following representations, (replace with actual id)

5pppppp=the timeperiod
5rrrrrr=the resource id 
5tsssss=the timesheet id
5teeeee= timesheet entry id
5aaaaaa=the task id
5bbbbbb=the input type code
5cccccc=the charge code


1. Obtain the timeperiod

GET /ppm/rest/v1/timePeriods
GET /ppm/rest/v1/timePeriods/5pppppp

2. Obtain the timesheets

GET /ppm/rest/v1/timesheets
GET /ppm/rest/v1/timesheets/5tsssss

3. Obtain the timeentries associated with the timesheet

GET /ppm/rest/v1/timesheets/5tsssss/timeEntries
GET /ppm/rest/v1/timesheets/5tsssss/timeEntries/5teeeee

4. Create the timesheet.

POST /ppm/rest/v1/timesheets
{
    "status": "0",
    "timePeriodId": 5pppppp,
    "resourceId" : 5rrrrrr
}

5. Create the timesheet entries.

If the time entry does not yet exist, use:

POST ppm/rest/v1/timesheets/5tsssss/timeEntries

This will create the timesheet entry.

{
    "actuals": {
        "_type": "tsv",
        "curveType": "value",
        "dataType": "numeric",
        "finish": "2024-12-07T00:00:00",
        "isFiscal": false,
        "segmentList": {
            "defaultValue": 0,
            "segments": [
                {
                    "finish": "2024-12-01T00:00:00",
                    "start": "2024-12-01T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-02T00:00:00",
                    "start": "2024-12-02T00:00:00",
                    "value": 3600
                },
                {
                    "finish": "2024-12-03T00:00:00",
                    "start": "2024-12-03T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-04T00:00:00",
                    "start": "2024-12-04T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-05T00:00:00",
                    "start": "2024-12-05T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-06T00:00:00",
                    "start": "2024-12-06T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-07T00:00:00",
                    "start": "2024-12-07T00:00:00",
                    "value": 0
                }
            ],
            "total": 0
        },
        "start": "2024-12-01T00:00:00"
    },
    "taskId": 5xxxxxx
}

If the time entry does exist, update it using:

PATCH  /ppm/rest/v1/timesheets/5tsssss/timeEntries/5teeeee
{
    "taskId" : 5aaaaaa,
    "inputTypeCode":5bbbbbb,
    "chargeCode" :5cccccc,
    "actuals": {
        "segmentList": {
            "defaultValue": 0,
            "segments": [
                {
                    "finish": "2024-12-01T00:00:00",
                    "start": "2024-12-01T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-02T00:00:00",
                    "start": "2024-12-02T00:00:00",
                    "value": 3600
                },
                {
                    "finish": "2024-12-03T00:00:00",
                    "start": "2024-12-03T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-04T00:00:00",
                    "start": "2024-12-04T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-05T00:00:00",
                    "start": "2024-12-05T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-06T00:00:00",
                    "start": "2024-12-06T00:00:00",
                    "value": 0
                },
                {
                    "finish": "2024-12-07T00:00:00",
                    "start": "2024-12-07T00:00:00",
                    "value": 0
                }
            ]
        }
    }
}

6. For setting the timesheet status:

PATCH  /ppm/rest/v1/timesheets/5tsssss

  {
    //"status": "1" //submit
    //"status": "2" //returned
    "status": "3" //approve
  }

NOTE: If a timesheet process is being used, the status will not be set to returned/approved