Get Batch Contact Api to Drop contacts that that fail validation

I’m importing a bunch of contacts to hubspot using upsert from the contact batch api.

There are some garbage email addresses in my database. When the hubspot api encounters a bad email in the batch, it returns a 400 for a whole batch it seems.

Is there a way to get the hubspot api to just drop the contacts that fail email validation and just push the good ones through?

I’m thinking my only option is to parse the error response, drop the email from my original request, then resend the request.

Multi status errors might be my way out: Error handling - HubSpot docs

Aww nuts. I guess multi status errors isn’t my way out. A least not with my current plan to upsert by email. I get the error:

“{“status”:“error”,“message”:“Cannot perform a partial upsert with email. To get around this limitation, omit `objectWriteTraceId` and try again.”,“category”:“VALIDATION_ERROR”}”

Hi @TwoOrMore,

If you are trying to use the Contacts API, then you would need to pre-process your data and pluck out all of the records with bad email addresses before passing it along via the API call. Technically you could do an API call for each record but that would be a bit inefficient.

You could also look into the Imports API - it might be more forgiving and allow the proper records to come trhough while rejecting the invalid ones. However, you would need to use a .csv or .xlsx file instead of JSON.

Hope this helps!

Hi @TwoOrMore

HubSpot’s batch upsert will fail the whole payload if a single record violates a constraint like email format.

Multi-status isn’t available for contact upserts by email, which is why you’re seeing that VALIDATION_ERROR. The native path is to avoid email as the dedupe key for partial success and either

1) pre-clean invalid emails before calling the API or 2) switch to the Imports API, whichh accepts a CSV/XLSX and will ingest valid rows while rejecting only the bad ones with a downloadable error file

(Accounts Dashboard | HubSpot )

If you stay with Contacts API, you won’t get per-row partial success on an email-keyed upsert

A practical pattern that works nicely is to run a quick email sanity check on your side, drop non-RFC candidates from the JSON batch, and log them for remediation.

If you need true partial success without giving up JSON, create a custom unique “External ID” property on contacts, migrate your dedupe to that idProperty, then upsert on it. That avoids the strict email validation blocking the batch, and you can still write the email property when it’s valid

Does moving dedupe off email fit your constraints?

If you want zero manual cleanup, the Imports API is the most forgiving path. It will land the good contacts, provide an error report for the rejects, and you can re-queue only those rows once fixed, all within HubSpot’s supported flow (Import records for multiple objects )

If you’re juggling this across tools, Stacksync keeps HubSpot and your source in two-way sync, which prevents these clean-up cycles.