Checking if serial number is available?

AussoAusso Posts: 9Member
edited December 2018 in Development
Hi everyone,

Forgive me if this is a dumb question, but I've not been able to find anything really definitive on this. I want to use the API to get the available serial numbers associated with a specific item. I am able to pull up serial numbers for a specific item using the Serialized endpoint, but haven't been able to figure out how to limit the results to only available serial numbers. Any help is greatly appreciated!

Austin

4 comments

  • Adrian SamuelAdrian Samuel moderator Posts: 545Moderator, Lightspeed Staff moderator
    @Ausso no it is a good question!

    There are a few steps in this process:

    Get your itemID from the item endpoint as so:

    https://api.lightspeedhq.com/API/Account/{{accountID}}/Item.json

    So you'll need to get the itemID and make a request to the Serialized endpoint as thus:

    https://api.lightspeedhq.com/API/Account/{{accountID}}/Serialized.json?itemID={{itemiD}}

    Then you'll need to take the SaleLineID that's returned in the response and then insert that into the SaleLine endpoint

    https://api.lightspeedhq.com/API/Account/{{accountID}}/SaleLine/{{saleLineID}}.json?

    This will return the saleID from which we can check the status of the Sale that the SaleLine is associated with the following request:

    https://api.lightspeedhq.com/API/Account/{{accountID}}/Sale/{{saleID}}.json

    Then you can check the Sale.completed key-value pair which returns a boolean whether the sale was completed or not

    Then you will know whether the serial number associated with the item has been used or not

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • AussoAusso Posts: 9Member
    edited December 2018
    Hi @Adrian Samuel ,

    Thanks for the quick response. The way I was able to do it (feel free to let me know if this way will cause issues) was the following which, so far, seems to work:

    First I got the itemID from the Item endpoint like you did, then:

    "https://api.lightspeedapp.com/API/Account/{{accountID}}/Serialized.json?itemID={{itemID}}&saleLineID=0"

    Are there cases where a serial number will have a saleLine = 0 and be unavailable?

    Thanks again for the help
  • Adrian SamuelAdrian Samuel moderator Posts: 545Moderator, Lightspeed Staff moderator
    edited December 2018
    @Ausso

    This way won't work perfectly because when an employee adds an item to a Sale and assigns a serial number, the Serialized endpoint associates that serial number with a saleLineID whether that sale is complete or not.

    You only want to filter out those items that have actually transitioned into a completed sale otherwise your availability numbers will be wrong.

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

Sign In or Register to comment.