Motivation

If you run a social media challenge or a reward campaign, someone has to check every entry. Did this person post the video? Did they use the campaign hashtag? Did they tag the brand? Did they post it while the campaign was running?

Doing that by hand works for 20 entries and falls apart at 2,000. So in this post we will validate UGC challenge entries with a small Node JS script.

Introduction

People submit a handle and a post link through your form. For each entry the script checks four things:

  • Author: the post belongs to the handle they gave you.
  • Hashtag: the post uses your campaign hashtag.
  • Tag: the post mentions your brand account (optional).
  • Date: the post went up during the campaign.

Each entry ends up as approve, reject or review. That third result is important. If a platform doesn't give us a value, we can't say the rule failed, so a person should look at it instead of a real entry getting rejected automatically.

I am using TrueScrape to read the posts. I built it, so keep that in mind. It reads public posts only with no login, and you can use any data source that returns the same fields.

Installation

There is nothing to install, you just need Node 18 or above. Get an API key from TrueScrape and set it in your terminal:

export TRUESCRAPE_API_KEY=your_key 

Step 1: Create the API Helper

Create a file called validate.mjs and add this. We keep the error code because the check needs it later.

async function api(path, params) { const url = new URL(`https://api.truescrape.com/v1${path}`); url.search = new URLSearchParams(params); const res = await fetch(url, { headers: { 'x-api-key': process.env.TRUESCRAPE_API_KEY }, }); const json = await res.json(); if (!json.success) { const error = new Error(json.error.message); error.code = json.error.code; throw error; } return json; } function getPost(url) { return new URL(url).hostname.includes('tiktok') ? api('/tiktok/video', { url }) : api('/instagram/post', { url }); } 

Step 2: Check Hashtags and Tags

People type #NikeRunning and #nikerunning, so compare in lowercase. We also check the caption text in case the hashtag list comes back empty.

function hasTag(list, text, tag, symbol) { const wanted = tag.toLowerCase(); if (list.some((item) => item.toLowerCase() === wanted)) return true; return new RegExp(`${symbol}${wanted}\\b`, 'i').test(text ?? ''); } 

Step 3: Validate the Entry

This is the main function. Read through the two early returns, they are what keep real entries safe.

async function checkEntry(entry, rules) { let post; try { ({ data: post } = await getPost(entry.url)); } catch (error) { if (error.code === 'upstream_not_found') { return { status: 'reject', reasons: ['post is missing, private or removed'] }; } return { status: 'review', reasons: [`could not check: ${error.code}`] }; } if (!post.authorHandle) { return { status: 'review', reasons: ['post has no readable details'] }; } const failed = []; const unsure = []; if (post.authorHandle.toLowerCase() !== entry.handle.toLowerCase()) { failed.push(`posted by @${post.authorHandle}, not @${entry.handle}`); } if (!hasTag(post.hashtags, post.text, rules.hashtag, '#')) { failed.push(`missing #${rules.hashtag}`); } if (rules.mention && !hasTag(post.mentions, post.text, rules.mention, '@')) { failed.push(`missing @${rules.mention}`); } if (!post.publishedAt) { unsure.push('post date not available'); } else if (new Date(post.publishedAt) < new Date(rules.start) || new Date(post.publishedAt) > new Date(rules.end)) { failed.push(`posted outside the campaign: ${post.publishedAt}`); } if (failed.length > 0) return { status: 'reject', reasons: failed }; if (unsure.length > 0) return { status: 'review', reasons: unsure }; return { status: 'approve', reasons: [] }; } 

Two cases go to review on purpose:

  • We could not reach the platform. A timeout says nothing about the entry.
  • The post came back with no details. In my testing, a TikTok video that doesn't exist returned a successful response with empty fields and no error, which is why we check authorHandle first.

Usage

Set your campaign rules and run your entries through it. I am using a real Nike video here so you can run it as is.

const rules = { hashtag: 'nikerunning', mention: null, // set this to your brand handle to require a tag start: '2026-10-01T00:00:00Z', end: '2026-11-30T23:59:59Z', }; const video = 'https://www.tiktok.com/@nike/video/7702980951252471053'; console.log(await checkEntry({ handle: 'nike', url: video }, rules)); console.log(await checkEntry({ handle: 'adidas', url: video }, rules)); 

Now run it:

node validate.mjs 

and you will get this output:

{ status: 'approve', reasons: [] } { status: 'reject', reasons: [ 'posted by @nike, not @adidas' ] } 

that's it, your entries are validated.

Things to Check Before You Pay Rewards

  • Check again before paying. People can edit or delete a post after approval, so run the winners through the same check on the last day.
  • Rules beyond these need a person. This script can't tell you if a video is good, or if it is really the participant in it.
  • Hashtags can change meaning. Use a campaign hashtag that is unique to you, because a common one will pull in unrelated posts.
  • Cost. Each check is 1 credit, and a failed check is free.

Frequently Asked Questions

Can I validate private accounts?
No. Only public posts can be read, so make "keep your account public until the campaign ends" one of your campaign rules.

Does this work without the entry form?
Yes, you can find entries from the hashtag instead. A later post in this series covers that, and also why you should still validate each result.

Thanks for reading, try it out once. Cheers.