Orders API: Search results missing metadata

Hello,

I’m noticing a discrepancy in the data being returned by two different Orders API endpoints:

Suppose I’ve created an order, with id 1234, consisting of order-level metadata and a line item with metadata as well.

When using GET /v2/orders/1234 for that order, all the expected metadata fields are returned:

{
  "order": {
    "id": "1234",
    "line_items": [
      {
        "metadata": {
          "foo": "bar"
        },
        "name": "Test item",
        "quantity" : "1",
        ...
      }
    ],

    "metadata": {
      "my_order_id": "..."
    },
    ...
  }
}

However, when using POST /v2/orders/search , the resulting order entry for the above mentioned order with ID 1234 does not include any metadata fields:

{
  "orders": [
    {
      "id" : "1234",
      "line_items" : [
        {
          "name" : "Test item",
          "quantity" : "1",
          ...
        }
      ],
      ...
    }
  ]
}

Is this a known bug/limitation of the search endpoint, or something that might be fixed in the future?

Thanks!

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

https://developer.squareup.com/docs/orders-api/what-it-does
https://developer.squareup.com/docs/orders-api/manage-orders/search-orders
Retrieve Orders

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

I was able to replicate this and am checking with the team on this. :slightly_smiling_face: