Update Employee
const options = {
method: 'PATCH',
headers: {
'x-api-key': '<x-api-key>',
'x-organization-id': '<x-organization-id>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', email: '<string>', situation: '<string>', status: '<string>'})
};
fetch('https://api.dcycle.io/v1/employees/{employee_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/employees/{employee_id}"
payload = {
"name": "<string>",
"email": "<string>",
"situation": "<string>",
"status": "<string>"
}
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)curl --request PATCH \
--url https://api.dcycle.io/v1/employees/{employee_id} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"name": "<string>",
"email": "<string>",
"situation": "<string>",
"status": "<string>"
}
'{
"id": "<string>",
"name": {},
"email": {},
"organization_id": "<string>",
"situation": {},
"status": "<string>",
"periods": {},
"created_at": {},
"updated_at": {}
}Update Employee
Modify an existing employee’s details
PATCH
/
v1
/
employees
/
{employee_id}
Update Employee
const options = {
method: 'PATCH',
headers: {
'x-api-key': '<x-api-key>',
'x-organization-id': '<x-organization-id>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', email: '<string>', situation: '<string>', status: '<string>'})
};
fetch('https://api.dcycle.io/v1/employees/{employee_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/employees/{employee_id}"
payload = {
"name": "<string>",
"email": "<string>",
"situation": "<string>",
"status": "<string>"
}
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)curl --request PATCH \
--url https://api.dcycle.io/v1/employees/{employee_id} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"name": "<string>",
"email": "<string>",
"situation": "<string>",
"status": "<string>"
}
'{
"id": "<string>",
"name": {},
"email": {},
"organization_id": "<string>",
"situation": {},
"status": "<string>",
"periods": {},
"created_at": {},
"updated_at": {}
}Update Employee
Update an existing employee’s information. You can modify any combination of the employee’s fields.Partial Updates: Only include the fields you want to update. Fields not included in the request body will remain unchanged.
Request
Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
a8315ef3-dd50-43f8-b7ce-d839e68d51faPath Parameters
string
required
The unique identifier (UUID) of the employee to updateExample:
550e8400-e29b-41d4-a716-446655440000Body Parameters
string
Employee’s full name (1-255 characters)Example:
"John Smith Jr."string
Employee’s email addressExample:
"john.smith.new@company.com"string
Employment situationAvailable values:
active, inactive, terminatedExample: "inactive"string
Data collection statusAvailable values:
uploaded, loadingExample: "uploaded"Response
string
Unique identifier (UUID)
string | null
Employee’s full name
string | null
Employee’s email address
string
Organization UUID
string | null
Employment status:
active, inactive, or terminatedstring
Data status:
uploaded or loadingarray | null
List of commuting periods
datetime
Timestamp when the employee was created
datetime | null
Timestamp when the employee was last updated
Example
curl -X PATCH "https://api.dcycle.io/v1/employees/550e8400-e29b-41d4-a716-446655440000" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d '{
"situation": "inactive"
}'
import requests
import os
api_key = os.getenv("DCYCLE_API_KEY")
org_id = os.getenv("DCYCLE_ORG_ID")
employee_id = "550e8400-e29b-41d4-a716-446655440000"
headers = {
"x-api-key": api_key,
"x-organization-id": org_id,
"Content-Type": "application/json"
}
# Only include fields to update
payload = {
"situation": "inactive"
}
response = requests.patch(
f"https://api.dcycle.io/v1/employees/{employee_id}",
headers=headers,
json=payload
)
employee = response.json()
print(f"Updated: {employee['name']}")
print(f"New situation: {employee['situation']}")
const axios = require('axios');
const apiKey = process.env.DCYCLE_API_KEY;
const orgId = process.env.DCYCLE_ORG_ID;
const employeeId = '550e8400-e29b-41d4-a716-446655440000';
const headers = {
'x-api-key': apiKey,
'x-organization-id': orgId,
'Content-Type': 'application/json'
};
// Only include fields to update
const payload = {
situation: 'inactive'
};
axios.patch(
`https://api.dcycle.io/v1/employees/${employeeId}`,
payload,
{ headers }
)
.then(response => {
const employee = response.data;
console.log(`Updated: ${employee.name}`);
console.log(`New situation: ${employee.situation}`);
})
.catch(error => console.error(error));
Successful Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "John Smith",
"email": "john.smith@company.com",
"organization_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
"situation": "inactive",
"status": "uploaded",
"periods": [...],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-11-24T14:45:00Z"
}
Common Errors
401 Unauthorized
Cause: Missing or invalid API key{
"detail": "Invalid API key",
"code": "INVALID_API_KEY"
}
404 Not Found
Cause: Employee not found or doesn’t belong to your organization{
"code": "EMPLOYEE_NOT_FOUND",
"detail": "Employee with id=UUID('...') not found"
}
422 Validation Error
Cause: Invalid field values or extra fields{
"detail": [
{
"loc": ["body", "situation"],
"msg": "value is not a valid enumeration member",
"type": "type_error.enum"
}
]
}
situation and status.
Use Cases
Update Employee Situation
Change an employee’s employment status:def update_employee_situation(employee_id, new_situation):
"""Update employee's employment situation"""
response = requests.patch(
f"https://api.dcycle.io/v1/employees/{employee_id}",
headers=headers,
json={"situation": new_situation}
)
return response.json()
# Mark employee as terminated
employee = update_employee_situation(
"550e8400-e29b-41d4-a716-446655440000",
"terminated"
)
print(f"{employee['name']} is now {employee['situation']}")
Update Employee Email
Change an employee’s email address:def update_employee_email(employee_id, new_email):
"""Update employee's email address"""
response = requests.patch(
f"https://api.dcycle.io/v1/employees/{employee_id}",
headers=headers,
json={"email": new_email}
)
return response.json()
employee = update_employee_email(
"550e8400-e29b-41d4-a716-446655440000",
"john.smith.new@company.com"
)
print(f"Email updated to: {employee['email']}")
Update Multiple Fields
Update several fields at once:def update_employee(employee_id, updates):
"""Update employee with multiple fields"""
response = requests.patch(
f"https://api.dcycle.io/v1/employees/{employee_id}",
headers=headers,
json=updates
)
return response.json()
employee = update_employee(
"550e8400-e29b-41d4-a716-446655440000",
{
"name": "John Smith Jr.",
"email": "john.jr@company.com",
"situation": "active"
}
)
print(f"Updated: {employee['name']} ({employee['email']})")
Mark Employee as Terminated
Handle employee offboarding:def offboard_employee(employee_id):
"""Mark employee as terminated during offboarding"""
response = requests.patch(
f"https://api.dcycle.io/v1/employees/{employee_id}",
headers=headers,
json={
"situation": "terminated",
"status": "uploaded"
}
)
return response.json()
# Offboard employee
employee = offboard_employee("550e8400-e29b-41d4-a716-446655440000")
print(f"{employee['name']} has been offboarded")
Bulk Update Employees
Update multiple employees’ status:def bulk_update_situation(employee_ids, new_situation):
"""Update situation for multiple employees"""
results = {"success": [], "failed": []}
for emp_id in employee_ids:
try:
response = requests.patch(
f"https://api.dcycle.io/v1/employees/{emp_id}",
headers=headers,
json={"situation": new_situation}
)
if response.status_code == 200:
results["success"].append(emp_id)
else:
results["failed"].append({"id": emp_id, "error": response.text})
except Exception as e:
results["failed"].append({"id": emp_id, "error": str(e)})
return results
# Mark employees as inactive
employee_ids = [
"550e8400-e29b-41d4-a716-446655440000",
"550e8400-e29b-41d4-a716-446655440001",
"550e8400-e29b-41d4-a716-446655440002"
]
results = bulk_update_situation(employee_ids, "inactive")
print(f"Updated: {len(results['success'])}")
print(f"Failed: {len(results['failed'])}")
Related Endpoints
Get Employee
View employee details
Delete Employee
Remove an employee
List Employees
View all employees
Update Commuting Period
Modify commuting data
Was this page helpful?