Open the panel

Send Prizes to Winners PRO ​

You run a contest on Discord or in your group, and you want the prize to arrive by itself. There are three kinds of prize.

PrizeRouteScope
A product from your hubPOST /products/{id}/senddeliveries:write
Store creditPOST /gift-cardsgift_cards:write
A discount codePOST /couponscoupons:write

Send a product ​

Delivers for free through your hubs, like Send to someone in the panel. It shows in your sales as a L$ 0 sale.

js
const BASE = 'https://api.fastyvendor.com/api/v1'

async function sendPrize(productId, username, contestId) {
  const res = await fetch(`${BASE}/products/${productId}/send`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.FASTY_KEY}`,
      'Content-Type': 'application/json',
      'Idempotency-Key': `contest-${contestId}-${username}`,
    },
    body: JSON.stringify({ username }),
  })
  const data = await res.json()
  if (!res.ok) throw new Error(data.error.message)
  return data
}

await sendPrize('prd_mxbjm9xtpchmet', 'luna.caelum', 'halloween')
python
import os, requests

BASE = "https://api.fastyvendor.com/api/v1"

def send_prize(product_id, username, contest_id):
    res = requests.post(
        f"{BASE}/products/{product_id}/send",
        headers={
            "Authorization": f"Bearer {os.environ['FASTY_KEY']}",
            "Idempotency-Key": f"contest-{contest_id}-{username}",
        },
        json={"username": username},
    )
    data = res.json()
    if not res.ok:
        raise Exception(data["error"]["message"])
    return data

send_prize("prd_mxbjm9xtpchmet", "luna.caelum", "halloween")
lsl
string body = llList2Json(JSON_OBJECT, ["avatar_key", (string)winner]);

llHTTPRequest(API + "/products/" + PRIZE + "/send",
    [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/json",
     HTTP_CUSTOM_HEADER, "Authorization", "Bearer " + KEY,
     HTTP_CUSTOM_HEADER, "Idempotency-Key", "contest-1-" + (string)winner],
    body);

Two answers mean success:

StatusMeaning
201Sent. You get the sale_id.
202With username only: Second Life hasn't confirmed who that is yet. The send is saved and goes out by itself.

The winner doesn't need to be online. The hub delivers when they are.

Always send an Idempotency-Key

Without one, a retry after a timeout sends the prize twice.

Give store credit ​

The avatar gets an IM in Second Life, and the balance works at your vendors. Use days for a prize that expires.

bash
curl -X POST "https://api.fastyvendor.com/api/v1/gift-cards" \
  -H "Authorization: Bearer $FASTY_KEY" \
  -H "Idempotency-Key: contest-halloween-a1b2c3d4" \
  -H "Content-Type: application/json" \
  -d '{"owner_key": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d", "value": 250, "days": 90, "note": "Contest prize"}'

Give a discount code ​

A personal coupon only works for the avatars you list. With notify, they get the code by IM:

bash
curl -X POST "https://api.fastyvendor.com/api/v1/coupons" \
  -H "Authorization: Bearer $FASTY_KEY" \
  -H "Idempotency-Key: contest-halloween-coupon" \
  -H "Content-Type: application/json" \
  -d '{"name": "Halloween winner", "kind": "percent", "value": 50, "avatars": ["a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"], "notify": true}'

Giving codes to a crowd? A batch creates up to 500 single-use codes, and the answer lists them all:

bash
curl -X POST "https://api.fastyvendor.com/api/v1/coupons" \
  -H "Authorization: Bearer $FASTY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Event", "kind": "percent", "value": 20, "batch": {"prefix": "EVENT", "count": 100}}'

Details: Deliveries, Gift Cards and Coupons.