Syncing Jobs

Before we start, do look at Getting started with Knit and How Syncs Work

👍

Prerequisites

  • Take a look at How Syncs Work to get familiar with Syncs
  • Knit API Key
  • Integration ID for any ATS application whitelisted on Knit that has been successfully validated.

With the Jobs Sync, you can sync the Jobs Data Models via Knit.

1. Events generated by Job Sync

  • record.new

When a new job has been created

{
  "eventId": "e_123sadasdasda",
  "eventType": "record.new",
  "eventData": {
    "info": {},
    "departments": [],
    "offices": [],
    "hiringManagers": [],
    "recruiters": [],
    "stages": [],
    "customFields": {},
  },
  "syncType": "initial_sync",
  "syncDataType": "ats_jobs",
  "syncJobId": "sj_asda32424",
  "syncRunId": "sr_jhhkk80869",
  "recordId": "123"
}
  • record.modified

When a job data has been modified

{
  "eventId": "e_123sadasdasda",
  "eventType": "record.modified",
  "eventData": {
    "info": {},
    "departments": [],
    "offices": [],
    "hiringManagers": [],
    "recruiters": [],
    "stages": [],
    "customFields": {},
  },
  "syncType": "delta_sync",
  "syncDataType": "ats_jobs",
  "syncJobId": "sj_asda32424",
  "syncRunId": "sr_jhhkk80869",
  "recordId": "123"
}
  • record.deleted

When a job has been marked as closed or is no longer present in the ATS system

{
  "eventId": "ev_jLPn5iJNhvhDBh91xtb8kc",
  "eventData": {
    "jobId": ""
  },
  "eventType": "record.deleted",
  "syncType": "delta_sync",
  "syncDataType": "ats_jobs",
  "syncJobId": "sj_asda32424",
  "syncRunId": "sr_jhhkk80869",
  "recordId": "123"
}
  • sync.events.processed
{
  "eventId": "ev_UFrXyD8d5yneJ6UnfxAoJ7",
  "eventData": {
    "status": "processed",
    "processed": 200,
    "emitted": 0,
    "startedAt": "1676292064383",
    "processedAt": "1676292068616",
    "complete": false
  },
  "eventType": "sync.events.processed",
  "syncType": "delta_sync",
  "syncDataType": "ats_jobs",
  "syncJobId": "sj_rJWQawZYVS8IqgtXkSJ8BQ",
  "syncRunId": "sn_agQO87vjVs6tMe9CEsPkBk"
}
  • sync.events.allConsumed
{
  "eventId": "ev_Z9s8E9mwdwju7dpRcCLh7d",
  "eventData": {
    "status": "completed",
    "processed": 200,
    "emitted": 200,
    "consumed": 200,
    "completedAt": "1676281276296",
    "startedAt": "1676281265551",
    "processedAt": "1676281275876",
    "complete": true
  },
  "eventType": "sync.events.allConsumed",
  "syncType": "initial_sync",
  "syncDataType": "ats_jobs",
  "syncJobId": "sj_rJWQawZYVS8IqgtXkSJ8BQ",
  "syncRunId": "sn_NHXHC2Hn6oOaLrCfsaqGOM"
}

👍

The webhook will always receive one Job data in one request call.

If you are syncing with some account that has 500 jobs, you can expect the webhook to be invoked 500 times with each job details dispatched individually by Knit. All 500 jobs will not be dispatched together on one API call.

2. Start a Job sync by calling Knit API

You can start a sync by invoking Start a Sync API

Do look at all the Job Data Models and subscribe to the ones that you need.

📘

Use the Model ID in models array to subscribe to a data model.

String payload = "{
     "models": [
          "job_info",
          "job_departments",
          "job_offices",
          "job_hiringManagers",
       		"job_recruiters",
       		"job_stages",
       		"job_customFields"
     ],
     "frequency": "standard",
     "destination": "https://call.me/knithook", //your webhook
     "dataType": "ats_jobs"
}"
  
//You should have an Integration ID before this step.  
String integrationId = "integration-id-received-from-knit-ui-component";  
Request request = new Request.Builder()
                .url("https://api.getknit.dev/v1.0/sync.start")
                .addHeader("Authorization", "Bearer " + YOUR_KNIT_API_KEY)
                .addHeader("X-Knit-Integration-Id", integrationId)
                .post(RequestBody.create(JSON, payload))
                .build();

Response response = HTTP_CLIENT.newCall(request).execute();
if (!response.isSuccessful()) {
  //handle error
}

//store the sync job id for tracking the sync status and runs.
String syncJobId = jsonMapper.readTree(response.body().string()).get("data").get("syncJobId").asText();