> ## Documentation Index
> Fetch the complete documentation index at: https://help-empuls.xoxoday.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send referral data to Empuls with the ingestion webhook

> Push referee and referrer records from your HRMS to Empuls referral incentives with the data ingestion webhook. Covers authentication, payloads, and batch status.

The data ingestion webhook lets your HRMS or integration platform send referral records to Empuls. Empuls processes each batch, matches referees to referrers, and applies your [referral incentive policies](https://help-empuls.xoxoday.com/admin/referral-incentives/set-up-referral-policies.md).

The webhook has two endpoints:

* `POST /chef/api/webhook/store_data` submits a batch of records.
* `GET /chef/api/webhook/batch_status` reports how a batch was processed.

## Prerequisites

* An OAuth client with the `empulsapi` scope. The Empuls team issues the client ID, client secret, and refresh token. See [Authentication & Authorisation](https://help-empuls.xoxoday.com/admin/integrations/other/sdk.md#1-authentication-%26-authorisation).
* A referral data webhook integration enabled for your company.
* A `dataSourceName` agreed with the Empuls team and configured for your company.
* If your OAuth client has an IP allowlist, calls must come from an allowed IP address.

## Authenticate

Exchange your refresh token for a company access token, then send it in the `Authorization` header:

```bash theme={null}
Authorization: Bearer xoxoc-<access_token>
```

Empuls identifies your company from the token alone. Don't send a user identifier, company ID, or tenant header. Empuls rejects any record that contains `company_id`, `auth_company_id`, or `auth_user_id` with `400 invalid_request`.

## Submit a batch

```text theme={null}
POST https://{subdomain}.xoxoday.com/chef/api/webhook/store_data?dataSourceName={name}&data_type={type}
```

| Query parameter | Description |
| - | - |
| `dataSourceName` | Required. Your configured data source. Use 1 to 64 letters, digits, `.`, `_`, or `-`. |
| `data_type` | Required. `json` for one object, `json_array` for an array of objects, or `csv`. |

`dataSourceName` and `data_type` are the only query parameters Empuls accepts. Any other query parameter returns `400 invalid_request`. Send all employee data in the request body.

The `Content-Type` header must match `data_type`:

| `data_type` | `Content-Type` |
| - | - |
| `json` | `application/json` |
| `json_array` | `application/json` |
| `csv` | `text/csv` |

### Limits

* Up to 1,000 records per call. Split larger batches across sequential calls.
* Up to 5 MB per request body.
* Up to 120 calls per minute to `store_data` and 60 per minute to `batch_status`.

### Record fields

| Field | Description |
| - | - |
| `emp_id` | The referee's employee ID |
| `name` | The referee's name |
| `work_email` | The referee's work email |
| `band` | The referee's band or grade |
| `department` | The referee's department |
| `referred_by_emp_id` | The employee ID of the referrer |
| `resignation_status` | The referee's resignation status |

Empuls ignores any other field. Leave optional fields empty rather than sending the string `null`. A record that is missing a mandatory field, such as `work_email`, is rejected during processing.

For CSV, the first row must be a header row with these field names. Use UTF-8 and comma delimiters.

### Example request

```bash theme={null}
curl -X POST 'https://{subdomain}.xoxoday.com/chef/api/webhook/store_data?dataSourceName=npci_referral_employees&data_type=json_array' \
  -H 'Authorization: Bearer xoxoc-<access_token>' \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "emp_id": "E1042",
      "name": "Priya Sharma",
      "work_email": "priya.sharma@example.com",
      "band": "B2",
      "department": "Engineering",
      "referred_by_emp_id": "E0311",
      "resignation_status": ""
    }
  ]'
```

Empuls responds with `202 Accepted`:

```json theme={null}
{
  "success": 1,
  "batch_id": "<batch_id>",
  "dataSourceName": "npci_referral_employees",
  "data_type": "json_array",
  "received_records": 1,
  "received_at": "2026-10-13T09:30:00.000Z"
}
```

A `202` means Empuls received the batch. It doesn't mean every record was accepted. Save the `batch_id` and check the batch status.

## Check batch status

```bash theme={null}
curl 'https://{subdomain}.xoxoday.com/chef/api/webhook/batch_status?batch_id=<batch_id>' \
  -H 'Authorization: Bearer xoxoc-<access_token>'
```

`status` is one of `queued`, `processing`, `processed`, or `failed`. Records are processed in a scheduled run, so poll about once an hour. Don't poll more often than every 15 minutes.

Once a batch is `processed`, the response lists each record's outcome:

```json theme={null}
{
  "success": 1,
  "batch_id": "<batch_id>",
  "status": "processed",
  "summary": { "received": 2, "accepted": 1, "rejected": 1 },
  "accepted_records": [
    { "emp_id": "E1042", "name": "Priya Sharma", "referred_by_emp_id": "E0311" }
  ],
  "rejected_records": [
    {
      "emp_id": "E1043",
      "reason_code": "referrer_not_found",
      "reason": "referred_by_emp_id did not resolve to a known employee"
    }
  ]
}
```

| `reason_code` | Meaning |
| - | - |
| `missing_mandatory_field` | A mandatory field was absent or empty |
| `invalid_field_value` | A field failed validation or didn't match a value configured for your company |
| `referrer_not_found` | `referred_by_emp_id` didn't match a known employee |
| `policy_cap_exceeded` | The record was valid, but your company's incentive cap is already exhausted |

An unknown `batch_id` returns `404 unknown_batch`.

## Errors

Error responses include `error` and `error_description` fields:

```json theme={null}
{
  "error": "invalid_request",
  "error_description": "dataSourceName is required and must match ^[A-Za-z0-9._-]{1,64}$"
}
```

| Status | `error` | What to do |
| - | - | - |
| 400 | `invalid_request` | Fix the query parameters, record count, or forbidden fields, then resend |
| 400 | `invalid_payload` | Fix the body so it matches `data_type`, then resend |
| 401 | `invalid_token` | Get a new access token |
| 403 | `invalid_permission` | Ask Empuls to grant your client the `empulsapi` scope |
| 403 | `invalid_ip` | Call from an allowed IP address |
| 403 | `unknown_data_source` | Contact Empuls to configure the `dataSourceName` |
| 413 | `payload_too_large` | Split the batch so each body is under 5 MB |
| 415 | `unsupported_media_type` | Set the `Content-Type` that matches `data_type` |
| 429 | `rate_limited` | Back off and retry |
| 500 | `server_error` | Retry with backoff |
