order endpoint - CustomFieldValues

sam123456sam123456 Member Posts: 54

the documentation suggests that I should be able to access an order custom field value from the order endpoint

however, the examples, and my own json responses don't include any mention of of the custom field. How can I access this field/value per order?


  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @sam123456 ,

    Thank you for contacting us.

    When want to get the CustomFieldValues per order you'll need to do the following request.


    You will see the following response:

            "CustomFieldValues": {
                "CustomFieldValue": {
                    "customFieldValueID": "3",
                    "customFieldID": "1",
                    "name": "Inkooporder",
                    "type": "boolean",
                    "value": "true"

    I hope this will help.

  • gregaricangregarican Member Posts: 926 

    One caveat I've found. When querying not a single record but multiple records, including custom fields is an expensive operation. In terms of the response time. For example, if I query a single product then the response time is relatively quick. But if I query a listing of multiple products, including all of our custom fields can really drag things down. I suppose it depends on our over-reliance upon custom fields 😀

  • sam123456sam123456 Member Posts: 54
    edited September 2019

    @gregarican I'm putting together a little script to concatenate the value in a custom field called "buyer" with the order reference number and move the new string to the notes field.

    I'm still a bit confused why Lightspeed hasn't made it possible to search by reference number, but this is (hopefully) my way around the issue.

    To be clear, but 'expensive' to you mean it just runs slowly or it actually costs more in the leaky bucket calculation?

  • gregaricangregarican Member Posts: 926 

    Sorry I wasn't clear. the GET requests are a factor of 1, compared to POST or PUT requests at a factor of 10. So your GET requests aren't expensive in that regard. I meant performance-wise getting the response back. For example, our products have roughly a dozen custom fields we used to define the items more granularly for their attributes. Pulling these custom fields for a product list via the API takes awhile!

  • sam123456sam123456 Member Posts: 54
    edited September 2019

    @gregarican Understood, thank you.

    @LucienVersendaal When I try to use Put to update the notes field, I'm getting response 400. I'm assuming it's possible to update that field, right? Is there an issue with my code?

    headers = {
        'authorization': f'Bearer {self.access_token}'
    endpoint = f'/Order/{orderID}.json'
    url = f'{self.base_url}{self.account_id}{endpoint}'
    data = {
        "note": f"{buyer} - PO#:{refnumber}"
    response = requests.put(url, headers=headers, data=data)

    I've tried adding:


    to the url, but that was also a 400 response.

    Thanks in advance !


    NVM on this part of the question. I figured out that:

    data=data needs to be json=data

    Post edited by sam123456 on
  • gregaricangregarican Member Posts: 926 

    This worked for me. The web request/response pair is below. Note you have to create a Note array and then specify the noteID within there too. Hope this helps!

    PUT https://api.merchantos.com/API/Account/{accountId}/Order/9.json HTTP/1.1

    Authorization: Bearer {token}

    Content-Type: text/plain

    User-Agent: PostmanRuntime/7.16.3

    Accept: */*

    Cache-Control: no-cache

    Postman-Token: ebb82a2a-f18c-4448-9b6b-64072b50a8b1

    Host: api.merchantos.com

    Accept-Encoding: gzip, deflate

    Content-Length: 95

    Cookie: __cfduid=dc92c208fe990511a3e7b3f1c7a60be141540561895

    Connection: close


     "Note": {

          "noteID": "359",

          "note": "update test note"



    HTTP/1.1 200 OK

    Date: Fri, 06 Sep 2019 17:13:47 GMT

    Content-Type: application/json

    Content-Length: 543

    Connection: close

    x-frame-options: SAMEORIGIN

    X-XSS-Protection: 1; mode=block

    X-Content-Type-Options: nosniff

    X-LS-Acct-Id: 164019

    X-LS-OAuth-Client-Id: 64577

    X-LS-API-Bucket-Level: 10/100

    X-LS-Shard-Id: 18

    X-LS-API-Drip-Rate: 5

    X-LS-Master-System: false

    X-LS-Master-Account: true

    X-LS-Master-Catalog: false

    Vary: Accept-Encoding

    Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"

    Server: cloudflare

    CF-RAY: 51221359abf5c548-ORD

    {"@attributes":{"count":"1"},"Order":{"orderID":"9","orderedDate":"2018-04-18T04:00:00+00:00","shipInstructions":"","stockInstructions":"","shipCost":"0","otherCost":"0","complete":"false","archived":"false","discount":"0","totalDiscount":"0","totalQuantity":"0","arrivalDate":"2018-04-23T04:00:00+00:00","timeStamp":"2019-09-06T17:13:47+00:00","refNum":"loose","vendorID":"124","noteID":"359","shopID":"2","createdByEmployeeID":"0","Note":{"noteID":"359","note":"update test note","isPublic":"false","timeStamp":"2019-09-06T17:13:47+00:00"}}}

  • sam123456sam123456 Member Posts: 54

    @gregarican Thank you!

Sign In or Register to comment.