One or more pre-hashed records is not in the correct format. Pre-hashed records should be in hex and hashed using SHA256

tailored-audiences
error-codes
api

#1

My current task right now is making sure that audience uploads succeed.
I’m currently trying to do test cases, testing manual uploads against uploads against the API.

I can manually upload a CSV of email addresses fine.
When I upload any audience via API, I get “Audience Too Small”. (I’m uploading a list of 95k email addresses, so I hope there’s at least 500 matches).
However, when I try to upload a CSV of hashed email addresses, I receive the following error:
One or more pre-hashed records is not in the correct format. Pre-hashed records should be in hex and hashed using SHA256.

I’ve tried hashing the email addresses, and hex encoding the email addresses then hashing. Both give me this error. Here is what I’m using to normalize and hash (PHP)

$normalized_email = strtolower(trim($email));
$hashed_email = hash(“sha256”,$normalized_email);

Is there another step missing here? https://business.twitter.com/help/tailored-audiences and https://dev.twitter.com/ads/audiences/file-data do not mention any kind of hex-related step. Specifically:
Email Addresses:

lowercase, remove leading and trailing spaces; ex: support@twitter.com

I assume that whatever is preventing me from manually uploading is also what is preventing my audience size from increasing. Can anyone provide any insight?


#2

Hi @silverpop_ea! I use:

// trim leading and trailing whitespace
$normalized_email = strtolower(trim($email, " \t\r\n\0\x0B."));
$normalized_email = hash('sha256', $normalized_email);

Also, make sure you don’t have any blank “emails”, i.e. that !!$normalized_email is true after trimming it like above.


#3

Unfortunately I’m still seeing the same results from the manual upload with that code…