Skip to content
Docs
API 1.0.0 · 22 Nov 2026

Search the docs

    Română

    Sync your directory

    Keep the people of HR in step with your own directory: hire, change and leave, with a run that can be repeated.

    On this page

    If your people are kept in another system, the sync reads a row for each person and brings HR to the same state. It has three rules: every person carries your own number as externalId; every change has an operationId that depends only on the row, so a run that is repeated sends the same requests; and every change to an existing person sends the revision that was read.

    Find the person

    List people with externalId returns the person or an empty list. This is how a repeated run learns that a hire already happened.

    curl

    curl "$RDC_BASE_URL/hr/v1/employees?externalId=hr-0231" \
      -H "Authorization: Bearer $RDC_TOKEN"

    JavaScript

    const response = await fetch(`${process.env.RDC_BASE_URL}/hr/v1/employees?externalId=hr-0231`, {
      method: 'GET',
      headers: {
        Authorization: `Bearer ${process.env.RDC_TOKEN}`,
      },
    });
    const result = await response.json();

    Python

    import os
    import requests
    
    response = requests.request(
        'GET',
        f'{os.environ["RDC_BASE_URL"]}/hr/v1/employees?externalId=hr-0231',
        headers={
            'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
        },
    )
    result = response.json()

    PHP

    <?php
    
    $curl = curl_init(getenv('RDC_BASE_URL') . '/hr/v1/employees?externalId=hr-0231');
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => 'GET',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        ],
    ]);
    $result = json_decode(curl_exec($curl), true);
    curl_close($curl);

    C#

    using System.Net.Http.Headers;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/hr/v1/employees?externalId=hr-0231");
    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
    var response = await client.SendAsync(request);
    var result = await response.Content.ReadAsStringAsync();

    Response 200

    {
      "items": [
        {
          "id": "c9e3affa-61ed-4023-a015-4c988db539e5",
          "number": "A-0053",
          "name": "Teodora Nistor",
          "job": "Buyer",
          "departmentId": "purchasing",
          "managerId": "68830a58-d574-4401-9f7d-90be0b6c1dbf",
          "workplaceId": "office",
          "contractType": "indefinite",
          "contractEnd": null,
          "startDate": "2026-12-02",
          "lastDay": null,
          "status": "onboarding",
          "externalId": "hr-0231",
          "revision": 1
        }
      ],
      "nextCursor": null
    }

    What each row does

    The row saysThe sync sendsIf it is repeated
    A person HR does not knowcreateEmployeeSame operationId: one person
    A different job from this day onchangeEmploymentSame operationId: one period
    A last daystartOffboardingRefused with already_offboarding if it was done under another operationId

    The code

    sync.mjs

    import {createHash} from 'node:crypto';
    
    const base = process.env.RDC_BASE_URL;
    const headers = {Authorization: `Bearer ${process.env.RDC_TOKEN}`, 'Content-Type': 'application/json'};
    
    // The same row and the same change always give the same operationId, so a run that is repeated sends the same request.
    function operationId(parts) {
      const hex = createHash('sha256').update(parts.join('|')).digest('hex');
      return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-8${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
    }
    
    async function call(method, path, body) {
      const response = await fetch(`${base}${path}`, {method, headers, body: body ? JSON.stringify(body) : undefined});
      if (response.status >= 500) throw new Error(`${path}: ${response.status}`);
      return {status: response.status, body: await response.json()};
    }
    
    export async function findByExternalId(externalId) {
      const {body} = await call('GET', `/hr/v1/employees?externalId=${encodeURIComponent(externalId)}`);
      return body.items[0] ?? null;
    }
    
    export async function syncRow(row) {
      const known = await findByExternalId(row.externalId);
      if (!known) {
        return call('POST', '/hr/v1/employees', {
          operationId: operationId(['hire', row.externalId]), externalId: row.externalId, name: row.name, job: row.job, departmentId: row.departmentId,
          workplaceId: row.workplaceId, contractType: row.contractType, grossSalary: row.grossSalary, startDate: row.startDate,
        });
      }
      if (row.lastDay && !known.lastDay) {
        return call('POST', `/hr/v1/employees/${known.id}/offboard`, {operationId: operationId(['last-day', row.externalId, row.lastDay]), expectedRevision: known.revision, lastDay: row.lastDay});
      }
      if (known.job !== row.job) {
        return call('POST', `/hr/v1/employees/${known.id}/employments`, {
          operationId: operationId(['job', row.externalId, row.job, row.effectiveFrom]), expectedRevision: known.revision, effectiveFrom: row.effectiveFrom, job: row.job,
        });
      }
      return null;
    }
    

    When a row is refused

    • 409 with revision_conflict: someone changed the person since you read them. Read again and decide whether the row still applies.
    • 422 with leave_after_last_day: leave is still open after the last day. Cancel those requests, then send the last day again.
    • 422 with not_a_working_day: the first day of work of a hire falls on a weekend or a public holiday. Correct the row.