Creating Purchase Order with Multiple Orderlines

ManavAggarwalManavAggarwal Member Posts: 5


I am trying to create a purchase order in lightspeed via salesforce integration using the APIs. I am able to successfully create an order, but when I enter multiple order line items, it creates only the first one. I am not able to find anything in the documentation. Does Lightspeed API not support bulk uploads? Or am I looking at the wrong place? (



  • Hello @ManavAggarwal,

    It's not possible to make bulk uploads, each orderline needs to be created individually.

  • ManavAggarwalManavAggarwal Member Posts: 5

    Hi Alex,

    Thanks for the response.

    The trouble I am facing with creating each orderline individually is that I hit the rate limit very frequently.

    So far my team is not able to come up with an effective workaround to send orderlines without hitting Error 429.

    Any suggestion would be really helpful.

  • Hello @ManavAggarwal,

    You will need to adjust your API request calls by looking at the header X-LS-API-Bucket-Level which provides the current drip rate and the current level of your bucket

  • ManavAggarwalManavAggarwal Member Posts: 5

    Hi @Alex Lugo

    The problem is that we are unable to send multiple records in one go due to no Bulk API and are also unable to send multiple records individually due to rate limiting.

    At this point, we are stuck and don't really have anywhere to go. The code from my end is opitmized to send requests only when necessary, but that is also proving a challenge.

    I can buy 10 different products which will make 5 different line items. Sending them together along with an order record will cause the integration to fail in the first transaction itself.

    Since the integration needs to be real-time, we cannot wait for the bucket to empty before sending the next batch.

    Please advise.

  • Hello @ManavAggarwal,

    Would it be possible for you to confirm that you want to create a Purchase Order and not a Sale? When you create a sale, is it possible to create a sale with multiple saleLines in the same API request. Purchase Orders is the list of items that merchants will acquire from one of their vendors vs. sales, which are transaction between the merchants and a customer.

  • rcojoercojoe Member Posts: 4

    @ManavAggarwal ,

    If you are hitting 429's, then use a simple pause point to let the bucket drip for a few seconds. This code below checks the bucket and makes sure there is at least 15 units left before proceeding. If there is not, it pauses the script for 10 seconds to let the drip level reduce the bucket. Run this after every line added (PUT). I am in the same situation as you, too little bucket units for the amount of work I want to do immediately. It just takes time to import these lines because of the bucket system but that is the nature of any API, you have pay attention to your rate limits and work around them.

    This is in PHP

    $usage_bucket = explode("/",$header_content["X-LS-API-Bucket-Level"]);

    //$usage_bucket[1] is total bucket units allowed

    //$usage_bucket[0] is current bucket units used

    if ($usage_bucket[1] - $usage_bucket[0] <= 15) {

       echo "Sleeping for 10 seconds\n";



Sign In or Register to comment.