Import rewards
const url = 'https://kmlrvcofvtzdlbomxrbp.supabase.co/functions/v1/external-api/rewards';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"rewards":[{"external_id":"coffee-voucher","name":"Coffee voucher","description":"A coffee on us at the office café.","points_cost":50,"reward_type":"perk"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Your own ID for the reward. Sending the same one again updates it.
Rounded to a whole number.
object
Your own ID for the reward. Sending the same one again updates it.
Rounded to a whole number.
object
object
Your own ID for the reward. Sending the same one again updates it.
Rounded to a whole number.
Example
{ "rewards": [ { "external_id": "coffee-voucher", "name": "Coffee voucher", "description": "A coffee on us at the office café.", "points_cost": 50, "reward_type": "perk" } ]}Responses
Section titled “ Responses ”The rewards that were created or updated.
object
object
Example
{ "imported": 1}The body is not valid JSON, is empty, has more than 500 rewards, or a row is invalid. Nothing was written.
object
Example
{ "error": "rewards[2]: points_cost must be a number of 0 or more"}The key is missing, malformed or revoked.
object
Example
{ "error": "Unauthorized: Invalid or missing API Key"}The key works but does not have the scope this endpoint needs.
object
Example
{ "error": "Forbidden: this key is missing the \"read:members\" scope"}Something went wrong on our side. The response does not include details.
object
Example
{ "error": "Internal Server Error"}