Fetch all customers
| GET | /customers |
|---|
Use this endpoint to retrieve the details of all the customers of your organization. In this example, count and skip query parameters have been used. You can invoke this API without these query parameters as well.
Header
Authorization
Example: Bearer {YOUR_AUTH_KEY}
Content-Type
Example: application/json
Accept
Example: application/json
URL Parameters
| Parameter | Datatype | Description |
|---|---|---|
| count | integer(optional) | The number of orders to be fetched. The default value is 10. The maximum value is 100. This can be used for pagination, in combination with skip. |
| skip | integer(optional) | The number of orders to be skipped. The default value is 0. This can be used for pagination, in combination with count. |
Response Parameters
| Parameter | Datatype | Description |
|---|---|---|
| id | integer | The unique identifier of the customer. |
| contact_person_name | string | The name of the customer. |
| company_name | string | The name of the customer's company. |
| display_name | string | The name of the customer's company. |
| string | The customer's email address. | |
| contactperson_number | string | The customer's contact number. |
| company_phone | string | The company's contact number. |
| gst_treatment | string | This indicates whether the customer is GST-registered or not. |
| gstin | string | This is the customer's GST number. |
| customer_code | string | This is the customer's unique identifier code. |
| status | string | The customer's status can be either "Active" or "Inactive". |
| approval | string | The status of the customer approval & possible values are ('pending','accepted','rejected'). |
| address | collection | Collection of customer address. |
| address.addressline1 | string | This is the first line of the customer's address. |
| address.addressline2 | string | This is the second line of the customer's address. |
| address.area | collection | Collection of area. |
| address.area.id | integer | The unique identifier of the area. |
| address.area.name | string | The name of the area. |
| address.area.area_code | string | The code of the area. |
| address.area.city | collection | Collection of city. |
| address.area.city.id | integer | The unique identifier of the city. |
| address.area.city.name | string | The name of the city. |
| address.area.city.code | string | The code of the city. |
| address.area.city.state | collection | Collection of state. |
| address.area.city.state.id | integer | The unique identifier of the state. |
| address.area.city.state.code | string | The code of the state. |
| address.area.city.state.name | string | The name of the state. |
| address.postalcode | collection | Collection of ZIP code. |
| address.postalcode.id | integer | The unique identifier of the ZIP code. |
| address.postalcode.code | string | The ZIP code. |
| pagination | Collection of pagination settings. These settings are used to limit the amount of data retrieved in each request. | |
| pagination.current_page | integer | This is basically the current page number |
| pagination.first_page_url | string (URL) | Data loaded form this page URL. |
| pagination.prev_page_url | string (URL) | This is the previous page URL of the current page URL |
| pagination.next_page_url | string (URL) | This is the next page URL of the current page URL |
| pagination.last_page_url | string (URL) | This is the last page where data exists. |
| pagination.last_page | integer | The number of last page. |
| pagination.per_page | integer | The number of data loaded in a page. |
| pagination.total | integer | Total number of row (Data) exists. |
| pagination.path | integer | Full path of the API. |
Sample Request
curl --location 'https://webservices.sourcehub.in/api/customers?limit=10' \
--header 'Authorization: Bearer ************'
Sample Success Response
{
"data": {
"customers": [
{
"id": 9,
"contact_person_name": "Amit De",
"company_name": "Arobit Business Solutions Pvt Ltd",
"display_name": "Arobit Business Solutions Pvt Ltd",
"email": "",
"contactperson_number": "9163367906",
"company_phone": "9163367906",
"gst_treatment": "Unregistered",
"gstin": "",
"customer_code": "1639328586",
"status": "Active",
"approval": "accepted",
"address": {
"addressline1": "Tarakeswar",
"addressline2": "",
"area": {
"id": 108,
"name": "BTM",
"area_code": "",
"city": {
"id": 1,
"name": "Bengaluru",
"code": "BEN1",
"state": {
"id": 1,
"code": "K001",
"name": "Karnataka"
}
}
},
"postalcode": {
"id": 30,
"code": "560063"
}
}
},
{
"id": 613,
"contact_person_name": "prasanth",
"company_name": "abhav Retail",
"display_name": "abhav Retail",
"email": "",
"contactperson_number": "9740797408",
"company_phone": "9740797408",
"gst_treatment": "Unregistered",
"gstin": "",
"customer_code": "1639569149",
"status": "Active",
"approval": "accepted",
"address": {
"addressline1": "jp nagar",
"addressline2": "",
"area": {
"id": 159,
"name": "J P Nagar",
"area_code": "",
"city": {
"id": 1,
"name": "Bengaluru",
"code": "BEN1",
"state": {
"id": 1,
"code": "K001",
"name": "Karnataka"
}
}
},
"postalcode": {
"id": 86,
"code": "560022"
}
}
}
],
"pagination": {
"current_page": 1,
"first_page_url": "https://webservices.sourcehub.in/api/customers?page=1",
"prev_page_url": null,
"next_page_url": "https://webservices.sourcehub.in/api/customers?page=2",
"last_page_url": "https://webservices.sourcehub.in/api/customers?page=2",
"last_page": 2,
"per_page": 2,
"total": 4,
"path": "https://webservices.sourcehub.in/api/customers"
}
}
}
Sample 401 Faliure Response
{
"error": {
"code": "AUTHENTICATION_ERROR",
"description": "Invalid credential or token.",
"source": "https://webservices.sourcehub.in/api/customers",
"status_code": 401
}
}
Errors
The API key/secret provided is invalid. Error Status: 401
The API credentials passed in the API call differ from the ones generated on the Dashboard. Possible reasons are:
- Different keys for test mode and live modes.
- Expired API key.
Solution :
The API keys must be active and entered correctly with no whitespace before or after the keys.