# Orders API to replicate "Online" \> "Orders" \> "Export Orders"

**URL:** <https://developer.squareup.com/forums/t/orders-api-to-replicate-online-orders-export-orders/9851>\
**Category:** Questions\
**Tags:** orders-api\
**Created:** [June 25, 2023, 11:53pm UTC](https://developer.squareup.com/forums/t/orders-api-to-replicate-online-orders-export-orders/9851 "2023-06-25T23:53:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lle4](https://avatars.discourse-cdn.com/v4/letter/l/9fc29f/32.png) [@lle4](https://developer.squareup.com/forums/u/lle4)\
**Post date:** [June 25, 2023, 11:53pm UTC](https://developer.squareup.com/forums/t/orders-api-to-replicate-online-orders-export-orders/9851/1 "2023-06-25T23:53:23Z")

</div>

I’m working within the Square API to try to re-create the Export Orders option for all online orders. So far, I’m working with the following payload:

```auto
    let payload = {
      "return_entries": false,
      "limit": 5000,
      "location_ids": ["xxxxx"],
      "query": {
        "filter": {
          "state_filter": {
            "states": ["OPEN"]
          }
        },
        "source_filter": {
          "source_names": [
            "Square Online",
          ]
        },
      },

    };

```

This is doing a pretty good job, but a few things don’t seem to be quite right. The IDs associated with each order do not match the format from the raw export (raw export Order ID #s are 10-digit strings, here I’m getting 25 or 29-digit ID values); but the most important thing is the customer\_id field, which just isn’t populating in about 70-80% of cases. When I do the online export, I can always get the customer name and email, but I don’t see a clear way to do that if I can’t hit the customers api when I have an order in hand. In Stripe, this would be done simply by “extending” the API queries, which makes it WAY easier to just quickly and simply get the customer info–is there an equivalent version in Square? If not, are there other endpoints I should be looking at?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [June 26, 2023, 4:18pm UTC](https://developer.squareup.com/forums/t/orders-api-to-replicate-online-orders-export-orders/9851/2 "2023-06-26T16:18:59Z")

</div>

With the Orders API the short `order_id` that’s shown in the seller Dashboard isn’t currently returned in the API response. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team.

If the `customer_id` isn’t in the order body you’ll want to call the Payments API [GetPayment](https://developer.squareup.com/reference/square/payments-api/get-payment) with the `payment_id` to get the `customer_id`.

If a customer is not assigned to a payment, Square attempts to infer the associated customer. First, Square checks the `customer_id` field in the corresponding order. If this field is not set, Square searches the Customer Directory for a matching profile using payment or related information (such as the billing and shipping address, email address, and payment source). If one cannot be found, Square attempts to create an instant profile. Note that this process is asynchronous and might take some time before `customer_id` is added to the payment.

If Square cannot find a matching customer profile and cannot create an instant profile, the `customer_id` field of the payment remains unset. 🙂
