curl --request PUT \
--url https://{host}/timmi-timesheet/services/time-entries \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
[
{
"owner": {
"id": 123
},
"startsAt": "2024-05-06T00:00:00",
"duration": {
"iso": "PT4H"
},
"comment": null,
"timeSource": "manual",
"unit": "duration",
"timeType": null,
"axisSections": [
{
"id": 41
},
{
"id": 127
},
{
"id": 285
},
{
"id": 319
}
]
},
{
"owner": {
"id": 123
},
"startsAt": "2024-05-06T00:00:00",
"duration": {
"iso": "PT2H"
},
"comment": null,
"timeSource": "manual",
"unit": "duration",
"timeType": null,
"axisSections": [
{
"id": 41
},
{
"id": 290
},
{
"id": 309
},
{
"id": 311
}
]
},
{
"owner": {
"id": 123
},
"startsAt": "2024-05-07T00:00:00",
"duration": {
"iso": "PT7H20M"
},
"comment": "This is a comment",
"timeSource": "manual",
"unit": "duration",
"timeType": null,
"axisSections": [
{
"id": 41
},
{
"id": 127
},
{
"id": 285
},
{
"id": 319
}
]
}
]
'import requests
url = "https://{host}/timmi-timesheet/services/time-entries"
payload = [
{
"owner": { "id": 123 },
"startsAt": "2024-05-06T00:00:00",
"duration": { "iso": "PT4H" },
"comment": None,
"timeSource": "manual",
"unit": "duration",
"timeType": None,
"axisSections": [{ "id": 41 }, { "id": 127 }, { "id": 285 }, { "id": 319 }]
},
{
"owner": { "id": 123 },
"startsAt": "2024-05-06T00:00:00",
"duration": { "iso": "PT2H" },
"comment": None,
"timeSource": "manual",
"unit": "duration",
"timeType": None,
"axisSections": [{ "id": 41 }, { "id": 290 }, { "id": 309 }, { "id": 311 }]
},
{
"owner": { "id": 123 },
"startsAt": "2024-05-07T00:00:00",
"duration": { "iso": "PT7H20M" },
"comment": "This is a comment",
"timeSource": "manual",
"unit": "duration",
"timeType": None,
"axisSections": [{ "id": 41 }, { "id": 127 }, { "id": 285 }, { "id": 319 }]
}
]
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
owner: {id: 123},
startsAt: '2024-05-06T00:00:00',
duration: {iso: 'PT4H'},
comment: null,
timeSource: 'manual',
unit: 'duration',
timeType: null,
axisSections: [{id: 41}, {id: 127}, {id: 285}, {id: 319}]
},
{
owner: {id: 123},
startsAt: '2024-05-06T00:00:00',
duration: {iso: 'PT2H'},
comment: null,
timeSource: 'manual',
unit: 'duration',
timeType: null,
axisSections: [{id: 41}, {id: 290}, {id: 309}, {id: 311}]
},
{
owner: {id: 123},
startsAt: '2024-05-07T00:00:00',
duration: {iso: 'PT7H20M'},
comment: 'This is a comment',
timeSource: 'manual',
unit: 'duration',
timeType: null,
axisSections: [{id: 41}, {id: 127}, {id: 285}, {id: 319}]
}
])
};
fetch('https://{host}/timmi-timesheet/services/time-entries', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/timmi-timesheet/services/time-entries",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
[
'owner' => [
'id' => 123
],
'startsAt' => '2024-05-06T00:00:00',
'duration' => [
'iso' => 'PT4H'
],
'comment' => null,
'timeSource' => 'manual',
'unit' => 'duration',
'timeType' => null,
'axisSections' => [
[
'id' => 41
],
[
'id' => 127
],
[
'id' => 285
],
[
'id' => 319
]
]
],
[
'owner' => [
'id' => 123
],
'startsAt' => '2024-05-06T00:00:00',
'duration' => [
'iso' => 'PT2H'
],
'comment' => null,
'timeSource' => 'manual',
'unit' => 'duration',
'timeType' => null,
'axisSections' => [
[
'id' => 41
],
[
'id' => 290
],
[
'id' => 309
],
[
'id' => 311
]
]
],
[
'owner' => [
'id' => 123
],
'startsAt' => '2024-05-07T00:00:00',
'duration' => [
'iso' => 'PT7H20M'
],
'comment' => 'This is a comment',
'timeSource' => 'manual',
'unit' => 'duration',
'timeType' => null,
'axisSections' => [
[
'id' => 41
],
[
'id' => 127
],
[
'id' => 285
],
[
'id' => 319
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/timmi-timesheet/services/time-entries"
payload := strings.NewReader("[\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT4H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT2H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 290\n },\n {\n \"id\": 309\n },\n {\n \"id\": 311\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-07T00:00:00\",\n \"duration\": {\n \"iso\": \"PT7H20M\"\n },\n \"comment\": \"This is a comment\",\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n }\n]")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://{host}/timmi-timesheet/services/time-entries")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("[\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT4H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT2H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 290\n },\n {\n \"id\": 309\n },\n {\n \"id\": 311\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-07T00:00:00\",\n \"duration\": {\n \"iso\": \"PT7H20M\"\n },\n \"comment\": \"This is a comment\",\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/timmi-timesheet/services/time-entries")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT4H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT2H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 290\n },\n {\n \"id\": 309\n },\n {\n \"id\": 311\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-07T00:00:00\",\n \"duration\": {\n \"iso\": \"PT7H20M\"\n },\n \"comment\": \"This is a comment\",\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"$[0]": [
"You cannot create a time entry that spans over two days."
],
"$[0].AxisSections": [
"AxisSections must all be active and consistent with the tree structure of their sections"
],
"$[2]": [
"You cannot create a time entry with a duration that exceeds 24h."
]
}
}TimeEntries update service
Before using this service
This service is aimed at updating a given user TimeEntries easily, as it automatically detects and applies changes needed to transform whatever TimeEntries might currently exist to what you send it. It create, edit, or delete TimeEntries. An algorithm tries to match and update any existing TimeEntries, but it might wipe clean TimeEntries before adding new ones.
There are different ways to update TimeEntries. Please see this guide for a guide on how to update TimeEntries the right way depending on your use case.
How to use
It will create, edit, or delete existing TimeEntries for a given period and owner to match the TimeEntries of the request body.
The request body is an array of ‘simplified’ TimeEntries, please see the API reference for a TimeEntry model for additional information and main validation rules.
Here the TimeEntry id field is optional as the matching algorithm does not take it into account.
curl --request PUT \
--url https://{host}/timmi-timesheet/services/time-entries \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
[
{
"owner": {
"id": 123
},
"startsAt": "2024-05-06T00:00:00",
"duration": {
"iso": "PT4H"
},
"comment": null,
"timeSource": "manual",
"unit": "duration",
"timeType": null,
"axisSections": [
{
"id": 41
},
{
"id": 127
},
{
"id": 285
},
{
"id": 319
}
]
},
{
"owner": {
"id": 123
},
"startsAt": "2024-05-06T00:00:00",
"duration": {
"iso": "PT2H"
},
"comment": null,
"timeSource": "manual",
"unit": "duration",
"timeType": null,
"axisSections": [
{
"id": 41
},
{
"id": 290
},
{
"id": 309
},
{
"id": 311
}
]
},
{
"owner": {
"id": 123
},
"startsAt": "2024-05-07T00:00:00",
"duration": {
"iso": "PT7H20M"
},
"comment": "This is a comment",
"timeSource": "manual",
"unit": "duration",
"timeType": null,
"axisSections": [
{
"id": 41
},
{
"id": 127
},
{
"id": 285
},
{
"id": 319
}
]
}
]
'import requests
url = "https://{host}/timmi-timesheet/services/time-entries"
payload = [
{
"owner": { "id": 123 },
"startsAt": "2024-05-06T00:00:00",
"duration": { "iso": "PT4H" },
"comment": None,
"timeSource": "manual",
"unit": "duration",
"timeType": None,
"axisSections": [{ "id": 41 }, { "id": 127 }, { "id": 285 }, { "id": 319 }]
},
{
"owner": { "id": 123 },
"startsAt": "2024-05-06T00:00:00",
"duration": { "iso": "PT2H" },
"comment": None,
"timeSource": "manual",
"unit": "duration",
"timeType": None,
"axisSections": [{ "id": 41 }, { "id": 290 }, { "id": 309 }, { "id": 311 }]
},
{
"owner": { "id": 123 },
"startsAt": "2024-05-07T00:00:00",
"duration": { "iso": "PT7H20M" },
"comment": "This is a comment",
"timeSource": "manual",
"unit": "duration",
"timeType": None,
"axisSections": [{ "id": 41 }, { "id": 127 }, { "id": 285 }, { "id": 319 }]
}
]
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
owner: {id: 123},
startsAt: '2024-05-06T00:00:00',
duration: {iso: 'PT4H'},
comment: null,
timeSource: 'manual',
unit: 'duration',
timeType: null,
axisSections: [{id: 41}, {id: 127}, {id: 285}, {id: 319}]
},
{
owner: {id: 123},
startsAt: '2024-05-06T00:00:00',
duration: {iso: 'PT2H'},
comment: null,
timeSource: 'manual',
unit: 'duration',
timeType: null,
axisSections: [{id: 41}, {id: 290}, {id: 309}, {id: 311}]
},
{
owner: {id: 123},
startsAt: '2024-05-07T00:00:00',
duration: {iso: 'PT7H20M'},
comment: 'This is a comment',
timeSource: 'manual',
unit: 'duration',
timeType: null,
axisSections: [{id: 41}, {id: 127}, {id: 285}, {id: 319}]
}
])
};
fetch('https://{host}/timmi-timesheet/services/time-entries', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/timmi-timesheet/services/time-entries",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
[
'owner' => [
'id' => 123
],
'startsAt' => '2024-05-06T00:00:00',
'duration' => [
'iso' => 'PT4H'
],
'comment' => null,
'timeSource' => 'manual',
'unit' => 'duration',
'timeType' => null,
'axisSections' => [
[
'id' => 41
],
[
'id' => 127
],
[
'id' => 285
],
[
'id' => 319
]
]
],
[
'owner' => [
'id' => 123
],
'startsAt' => '2024-05-06T00:00:00',
'duration' => [
'iso' => 'PT2H'
],
'comment' => null,
'timeSource' => 'manual',
'unit' => 'duration',
'timeType' => null,
'axisSections' => [
[
'id' => 41
],
[
'id' => 290
],
[
'id' => 309
],
[
'id' => 311
]
]
],
[
'owner' => [
'id' => 123
],
'startsAt' => '2024-05-07T00:00:00',
'duration' => [
'iso' => 'PT7H20M'
],
'comment' => 'This is a comment',
'timeSource' => 'manual',
'unit' => 'duration',
'timeType' => null,
'axisSections' => [
[
'id' => 41
],
[
'id' => 127
],
[
'id' => 285
],
[
'id' => 319
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/timmi-timesheet/services/time-entries"
payload := strings.NewReader("[\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT4H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT2H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 290\n },\n {\n \"id\": 309\n },\n {\n \"id\": 311\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-07T00:00:00\",\n \"duration\": {\n \"iso\": \"PT7H20M\"\n },\n \"comment\": \"This is a comment\",\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n }\n]")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://{host}/timmi-timesheet/services/time-entries")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("[\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT4H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT2H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 290\n },\n {\n \"id\": 309\n },\n {\n \"id\": 311\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-07T00:00:00\",\n \"duration\": {\n \"iso\": \"PT7H20M\"\n },\n \"comment\": \"This is a comment\",\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/timmi-timesheet/services/time-entries")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT4H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-06T00:00:00\",\n \"duration\": {\n \"iso\": \"PT2H\"\n },\n \"comment\": null,\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 290\n },\n {\n \"id\": 309\n },\n {\n \"id\": 311\n }\n ]\n },\n {\n \"owner\": {\n \"id\": 123\n },\n \"startsAt\": \"2024-05-07T00:00:00\",\n \"duration\": {\n \"iso\": \"PT7H20M\"\n },\n \"comment\": \"This is a comment\",\n \"timeSource\": \"manual\",\n \"unit\": \"duration\",\n \"timeType\": null,\n \"axisSections\": [\n {\n \"id\": 41\n },\n {\n \"id\": 127\n },\n {\n \"id\": 285\n },\n {\n \"id\": 319\n }\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"$[0]": [
"You cannot create a time entry that spans over two days."
],
"$[0].AxisSections": [
"AxisSections must all be active and consistent with the tree structure of their sections"
],
"$[2]": [
"You cannot create a time entry with a duration that exceeds 24h."
]
}
}Headers
Query Parameters
Body
Attribute used to identify last modification source :
- manual : Manually created or edited (default).
- import : Imported from external sources. Is read-only on Lucca Timesheet user interfaces only if Timesheet regulation is in following modes : attendance schedule with clock-in clock-out, and activity-schedule
- timer : Entered with Lucca Timesheet clock-in clock-out tool.
manual, import, timer Response
OK
Was this page helpful?