# Hoe integreer je Discourse Gamification met een extern systeem (punten inwisselen en toekennen)

**URL:** https://meta.discourse.org/t/how-to-integrate-discourse-gamification-with-an-external-system-redeem-and-award-points/262968
**Category:** Integrations
**Tags:** gamification
**Created:** [26 april 2023 om 17:07 UTC](https://meta.discourse.org/t/how-to-integrate-discourse-gamification-with-an-external-system-redeem-and-award-points/262968 "2023-04-26T17:07:13Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [26 april 2023 om 17:07 UTC](https://meta.discourse.org/t/how-to-integrate-discourse-gamification-with-an-external-system-redeem-and-award-points/262968/1 "2023-04-26T17:07:13Z")

</div>

Since we launched [Discourse Gamification](https://meta.discourse.org/t/discourse-gamification/225916) a year ago, one of the most requested features from our roadmap has been the ability to make it possible to integrate Discourse Gamification with external gamification system . Examples are plenty:

- Integrate with existing gamification programs in companies

- ability to award points for events that happen outside of Discourse, like IRL events, or elsewhere online, like being a customer in a community, or buying a product.

- the ability to allow users to redeem their points for swag, products or benefits

Today, just in time for the plugin’s first anniversary, we made all of the above possible with a full API to handle custom scoring events 🎉.

This new system allows admins to:

- Award users a custom score event

- Award users with negative score events, to accommodate redeem or penalties events

- Update and list custom events previously created

## API

> ⚠ Points awarded via API will take up to 1 hour to reflect on a user’s overall score for events created with the current date, and up to 24 hours for events created in the last 10 days. For events created with a date older than 10 days, you can use the **Recalculate Scores** button in the admin gamification UI, or run the backfill rake task: `rake gamification_scores:backfill_scores_from[YYYY-MM-DD]`.

There are 3 different API endpoints currently.

### List Events

Returns up to 100 events. You can filter by `id`, `user_id`, and/or `date`.

```bash
curl https://<example_url>/admin/plugins/gamification/score_events.json \
-H 'API-Key: <api_key_here>' \
-H 'API-Username: <api_username_here>'

```

You can also list specific user or date events:

```bash
curl https://<example_url>/admin/plugins/gamification/score_events.json?user_id=1&date=2023-05-01 \
-H 'API-Key: <api_key_here>' \
-H 'API-Username: <api_username_here>'

```

### Create Event

```plaintext
curl -X POST https://<example_url>/admin/plugins/gamification/score_events.json \
-H 'API-Key: <api_key_here>' \
-H 'API-Username: <api_username_here>' \
-H "Content-Type: application/json" \
-d '{
  "user_id": 13,
  "date": "2023-04-14",
  "points": 15,
  "description": "May 2023 Karaoke attendee"
}'

```

Alternate syntax using [jo](https://github.com/jpmens/jo):

```bash
jo -p user_id="13" date="2023-04-14" points="15" description="May 2023 Karaoke atendee" | curl --json @- -XPOST http://example/admin/plugins/gamification/score_events -H "Api-Key: apikeyhere" -H "Api-Username: system"

```

### Update Event

The update endpoint requires `id` and `points`. You can optionally update `description`. Note that `user_id` and `date` cannot be changed after creation.

```plaintext
curl -L -X PUT https://<example_url>/admin/plugins/gamification/score_events.json \
-H 'API-Key: <api_key_here>' \
-H 'API-Username: <api_username_here>' \
-H "Content-Type: application/json" \
-d '{
  "id": 6,
  "points": 25,
  "description": "May 2023 keynote attendee"
}'

```

Alternate syntax using [jo](https://github.com/jpmens/jo):

```bash
jo -p id="11" points="25" description="May 2023 Karaoke attendee" | curl --json @- -XPUT http://example/admin/plugins/gamification/score_events -H "Api-Key: apikeyhere" -H "Api-Username: system"

```

> Last edited by @MarkDoerr 2025-12-03T01:34:43Z
> 
> Last checked by @MarkDoerr 2025-12-19T22:30:29Z
> 
> > **Check document**
> >
> > Perform check on document:

---

_[View the full topic](https://meta.discourse.org/t/how-to-integrate-discourse-gamification-with-an-external-system-redeem-and-award-points/262968)._
