Publishers · Rewards & security

Reward URL (server callback)

Give rewards safely: Adsun calls your server after a verified watch or task.

The Reward URL is an address on your server. Adsun calls it when a user really finished a Reward ad or a Task. This is the only safe way to give rewards that have value.

How it works

  1. User watches the full ad in your app.
  2. Adsun's server checks the watch (time, Telegram signature, anti-fraud).
  3. Adsun sends a GET request to your Reward URL with the user's Telegram ID.
  4. Your server adds the reward to that user.

Set it up

In the panel: Platform → Block → Edit → Reward URL. Use placeholders that Adsun replaces:

PlaceholderReplaced with
[userId]Telegram user ID
[blockId]Your block ID
[timestamp]Time of the reward in seconds (Unix) — use it to reject duplicates

The same placeholders also work with curly braces: {userId}, {blockId}, {timestamp}.

https://mygame.com/api/adsun-reward?userid=[userId]&block=[blockId]

Adsun also adds user and block query parameters automatically.

Example server

app.get("/api/adsun-reward", async (req, res) => {
  const userId = String(req.query.userid || "");
  if (!/^\d+$/.test(userId)) return res.status(400).send("bad user");

  // Optional: protect with a secret in the URL, e.g. &key=MY_SECRET
  await db.users.increment({ telegramId: userId }, "coins", 100);
  res.send("ok");
});

Good practice

  • Add a secret parameter to the URL (&key=abc123) and check it.
  • Return 200 quickly — do heavy work in the background.
  • Then refresh the balance in your app (e.g. in onReward).

INFO

The Reward URL is never called in debug mode.

Still stuck? Write to support@adsun.io or our Telegram support — we answer fast.