Knowledge Base Articles
Breadcrumbs

Timesheet approval REST API on Cloud and Servlet API on Data Center

Cloud

Due to security reasons, Servlet API on Cloud is no longer available. Timesheet approvals are associated with a user and a given period, the approval status is not directly linked to individual worklogs.

There is a workaround to get the Timesheet approval status through Export Report .

Or, to get the Timesheet approval status through REST API’s , there are some endpoints needed to get the complete approval info in the script.

There are 2 ways to retrieve approval data - one by team and another by user.

By Team:

To get approval by Team - https://api.tempo.io/4/timesheet-approvals /team/{teamId} with “from” and “to” period parameters: This returns you each team member’s approval details such as period, status, worklogs, etc.

GET https://api.tempo.io/4/timesheet-approvals/team/6?from=2021-06-01&to=2021-06-30
{
    "self": "https://api.tempo.io/4/timesheet-approvals/team/6?from=2021-06-01&to=2021-06-30",
    "metadata": {
        "count": 4
    },
    "results": [
        {
            "self": "https://api.tempo.io/4/timesheet-approvals/user/5a39928628e65137bf83702e?from=2021-06-01&to=2021-06-30",
            "period": {
                "from": "2021-06-01",
                "to": "2021-06-30"
            },
            "requiredSeconds": 576000,
            "timeSpentSeconds": 0,
            "status": {
                "key": "OPEN"
            },
            "user": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=5a39928628e65137bf83702e",
                "accountId": "5a39928628e65137bf83702e",
                "displayName": "Sofie-Anh Duranceau"
            },
            "actions": {
                "submit": {
                    "self": "https://api.tempo.io/4/timesheet-approvals/user/5a39928628e65137bf83702e/submit?from=2021-06-01&to=2021-06-30"
                }
            },
            "worklogs": {
                "self": "https://api.tempo.io/4/worklogs/user/5a39928628e65137bf83702e?from=2021-06-01&to=2021-06-30"
            }
        },
        {
            "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:b2a212da-88e7-4012-a6b8-9874025b63ae?from=2021-06-01&to=2021-06-30",
            "period": {
                "from": "2021-06-01",
                "to": "2021-06-30"
            },
            "requiredSeconds": 576000,
            "timeSpentSeconds": 0,
            "status": {
                "key": "OPEN",
                "comment": "",
                "actor": {
                    "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                    "accountId": "557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                    "displayName": "Tempo Support"
                },
                "requiredSecondsAtSubmit": 576000,
                "timeSpentSecondsAtSubmit": 0,
                "updatedAt": "2021-06-11T14:55:23Z"
            },
            "user": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:b2a212da-88e7-4012-a6b8-9874025b63ae",
                "accountId": "557058:b2a212da-88e7-4012-a6b8-9874025b63ae",
                "displayName": "Taylor"
            },
            "reviewer": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "accountId": "557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "displayName": "Tempo Support"
            },
            "actions": {
                "submit": {
                    "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:b2a212da-88e7-4012-a6b8-9874025b63ae/submit?from=2021-06-01&to=2021-06-30"
                }
            },
            "worklogs": {
                "self": "https://api.tempo.io/4/worklogs/user/557058:b2a212da-88e7-4012-a6b8-9874025b63ae?from=2021-06-01&to=2021-06-30"
            }
        },
        {
            "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:27b3cecc-b58f-4aa7-95d2-85684501993a?from=2021-06-01&to=2021-06-30",
            "period": {
                "from": "2021-06-01",
                "to": "2021-06-30"
            },
            "requiredSeconds": 806400,
            "timeSpentSeconds": 0,
            "status": {
                "key": "OPEN"
            },
            "user": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:27b3cecc-b58f-4aa7-95d2-85684501993a",
                "accountId": "557058:27b3cecc-b58f-4aa7-95d2-85684501993a",
                "displayName": "Helga María Jónsdóttir"
            },
            "actions": {
                "submit": {
                    "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:27b3cecc-b58f-4aa7-95d2-85684501993a/submit?from=2021-06-01&to=2021-06-30"
                }
            },
            "worklogs": {
                "self": "https://api.tempo.io/4/worklogs/user/557058:27b3cecc-b58f-4aa7-95d2-85684501993a?from=2021-06-01&to=2021-06-30"
            }
        },
        {
            "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:cc8b3ba1-1268-446e-87e0-89a0692080fd?from=2021-06-01&to=2021-06-30",
            "period": {
                "from": "2021-06-01",
                "to": "2021-06-30"
            },
            "requiredSeconds": 576000,
            "timeSpentSeconds": 174600,
            "status": {
                "key": "IN_REVIEW",
                "comment": "",
                "actor": {
                    "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                    "accountId": "557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                    "displayName": "Tempo Support"
                },
                "requiredSecondsAtSubmit": 576000,
                "timeSpentSecondsAtSubmit": 138600,
                "updatedAt": "2021-06-11T16:18:43Z"
            },
            "user": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "accountId": "557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "displayName": "Tempo Support"
            },
            "reviewer": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=5d9208b085a58b0dd530bb74",
                "accountId": "5d9208b085a58b0dd530bb74",
                "displayName": "Andrew Ramsay"
            },
            "actions": {
                "approve": {
                    "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:cc8b3ba1-1268-446e-87e0-89a0692080fd/approve?from=2021-06-01&to=2021-06-30"
                },
                "reject": {
                    "self": "https://api.tempo.io/4/timesheet-approvals/user/557058:cc8b3ba1-1268-446e-87e0-89a0692080fd/reject?from=2021-06-01&to=2021-06-30"
                }
            },
            "worklogs": {
                "self": "https://api.tempo.io/4/worklogs/user/557058:cc8b3ba1-1268-446e-87e0-89a0692080fd?from=2021-06-01&to=2021-06-30"
            }
        }
    ]
}


