Orders_create webhook filters not filtering in the same ways as a graphql query

We are trying to setup a webhook for orders_create that only fires when an order is created without a payment gateway. We usually use orders_paid, but we have an outlier: Orders created using payment terms. We need to receive and export payment terms orders to the ERP before they are paid.

With that in mind I ran the following graphQL query against our store and it returned only the payment terms orders because they don’t have a gateway assigned:


query {
  orders(first: 100, query: "NOT gateway:*") {
    nodes {
      id
      name
    }
  }
}

This works well as does -gateway:*. However when applied to a filter in the orders_create webhook the orders returned in the above query did not trigger the webhook. Here is my webhook definition:

    {                                                                                                                                                                                                                                                                                    
        "node": {                                                                                                                                                                                                                                                                        
            "id": "gid://shopify/WebhookSubscription/***",                                                                                                                                                                                                                     
            "topic": "ORDERS_CREATE",                                                                                                                                                                                                                                                    
            "filter": "NOT gateway:*",                                                                                                                                                                                                                                                   
            "callbackUrl": "https://xxxxx.com/api/webhooks"                                                                                                                                                                                                             
        }                                                                                                                                                                                                                                                                                
    }  

I tried it with the hyphen too and it did not work.

To debug this further I then made an unfiltered orders_create webhook and the payload for payment terms orders did indeed have no gateway assigned, so this is not something wrong with the gateway value at the point the webhook is triggered.

Any help would be much appreciated, we are trying to make sure we receive as few webhooks as possible so would rather not run an unfiltered orders_create webhook and then filter on our servers based on the payload.

Cheers
Luke

Hi @lrotherfield! I tested this on a dev store, and I’d use payment_terms:* for this case rather than NOT gateway:*.

Webhook filters are evaluated against the webhook payload field names. gateway works as an Admin order search filter, but it is not a top-level field in the orders/create webhook payload. In the payload I received, the relevant fields were payment_terms and payment_gateway_names.

For a payment terms order created from a draft order, the orders/create payload included payment_terms and matched this filter.

payment_terms:*

A normal paid order did not match that filter, which lines up with your goal of catching payment terms orders before they are paid.

I would avoid NOT payment_gateway_names:* for this specific use case. In my test, the payment terms order still had payment_gateway_names set to ["manual"], so that filter would not catch it. It could also overmatch other order types where payment gateway names are empty for reasons unrelated to payment terms.

If payment_terms:* still does not fire for you, could you share the API version, the webhook subscription ID, and one example order ID or name that should have matched? With that we can look into whether there is an issue with filter evaluation for that specific payload.