Fetch sales orders for a customer

GET /orders

Use this endpoint to obtain a comprehensive list of all sales orders associated with a specific customer in your organization. In the following example, the count and skip query parameters are utilized to manage the results. However, you can also invoke this API without including these parameters. Feel free to let me know if you need further adjustments!

Header

                    
                        Authorization
                        Example: Bearer {YOUR_AUTH_KEY}
                        Content-Type
                        Example: application/json
                        Accept
                        Example: application/json
                    
                

Query Parameters

Parameter Datatype Description
phone_number string(required) Customer's phone number.
from_date string (optional) Format dd-mm-yyyy
to_date string (optional) Format dd-mm-yyyy
count integer(optional) The number of orders to retrieve is set to a default value of 10, with a maximum limit of 100. This parameter can be utilized for pagination in conjunction with the 'skip' option.
skip integer(optional) The number of orders to skip, with a default value of 0. This parameter can be utilized for pagination in conjunction with the count.

Response Parameters

Parameter Datatype Description
data object This object contains the entire resource.
orders object This object contains the order related resource.
id Integer The unique identifier for a single order.
order_no String The unique identifier for a single order.
item_total_amount Double Total order amount.
discount_amount Double Total discount availed by the customer.
return_total_amount Double Total amount of returned products.
billable_amount Double Total amount payable by the customer.
date DATE Format (YYYY-MM-DD).
products Collection The list of products associated with the order.
products.id Integer The unique product identifier.
products.sku string The unique product identifier.
products.name string The product name.
products.quantity Integer The quantity of the product sold.
products.price Integer The selling price of the product.
customer Collection The customer's information associated with the order.
customer.id Integer The customer's unique identifier.
customer.contact_person_name String The customer's name.
customer.company_name String The name of the customer's company.
customer.display_name String The customer's display name.
customer.email String The customer's email address.
customer.contactperson_number string The customer's contact number.
customer.company_phone string The company's contact number.
customer.gst_treatment String This indicates whether the customer is GST-registered or not.
customer.gstin String This is the customer's GST number.
customer.customer_code String This is the customer's unique identifier code.
address collection Collection of customer's 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.
salesagent Collection The salesagent's information associated with the order.
salesagent.id Integer The salesagent's unique identifier.
salesagent.first_name String The salesagent's first name.
salesagent.last_name String The salesagent's last name.
salesagent.mobile_number String The salesagent's mobile number.
salesagent.avatar String The full path to the salesagent's avatar image. (Will be null if not available)
salesagent.email String The salesagent's email address.
deliveryagent Collection The deliveryagent's information associated with the order.
deliveryagent.id Integer The deliveryagent's unique identifier.
deliveryagent.first_name String The deliveryagent's first name.
deliveryagent.last_name String The deliveryagent's last name.
deliveryagent.phone_number String The deliveryagent's phone number.
laststatus Collection The order status information associated with the order.
laststatus.name String The current status of the order. Possible values include : Placed, Processed, In Review/Invoice Dept, Shipment Created, Delivered, Cancelled, Returned, Invoice Generated, Undelivered & Postponed
invoices Collection Orders may have multiple invoices. Invoice details associated with the order.
invoices.id Integer The unique invoice identifier.
invoices.invoice_number String The unique invoice identifier.
invoices.date DATE Format YYYY-MM-DD.
invoices.due_date DATE Format YYYY-MM-DD. Invoice due date.
invoices.total_amount Double Total sale's amount.
invoices.discount_amount Double Total discount amount.
invoices.returned_amount Double Total amount of returned items (If any).
invoices.invoice_amount Double Total invoice amount.
invoices.cgst Double Total CGST amount.
invoices.sgst Double Total SGST amount.
invoices.igst Double Total IGST amount.
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/orders/?phone_number=6396281335&count=2&skip=0' \
--header 'Authorization: Bearer ***********'
                    
                