You can get a list of Team Id’s with - https://api.tempo.io/4/teams

GET https://api.tempo.io/4/teams
{
    "self": "https://api.tempo.io/4/teams",
    "metadata": {
        "count": 4
    },
    "results": [
        {
            "self": "https://api.tempo.io/4/teams/6",
            "id": 6,
            "name": "Tempo",
            "summary": "",
            "lead": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "accountId": "557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "displayName": "Tempo Support"
            },
            "program": null,
            "links": {
                "self": "https://api.tempo.io/4/teams/6/links"
            },
            "members": {
                "self": "https://api.tempo.io/4/teams/6/members"
            },
            "permissions": {
                "self": "https://api.tempo.io/4/teams/6/permissions"
            }
        },
        {
            "self": "https://api.tempo.io/4/teams/12",
            "id": 12,
            "name": "BlueJay",
            "summary": "",
            "lead": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "accountId": "557058:cc8b3ba1-1268-446e-87e0-89a0692080fd",
                "displayName": "Tempo Support"
            },
            "program": {
                "self": "https://api.tempo.io/4/programs/7",
                "id": 7,
                "name": "Drinking Contest"
            },
            "links": {
                "self": "https://api.tempo.io/4/teams/12/links"
            },
            "members": {
                "self": "https://api.tempo.io/4/teams/12/members"
            },
            "permissions": {
                "self": "https://api.tempo.io/4/teams/12/permissions"
            }
        },
        {
            "self": "https://api.tempo.io/4/teams/16",
            "id": 16,
            "name": "SWU",
            "summary": "",
            "lead": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=5b198320e249415c02f69600",
                "accountId": "5b198320e249415c02f69600",
                "displayName": "Susan Wu"
            },
            "program": {
                "self": "https://api.tempo.io/4/programs/39",
                "id": 39,
                "name": "Allied World"
            },
            "links": {
                "self": "https://api.tempo.io/4/teams/16/links"
            },
            "members": {
                "self": "https://api.tempo.io/4/teams/16/members"
            },
            "permissions": {
                "self": "https://api.tempo.io/4/teams/16/permissions"
            }
        },
        {
            "self": "https://api.tempo.io/4/teams/27",
            "id": 27,
            "name": "TestSupTeam",
            "summary": "",
            "lead": {
                "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=5b3cc15524f7612e7d4b4743",
                "accountId": "5b3cc15524f7612e7d4b4743",
                "displayName": "Richie Zhu"
            },
            "program": {
                "self": "https://api.tempo.io/4/programs/37",
                "id": 37,
                "name": "skan program"
            },
            "links": {
                "self": "https://api.tempo.io/4/teams/27/links"
            },
            "members": {
                "self": "https://api.tempo.io/4/teams/27/members"
            },
            "permissions": {
                "self": "https://api.tempo.io/4/teams/27/permissions"
            }
        }
    ]


and a list of Periods for the year - https://api.tempo.io/4/periods depending on how you have setup the approval periods (weekly or monthly) in Period Configuration .

