Kaizen #53 - Sales Orders #API

Kaizen #53 - Sales Orders #API

Hello everyone!
Welcome back to another week of Kaizen.
In this post, we will discuss inserting, updating, and deleting a Sales Order via an API.

What is a Sales Order?
A Sales Order is a document sent to your customers to confirm the items and prices of a sale. It is usually created after a quote is accepted by your customers, and your items are ready to be shipped or delivered to them.

Getting a Sales Order
Use the Get Records API to get the record(s) from the Sales Order module.

Request URL: {api-domain}/crm/v2/Sales_Orders (or)
                        {api-domain}/crm/v2/Sales_Orders/ {record_id}
Request Method: GET

Sample Response



Creating a Sales Order
Use the Insert Records API to insert a record in the Sales Order module.

Request URL: {api-domain}/crm/v2/Sales_Orders
Request Method: POST

Sample Input

{
    "data": [
        {
            "Account_Name": {
                "id": "3652397000000624046"
            },
            "Subject": "SO Kaizen 53",
            "Product_Details": [
                {
                    "product": {
                        "id": "3652397000000416001"
                    },
                    "quantity": 10,
                    "Discount": 20,
                    "Unit Price": 1000,
                    "line_tax": [
                        {
                            "percentage": 10,
                            "name": "Sales Tax"
                        },
                        {
                            "percentage": 1,
                            "name": "VAT"
                        }
                    ]
                }
            ]
        }
    ]
}

Request JSON

Key 
Description
Account_Name
Mandatory, JSON object
The record ID of the account you want to associate the sales order with. Use the Get Records API to fetch the Account_Name.
Subject
Mandatory, string
The subject line of your sales order.
Product_Details
Mandatory, JSON array
An array of details of the product you want to generate the sales order for. For more details on the keys inside this array, refer to our post on Handling product line items in the inventory modules.
Owner
Optional, JSON object
The record ID of the owner you want to assign this sales order record to. Use the Get Users API to fetch the owner's details.
Deal_Name
Optional, JSON object
The record ID of the deal you want to associate with this sales order. Use the Get Records API to fetch the Deal_Name.
Quote_Name
Optional, JSON object
The record ID of the quote that is associated with the sales order.
Contact_Name
Optional, JSON object
The record ID of the contact you want to associate with the sales order. Use the Get Records API to fetch the Contact_Name.
Discount
Optional, integer
The discount you want to offer on the sales order.
Description
Optional, string
A description of the sales order.
Customer_No
Optional, string
The customer number that you are generating the sales order for. This is for your own internal reference.
Tax
Optional, integer
The tax you want to apply for the sales order (this is different from the tax inside the product details section, which pertains to the taxes levied on that product).
Carrier
Optional, string
The name of the carrier that will ship the sales order. You can get the possible values through the Fields Metadata API.
Sales_Commission
Optional, integer
The commission that is applicable for the sale.
Due_Date
Optional, string
The date in the yyyy-mm-dd format on which the sales order is due.
Adjustment
Optional, integer
The adjustment in the sale, if any, that is added to the grand total of that product.
Terms_and_Conditions
Optional, string
The terms and conditions of the sales order, if any.
Excise_Duty
Optional, integer
The excise duty levied on the sale of the product, if any.
$line_tax
Optional, JSON array
The tax that you want to apply to the Sub Total of the line items while generating the sales order. For more details,  refer to Handling product line items in the inventory modules.
Status
Optional, string
The status of the sales order. You can get the possible values through the Fields Metadata API.

Apart from the above keys, you can also specify the keys about the billing and shipping details. Go to Setup > Developer Space > APIs > API Names > Sales Orders to know the API names of these fields. You can also use the Fields Metadata API.

Sample Response



Note
  • You can insert a maximum of 100 sales orders in an API call.
  • You can associate up to 200 products with a sales order. Add a JSON object for each product in the Product_Details section.

Updating a Sales Order
Use the Update Records API to update the record(s) in the Sales Order module.

Request URL: {api-domain}/crm/v2/Sales_Orders/record_id (or)
{api-domain}/crm/v2/Sales_Orders (with record IDs in the input body)
Request Method: PUT

Sample Input
In this example, we have updated the product associated with the sales order.



Sample Response



Note
  • You can update a maximum of 100 sales orders in an API call. 
  • When you update multiple sales orders in a single call, pass the record ID of each sales order in the JSON object under the root key "data". Example:
    {
        "data": [
            {
    "id":"3652397000002791035",
            },
            {
    "id":"3652397000002791004",
            }
        ]
    }

Deleting a Sales Order
Use the Delete Records API to delete the record(s) in the Sales Order module.

Request URL: {api-domain}/crm/v2/Sales_Orders/{record_id} (or)
                         {api-domain}/crm/v2/Sales_Orders?ids=record_id1,record_id2
Request Method: DELETE

Sample Response



Note
You can delete a maximum of 100 sales orders in a single API call.


We hope you found this post useful. Let us know your questions and feedback in the comments section, or write to us at support@zohocrm.com.

Cheers!





    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now