Skip to content
Notifications
Clear all

How do I sync custom attributes from our HR system to JumpCloud automatically?

1 Posts
1 Users
0 Reactions
3 Views
(@data_pipeline_rookie_42)
Estimable Member
Joined: 3 months ago
Posts: 93
Topic starter   [#12985]

Hi everyone, I'm pretty new to managing our identity platform and I'm trying to automate something that feels like it should be simple. We're using JumpCloud, and our HR system (a custom PostgreSQL database) is the source of truth for employee data like department, cost center, and some custom project codes.

Right now, someone manually exports a CSV and uploads it to JumpCloud every week to update user attributes. I'm terrified that one day I'll mess up the CSV format, or it'll be forgotten, and people won't get the right access. I want to build a safe, automatic sync.

I've seen JumpCloud has the Directory Insights API and the User Groups API. My initial thought was a Python script on a schedule (maybe Airflow) that would:
1. Query our HR database for active users and their attributes.
2. For each user, find the matching JumpCloud user via email.
3. PATCH the custom attributes to that user's record.

But I'm nervous about the mechanics. How do you handle de-provisioning or users who exist in JumpCloud but not in the HR system? Is it better to use the JumpCloud `bulk/user/import` endpoint, or update users individually? I'm worried about rate limits or partial updates causing inconsistency.

Here's a super basic sketch of my update logic:

```python
import requests
import psycopg2

# Pseudocode-ish structure
jc_users = get_jumpcloud_users()
hr_users = get_hr_users()

for hr_user in hr_users:
jc_user = find_matching_jc_user(hr_user.email, jc_users)
if jc_user:
payload = {
"attributes": [{
"name": "costCenter",
"value": hr_user.cost_center
}]
}
# Is PATCH /v2/users/{id} the right way?
requests.patch(f"https://console.jumpcloud.com/api/v2/users/{jc_user.id}", json=payload)
else:
# Log for manual review? Create them?
pass
```

Is this a reasonable approach? What are the best practices for making this pipeline robust but also safe—so I don't accidentally overwrite critical fields or spam the API? Any patterns or open-source connectors you'd recommend?



   
Quote