Creating Draft Order - Email is invalid

When trying to create a draft order through the Graph QL API I am getting the error returned as;

{
    "draftOrderCreate": {
        "draftOrder": null,
        "userErrors": [
            {
                "field": [
                    "email"
                ],
                "message": "Email is invalid",
                "__typename": "UserError"
            }
        ],
        "__typename": "DraftOrderCreatePayload"
    }
}

The odd thing is this is a customer that already exists on the store - and has placed orders in the past.

In the create payload I am sending both the Customer ID in the purchasingEntity field as well as the email in the “email” field.

Also, strangely, the draft order can be created through the Admin interface no problem.

The email looks inconspicuous and is a normal “@gmail.com” email. I can see in the timeline of the customer that emails have been sending normally.

I tried just sending the customerId in purchasingEntity and not including the email and that actually seemed to work fine - so there is a work around, but still strange.

Can you omit the purchasingEntity and just try passing email?

Hey @ozzyonfire,

I tested this on my test shop and couldn’t reproduce the “Email is invalid” error. Passing both customerId and email together worked fine across multiple scenarios.

Your current implementation (customerId-only) is working so you’re good to move forward with that, but if you’d like to investigate further so we can understand what’s causing the validation error in your environment, I’m happy to help dig into it.

A few things that could help narrow this down:

  • Which API version are you using?
  • Can you share the x-request-id from a failed request?
  • Are there other fields in your mutation beyond customerId and email that might be contributing?