German: "Arbeitszeiten"
- Attributes
- GET /users/presences
- GET /users/presences/{id}
- POST /users/presences
- POST /users/presences/touch
- PUT /users/presences/{id}
- DELETE /users/presences/{id}
Presences contain among the standard fields also:
- User (creator)
{
"id": 982237015,
"date": "2018-07-03",
"from": "07:30",
"to": "13:15",
"is_home_office": true,
"user": {
"id": 933590696,
"firstname": "John",
"lastname": "Doe"
},
"created_at": "2018-10-17T09:33:46Z",
"updated_at": "2018-10-17T09:33:46Z"
}
Retrieve all presences:
curl -X GET \
'https://{domain}.mocoapp.com/api/v1/users/presences?from=2018-06-01&to=2018-06-30' \
-H 'Authorization: Token token=YOUR_API_KEY'
This returns an array of all presences.
The following parameters can be supplied:
- from, to – "2018-06-01", "2018-06-30" (from and to have to be provided together)
- user_id – 123
- is_home_office – true/false
Retrieve a single presence:
curl -X GET \
'https://{domain}.mocoapp.com/api/v1/users/presences/{id}' \
-H 'Authorization: Token token=YOUR_API_KEY'
Create a presence:
Every presence is created for the user that the API key belongs to.
curl -X POST \
'https://{domain}.mocoapp.com/api/v1/users/presences' \
-H 'Authorization: Token token=YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"date": "2018-06-11",
"from": "08:00",
"to": "10:00"
}'
Mandatory fields are marked with a star (*):
- date* – "2018-06-11"
- from* – "08:00"
- to – "12:30" (End time, can be left blank)
- is_home_office – true/false (default:
false
, will set the whole day)
This request creates a new presence for the user with the corresponding API-Key starting from the current time or terminates an existing open presence at the current time. Can be used to implement a time clock system (e.g. RFID).
curl -X POST \
'https://{domain}.mocoapp.com/api/v1/users/presences/touch' \
-H 'Authorization: Token token=YOUR_API_KEY'
A first request at 9:30 AM creates a presence with from="09:30"
, a second request at 11:30 AM sets to="11:30"
of the previous presence. Field is_home_office
can be passed to the request as well.
⚠ There are two special situations to take into consideration:
- If a presence is started and stopped by
touch
within the same minute, then it is discarded. - If a
touch
conflicts with an existing presence, then the request is refused and the server response code is423 Locked
.
Update a presence.
curl -X PUT \
'https://{domain}.mocoapp.com/api/v1/users/presences/{id}' \
-H 'Authorization: Token token=YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"to": "14:00"
}'
All fields are analogous to the POST request.
Delete a presence.
curl -X DELETE \
'https://{domain}.mocoapp.com/api/v1/users/presences/{id}' \
-H 'Authorization: Token token=YOUR_API_KEY'