Customer GIDs in webhook payloads for guest checkouts

I’m trying to make sense of how this works.

I’m consuming checkouts/create and checkouts/update, i noticed that for guest checkouts the webhook payload contains a customer object, along with a "admin_graphql_api_id", which made me think that this id can be used with the graph api.

So I tried to query for it from within a checkout function, but the checkout function sees a null.

Can someone explain this to me?

Hey @nova_avon - thanks for reaching out and I’ll do my best to clarify here.

When you consume checkouts/create / checkouts/update, the payload is delivered to your app’s backend. The admin_graphql_api_id you see there is a real Customer GID, and you can use it with the Admin GraphQL API from your server, where your app is authenticated and has the right scopes.

A checkout Function works differently. It only receives the fields you ask for in its input query, evaluated live during the checkout, and it has no Admin API access at all. There’s no “look up this GID” step available inside a Function. The one outbound path a Function has is the optional fetch target (with network access requested which is predominantly available for Enterprise merchants), and that calls an external service you run, not Shopify’s Admin API. So handing a customer GID to a Function and querying it isn’t something the platform supports.

There’s a second thing worth knowing. The webhook payload and a Function’s input are different shapes. The webhook gives you a flat customer object. A Function instead exposes customer info under its input query at cart.buyerIdentity.customer, and for a guest checkout that field is null. It only populates once the buyer is signed in to a customer account, so a guest reads as null there even though the webhook recorded a customer for the same checkout.

If you need customer data inside the Function, the supported routes are:

  • You can request it in the input query and handle the null case for guest buyers
  • For data you control, a customer or product metafield (or a cart attribute) can carry it in, and you read that from the input query

Reference: the Function APIs overview covers inputs, targets, and the access limitations, and each Function API’s reference page lists the exact input fields available to it.

Hope this helps and let me know if you have any other questions!