Presence and timing of customer_id field in Orders API

When retrieving orders through the Orders API (POST/v2/orders/search), sometimes an order contains the customer_id field and sometimes it does not. This appears to be subject to timing (in limited testing it is absent when pulling an order 3 mins after the order was created and is present when pulling the order 10 mins after created). What is the maximum time it takes for this field to be populated in the orders object, and are there any cases when this field is never added?

Hi @bill welcome to the forums!

As far as I know the customer_id should appear relatively quickly, but we do not offer any guarantees on the maximum time. With that said, it also depends on how the order/payment was created. For instance, if you are creating the payment yourself using CreatePayment and attaching an order via CreateOrder, but only attach the customer_id to the payment (or neither), then the customer_id wouldn’t be on the order regardless.

Oh I see. I am dealing only with orders coming in from the Square Online Store. I am running a scheduled job to run a function that uses the customer_id to lookup the customer and see if they are in a specific customer group, and that info is used in the order fulfillment. While I would like this job to be run within 5-10 minutes of a new order, I would sacrifice timeliness to have that data. I don’t need a guarantee on it, just trying to understand how best to do this reliably. Would webhooks help here, or is it better to do a delayed scheduled job? Thanks

I’m trying to use this field as well, with Square Online Store; I don’t seem to be getting the customer_id field on batch retrieves (by id) or search. I can see that these orders are attached to customers in the dashboard. Can you help clarify?

If there is no way to get the Customer for a given order reliably, that seems to be a giant hole in the API. Are there any workarounds?


OrderId examples: CwsWeT0UAutjTZrLl3ZeT1GHBd4F, IHcB8AlA4tF1XsBsEO7x1ICGjg4F, Sw0sKrBzzeAyjkknGToIV5IPYh4F


Looks like the customer_id belongs to the Transaction, so if you use the (yes, deprecated) RetrieveTransaction (and order_id == transaction_id) then you can find the customer_id. This can happen in certain scenarios dealing with instant profiles. There are plans to make this available in Payments/Orders, but no ETA on when it will be available at this time.

I’m seeing customer Id inside the Tenders, inside a transaction. Is that your suggestion? My use case is an OrderCreated/Updated webhook that looks for completed orders. When order is completed, I check to see the items purchased and if one is a particular category, then I generate a special templated email with instructions, pdf, etc… so since it’s in a webhook and time is not a huge concern, my plan is to get the Order via Batch Retrieve; check for customer_id. If it’s not there, get the Transaction by OrderId, and check for customer_id in Tenders array.

Any other thoughts/ideas on how best to confirm identity of a customer for purpose of sending special instructions/email to them based on the items in a particular order?

Thanks for your help!


I’m finding transacitons/orders that I’m unable to tie to customer_id via the API but are clearly linked to a customer when browsing the dashboard. Can you help identify what’s going on? Example Order Id: i0aiXpj2chofRMFVPN4mQS2Ofc4F

In this case, it was an order from Online Store. There is no customer_id on the Order object and I get now value when I query for a transaction by id, using the Order Id as the lookup.

Any ideas?


That order (i0aiXpj2chofRMFVPN4mQS2Ofc4F) is still open, not paid for. Once it’s closed, it should create a payment/transaction that will have the customer information. Let me know if that’s not the case, though.