8. Downloading Timesheets via API

Download a Timesheet over API


API Documentation: Timesheet CSV Generation

Endpoint URL POST app.go2clock.com/api/timesheet_csv_v1

Description

Generates and downloads a timesheet CSV file for specified employees and date ranges.

Note the 'csv_vX' denotes the version number of the report and may change as different future versions are released.

Request Details

Headers

•Authorization: Required. API key for authentication.

•Content-Type: Required. Supports:

•application/json

•application/x-www-form-urlencoded

Request Body

JSON Format (if Content-Type is application/json)

{
"start_date": "YYYY-MM-DD", // Required. Start date for the timesheet.
"nodays": 7, // Required. Number of days to include in the report.
"dept": "Department Name", // Optional. Filter by department (default: "All Depts").
"userid": "Employee ID" // Optional. Filter by employee ID (default: "All Employees").
}

Form-Encoded Format (if Content-Type is application x-www-form-urlencoded)

Parameter. - Type, Description

start_date  - String, Required. Start date for the timesheet (YYYY-MM-DD).

nodays  - Integer, Required. Number of days to include in the report (Maximum 7 days).

dept  - String, Optional. Department filter (default: All Depts).

userid  - String, Optional. Employee filter (default: All Employees).


Important Notes: Timesheets may take a long time to produce and will require large amounts of server time. To make the download quick you should limit the number of days you are requesting and/or select just one department.


Response

Success (HTTP 200)

CSV file is returned as a downloadable attachment. Headers include:

•Content-Type: text/csv

•Content-Disposition: attachment; filename="timesheet_report.csv"


Failure Responses (Examples)

Unauthorized Access (HTTP 401)

{
"status": "failure",
"message": "",
"error": "EVAC only subscriptions are not authorised to access this resource, please upgrade your subscription."
}

Validation Error (HTTP 400)

{
"status": "failure",
"message": "",
"error": ""
}

No Data Found (HTTP 404)

{
"status": "failure",
"message": "",
"error": "No user data found."
}

Example Usage


cURL Example (JSON)

curl -X POST https://app.go2clock.com/api/timesheet_csv_v1 \
-H 'APIKEY: xxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"start_date": "2023-01-01",
"nodays": 7,
"dept": "HR",
"userid": "12345"
}'

cURL Example (Form-Encoded)

curl -X POST https://app.go2clock.com/api/timesheet_csv_v1 \
-H 'APIKEY: xxxxxxxxxxxxxxxx' \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "start_date=2023-01-01&nodays=7&dept=HR&userid=12345"

cURL Example with Output to CSV File

curl -X POST https://yourdomain.com/api/timesheet_csv_v1 \
-H 'APIKEY: xxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"start_date": "2023-01-01",
"nodays": 7,
"dept": "HR",
"userid": "12345"
}' -o timesheet_report.csv

Explanation

•-X POST: Specifies the HTTP method.

•-H: Sets the request headers.

•-d: Provides the request body as JSON data.

•-o timesheet_report.csv: Saves the API response to a file named timesheet_report.csv in the current directory.

After running this command, the downloaded timesheet_report.csv file will contain the timesheet data generated by the API.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us