Create a day off. Send the fields of the new row in JSON. An administrator can create a day off for all persons. Other users can create a day off for themselves only. The day off must not overlap another day off of the person. The time spent of the person on the days of the day off is deleted.
POST
/data/day-offs
curl
curl -X POST "http://api.example.com/data/day-offs/" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"date": "2024-01-15",
"end_date": "2024-01-20",
"person_id": "a24a6ea4-ce75-4665-a070-57453082c25"
}'
import requests
url = "http://api.example.com/data/day-offs/"
headers = {
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
"Content-Type": "application/json"
}
params = {}
payload = {
"date": "2024-01-15",
"end_date": "2024-01-20",
"person_id": "a24a6ea4-ce75-4665-a070-57453082c25"
}
response = requests.post(
url,
headers=headers,
params=params,
json=payload
)
response.raise_for_status()
if response.content:
print(response.json())
Request examples
{
"date": "2024-01-15",
"end_date": "2024-01-20",
"person_id": "a24a6ea4-ce75-4665-a070-57453082c250"
}
Response examples (201)
{
"id": "a24a6ea4-ce75-4665-a070-57453082c250",
"date": "2024-01-15",
"end_date": "2024-01-20",
"person_id": "b24a6ea4-ce75-4665-a070-57453082c250",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}