Skip to content

Import rewards

POST
/rewards
curl --request POST \
--url https://kmlrvcofvtzdlbomxrbp.supabase.co/functions/v1/external-api/rewards \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "rewards": [ { "external_id": "coffee-voucher", "name": "Coffee voucher", "description": "A coffee on us at the office café.", "points_cost": 50, "reward_type": "perk" } ] }'

Create or update rewards from another system. Rewards are matched on external_id, so you can send your whole catalogue on a schedule without creating duplicates. Send one reward, an array, or { "rewards": [...] }, at most 500 per request. Every row is validated before anything is written. Requires the write:rewards scope.

Media typeapplication/json
One of:
object
external_id
required

Your own ID for the reward. Sending the same one again updates it.

string
name
required
string
description
string
points_cost
required

Rounded to a whole number.

number
reward_type
string
default: perk
stock_count
integer
image_url
string
vendor_name
string
is_archived
boolean
Example
{
"rewards": [
{
"external_id": "coffee-voucher",
"name": "Coffee voucher",
"description": "A coffee on us at the office café.",
"points_cost": 50,
"reward_type": "perk"
}
]
}

The rewards that were created or updated.

Media typeapplication/json
object
imported
integer
rewards
Array<object>
object
id
string format: uuid
external_id
string
name
string
points_cost
integer
is_archived
boolean
Example
{
"imported": 1
}

The body is not valid JSON, is empty, has more than 500 rewards, or a row is invalid. Nothing was written.

Media typeapplication/json
object
error
string
Example
{
"error": "rewards[2]: points_cost must be a number of 0 or more"
}

The key is missing, malformed or revoked.

Media typeapplication/json
object
error
string
Example
{
"error": "Unauthorized: Invalid or missing API Key"
}

The key works but does not have the scope this endpoint needs.

Media typeapplication/json
object
error
string
Example
{
"error": "Forbidden: this key is missing the \"read:members\" scope"
}

Something went wrong on our side. The response does not include details.

Media typeapplication/json
object
error
string
Example
{
"error": "Internal Server Error"
}