Create customers

POST /customers/create

Use this endpoint to a customer of your organization. In this example. You can invoke this API without these query parameters as well.

Header

                    
                        Content-Type
                        Example: application/json
                        Accept
                        Example: application/json
                    
                

URL Parameters

Parameter Datatype Description
company_name string(required) The customer's company name.
mobile_number string(required) The customer's mobile or primary phone number.
contactpersons_name string(required) The name of the primary contact person.
address string(required) The customer's street address or address line.
area_id integer(required) The area ID. This should come from the Area API.
postalcode_id integer(required) The postal code ID. This should come from thePostal Code API.
gst_treatment string(required) Allowed values shown by Sourcehub are Registered and Unregistered.
gstin string(optional) Required when gst_treatment is Registered.
salesagent_id integer(required) The sales agent ID assigned to the customer.Salesagent API

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.
email 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.

Sample Request

                    
                        curl --location --request POST 'https://testwebservices.sourcehub.in/api/customers/create?
                                company_name=Arun%20Store&mobile_number=1230987654&contactpersons_name=Arun%20Sen&address=Bangalore&area_id=112&
                                postalcode_id=31&gst_treatment=Registered&gstin=29AAACC1206D2ZB&salesagent_id=12'
                    
                

Sample Success Response

                    
                        {
                            "data": {
                                "id": 3424,
                                "contact_person_name": "Arun Sen",
                                "company_name": "Arun Store",
                                "display_name": "Arun Store",
                                "email": "",
                                "contactperson_number": "1230987654",
                                "company_phone": null,
                                "gst_treatment": "Registered",
                                "gstin": "",
                                "customer_code": null,
                                "status": "Active",
                                "approval": "accepted",
                                "address": {
                                    "addressline1": "Bangalore",
                                    "addressline2": "",
                                    "area": {
                                        "id": 112,
                                        "name": "Agaram",
                                        "area_code": "",
                                        "city": {
                                            "id": 1,
                                            "name": "Bengaluru",
                                            "code": "BEN1",
                                            "state": {
                                                "id": 1,
                                                "code": "K001",
                                                "name": "Karnataka"
                                            }
                                        }
                                    },
                                    "postalcode": {
                                        "id": 31,
                                        "code": "560030"
                                    }
                                }
                            }
                        }
                    
                

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.

CONTENTS