API Response Structure

Every Knit API response follows a consistent envelope structure. This page explains the response body format for success and error cases, along with the response headers returned by Knit

Success Message

Knit API's response will always have success body parameter set. success boolean can be used for evaluating whether an API call was successful. A successful API call will also contain dataobject. The API response will be present within data object. Below is an example for successful Employee Location API response

All responses from Knit's API share a consistent top-level structure:

FieldTypeAlways PresentDescription
successbooleanYestrue if the call succeeded, false if it failed
dataobjectOn success onlyContains the API response payload
errorobjectOn failure onlyContains error details

Successful Response

When a request succeeds, success is true and the response payload is nested inside the data object. The shape of data varies by endpoint.

Example - generic structure:

{
  "success": true,
  "data": {
    
  }
}

Example - Employee Location endpoint:

{
  "success": true,
  "data": {
    "employeeId": "emp_8a7f3k",
    "addressLine1": "221B Baker Street",
    "addressLine2": "Apt 2",
    "city": "London",
    "state": "England",
    "country": "GB",
    "zipCode": "NW1 6XE",
    "addressType": "HOME_PRESENT"
  }
}

Error Message

When a request fails, success is false and the error object contains details about what went wrong.

FieldTypeDescription
error.msgstringHuman-readable description of error

{
  "success": false,
  "error": {
    "msg": "No such employee exists"
  }
}

Tip: Always check the success field first before processing the data object to avoid runtime errors on failed responses.

Response Headers

Below is a set of Knit headers you can expect in the API Response

Knit HeaderPresent OnTypeDescription
X-Knit-Execution-IdAll ResponsesMandatoryUnique Id for each API call/Webhook dispatch. Use it for debugging a particular execution.
X-Knit-SignatureWebhook dispatches onlyOptionalOnly passed with Webhook dispatches for checking the integrity of the Webhook message.
X-Knit-Integration-IdWebhook dispatches onlyOptionalOnly passed with Webhook dispatches.