GET https://api.tempo.io/4/periods?from=2021-01-01&to=2021-12-31
{
    "periods": [
        {
            "from": "2021-01-01",
            "to": "2021-01-31"
        },
        {
            "from": "2021-02-01",
            "to": "2021-02-28"
        },
        {
            "from": "2021-03-01",
            "to": "2021-03-31"
        },
        {
            "from": "2021-04-01",
            "to": "2021-04-30"
        },
        {
            "from": "2021-05-01",
            "to": "2021-05-31"
        },
        {
            "from": "2021-06-01",
            "to": "2021-06-30"
        },
        {
            "from": "2021-07-01",
            "to": "2021-07-31"
        },
        {
            "from": "2021-08-01",
            "to": "2021-08-31"
        },
        {
            "from": "2021-09-01",
            "to": "2021-09-30"
        },
        {
            "from": "2021-10-01",
            "to": "2021-10-31"
        },
        {
            "from": "2021-11-01",
            "to": "2021-11-30"
        },
        {
            "from": "2021-12-01",
            "to": "2021-12-31"
        }
    ]
}


If there are users who work in multiple teams at the same time, you will get duplicate records for the same users.

By User:

To get approval by User - https://api.tempo.io/4/timesheet-approvals /user/{accountId} with “from” and “to” parameters (see Periods above). You can get a list of user accountId’s from Jira REST API .

GET https://api.tempo.io/4/timesheet-approvals/user/5b198320e249415c02f69600?from=2021-06-01&to=2021-06-30
{
    "self": "https://api.tempo.io/4/timesheet-approvals/user/5b198320e249415c02f69600?from=2021-06-01&to=2021-06-30",
    "period": {
        "from": "2021-06-01",
        "to": "2021-06-30"
    },
    "requiredSeconds": 604800,
    "timeSpentSeconds": 0,
    "status": {
        "key": "OPEN"
    },
    "user": {
        "self": "https://tempo-support-1.atlassian.net/rest/api/2/user?accountId=5b198320e249415c02f69600",
        "accountId": "5b198320e249415c02f69600",
        "displayName": "Susan Wu"
    },
    "actions": {
        "submit": {
            "self": "https://api.tempo.io/4/timesheet-approvals/user/5b198320e249415c02f69600/submit?from=2021-06-01&to=2021-06-30"
        }
    },
    "worklogs": {
        "self": "https://api.tempo.io/4/worklogs/user/5b198320e249415c02f69600?from=2021-06-01&to=2021-06-30"
    }
}


Data Center

With Data Center Servlet API, it’s much easier to get timesheet approval status for worklogs within a selected period in XML, Excel, or test data format, as per our Data Center API documentation . There are more parameters in the documentation to include in the call.

To get approval by Worklogs - http://{datacenter}/plugins/servlet/tempo-getWorklog/ with tempoApiToken, format, addApprovalStatus, dateFrom, dateTo, etc..

GET http://localhost:8080/plugins/servlet/tempo-getWorklog/?format=xml&&dateFrom=2021-06-30&dateTo=2021-06-30&addApprovalStatus=true&tempoApiToken=dc4f634e-b504-4eb6-8c4e-xxxxxxxxxxxx
<worklogs date_from="2021-06-30 00:00:00" date_to="2021-06-30 23:59:59" number_of_worklogs="5" format="xml" diffOnly="false" errorsOnly="false" validOnly="false" addDeletedWorklogs="true" addBillingInfo="false" addIssueSummary="false" addIssueDescription="false" duration_ms="11" headerOnly="false" userName="" addIssueDetails="false" addParentIssue="false" addUserDetails="false" addWorklogDetails="false" billingKey="" issueKey="" projectKey="" addApprovalStatus="true">
<worklog>
<worklog_id>12391</worklog_id>
<jira_worklog_id>12391</jira_worklog_id>
<issue_id>10611</issue_id>
<issue_key>BJT-11</issue_key>
<hours>2.0</hours>
<billed_hours>2.0</billed_hours>
<work_date>2021-06-30</work_date>
<username>lwu</username>
<staff_id>lwu</staff_id>
<billing_key/>
<billing_attributes/>
<activity_id/>
<activity_name/>
<work_description>Officia officiis esse et dicta. Veritatis doloremque maxime quasi laudantium aut beatae. Ut fugit quis.</work_description>
<parent_key/>
<reporter>swu</reporter>
<external_id/>
<external_tstamp/>
<external_hours>0.0</external_hours>
<external_result/>
<customField_10000>{}</customField_10000>
<customField_10100>0|i000sf:</customField_10100>
<hash_value>7a0e5cbdaa7969ab3608cc1f91cadd0712d362ca</hash_value>
<approval_status>open</approval_status>
<timesheet_approval>
<status>open</status>
</timesheet_approval>
</worklog>