Sample Success Response

                    
                        {
                            "data": {
                                "orders": [
                                    {
                                        "id": 874,
                                        "order_no": "00865",
                                        "item_total_amount": 65000,
                                        "discount_amount": 0,
                                        "return_total_amount": 0,
                                        "billable_amount": 65000,
                                        "date": "2021-06-08",
                                        "products": [
                                            {
                                                "id": 257,
                                                "sku": "sku98",
                                                "name": "necklace",
                                                "quantity": 1,
                                                "price": 65000
                                            }
                                        ],
                                        "customer": {
                                            "id": 3,
                                            "contact_person_name": "test new",
                                            "company_name": "testing",
                                            "display_name": "testing",
                                            "email": null,
                                            "contactperson_number": "6396281335",
                                            "company_phone": "6396281331",
                                            "gst_treatment": "Registered GST",
                                            "gstin": "7896GHYO2030256",
                                            "customer_code": "1625035402",
                                            "address": []
                                        },
                                        "salesagent": [],
                                        "deliveryagent": {
                                            "id": 1,
                                            "first_name": "archa",
                                            "last_name": "jha",
                                            "phone_number": "7697602300"
                                        },
                                        "laststatus": {
                                            "name": "Shipment Created"
                                        },
                                        "invoices": [
                                            {
                                                "id": 877,
                                                "invoice_number": "INV-21-00001",
                                                "date": "2021-06-08",
                                                "due_date": "2021-06-08",
                                                "total_amount": 65000,
                                                "discount_amount": 0,
                                                "returned_amount": 0,
                                                "invoice_amount": 65000,
                                                "cgst": 0,
                                                "sgst": 0,
                                                "igst": 0
                                            }
                                        ]
                                    },
                                    {
                                        "id": 886,
                                        "order_no": "00877",
                                        "item_total_amount": 140000,
                                        "discount_amount": 0,
                                        "return_total_amount": 0,
                                        "billable_amount": 140000,
                                        "date": "2021-06-09",
                                        "products": [
                                            {
                                                "id": 257,
                                                "sku": "sku98",
                                                "name": "necklace",
                                                "quantity": 2,
                                                "price": 140000
                                            }
                                        ],
                                        "customer": {
                                            "id": 3,
                                            "contact_person_name": "test new",
                                            "company_name": "testing",
                                            "display_name": "testing",
                                            "email": null,
                                            "contactperson_number": "6396281335",
                                            "company_phone": "6396281331",
                                            "gst_treatment": "Registered GST",
                                            "gstin": "7896GHYO2030256",
                                            "customer_code": "1625035402",
                                            "address": []
                                        },
                                        "salesagent": [],
                                        "deliveryagent": {
                                            "id": 1,
                                            "first_name": "archa",
                                            "last_name": "jha",
                                            "phone_number": "7697602300"
                                        },
                                        "laststatus": {
                                            "name": "Shipment Created"
                                        },
                                        "invoices": [
                                            {
                                                "id": 878,
                                                "invoice_number": "INV-21-00002",
                                                "date": "2021-06-09",
                                                "due_date": "2021-06-09",
                                                "total_amount": 140000,
                                                "discount_amount": 0,
                                                "returned_amount": 0,
                                                "invoice_amount": 140000,
                                                "cgst": 0,
                                                "sgst": 0,
                                                "igst": 0
                                            }
                                        ]
                                    }
                                ],
                                "pagination": {
                                    "current_page": 1,
                                    "first_page_url": "http://testwebservices.sourcehub.in/api/orders?page=1",
                                    "prev_page_url": null,
                                    "next_page_url": "http://testwebservices.sourcehub.in/api/orders?page=2",
                                    "last_page_url": "http://testwebservices.sourcehub.in/api/orders?page=16",
                                    "last_page": 16,
                                    "per_page": 10,
                                    "total": 153,
                                    "path": "http://testwebservices.sourcehub.in/api/orders"
                                }
                            }
                        }
                    
                

Sample 401 Faliure Response

                    
                        {
                            "error": {
                                "code": "AUTHENTICATION_ERROR",
                                "description": "Invalid credential or token.",
                                "source": "https://webservices.sourcehub.in/api/products",
                                "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