Automatic Discord Integration
Minecraft Marketplace automatically integrates with Discord webhooks. However, this doesn't give you nearly as much customization as if you build your own API for receiving webhooks. If you want to learn more about how to build your own API for receiving webhooks, keep reading!
Webhook Overview
ping — Sent whenever you click the "ping" button on your resource's webhooks page
product.update — Sent whenever you post an update to your resource
product.user.purchase — Sent when a user purchases your resource
product.user.purchaseRemoved — Sent when a user issues a chargeback or is refunded
product.user.firstDownload — Sent when a user first downloads your resource
About Webhooks
When a webhook event is called, Minecraft Marketplace will send a request to the URL you provide on your resource page. With each request, the following headers will be sent:
X-Polymart-Webhook-Version: 1
X-Polymart-Signature will be a signature that verifies that the webhook request is in-fact valid. This is a
SHA256 HMAC hash, where the data is the data that was POSTed, and the key is your webhook secret. Your webhook secret generated when you
create a new webhook. YOU MUST VALIDATE THAT THIS IS CORRECT. If you do not, attackers will
easily be able to send random, invalid webhooks to your server
The data that is POSTed to your webhook will be in this format
{
"event": <event type>,
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
<key 1>: <val 1>,
<key 2>: <val 2>,
<...>: <...>
}
} So, the top-level information might look something like this
{
"event": "product.update",
"time": 1793077900,
"nonce": "gpHvR_ceajyXF1aA",
"payload": <...>
} Putting it all together, this is what a full valid request to https://example.com/polymartWebhook might look like, given the webhook secret cjADXfSJvyD3Fgod
POST /polymartWebhook HTTP/1.1
X-Polymart-Webhook-Version: 1
X-Polymart-Signature: f9b1bc9247ecfad6019996dc900abd80a6babfd9b76a6964dbbda75e39f7ded7
Content-Type: application/json
Content-Length: 166
{
"event": "testEvent",
"time": 1793077900,
"nonce": "0YKcobxHM-GmsiGd",
"payload": {
"webhook": "https://example.com/polymartWebhook"
}
}
ping Back to top
Use this to test your webhook! This webhook event is called when you click the "send a ping" button on your resource's webhooks page.
Format
{
"event": "ping",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <resource id>,
"title": <resource title>,
"subtitle": <resource subtitle>,
"url": <resource url>
},
"webhook": {
"url": <your webhook url>
}
}
}
Example
If your webhook secret is
{
"event": "ping",
"time": 1793077900,
"nonce": "gt6bdHp2eaRzuml0",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://polymart.org/resource/1"
},
"webhook": {
"url": "https://example.com/polymartWebhook"
}
}
}If your webhook secret is
cjADXfSJvyD3Fgod, then the signature of this
request will be cd4f48c2c90a54d51818f46ae4ec159d6a3bc2240f89129932e80c2b717d71d9 product.update Back to top
This webhook event is called when your resource is updated.
Format
{
"event": "resource.update",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <resource id>,
"title": <resource title>,
"subtitle": <resource subtitle>,
"url": <resource url>
},
"previous": {
"version": <old version>,
"id": <old version ID>,
"time": <old version update time>,
"size": <old size>,
"fileType": <old file type>,
"branch": <beta|snapshot|release>
},
"update": {
"version": <new version>,
"id": <new version ID>,
"time": <update time>,
"size": <new size>,
"fileType": <new file type>,
"branch": <beta|snapshot|release>,
"title": <update title>,
"description": <update description>
}
}
}
Example
If your webhook secret is
{
"event": "product.update",
"time": 1793077900,
"nonce": "_R9owc2aRrE6Ufhh",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://polymart.org/resource/1"
},
"previous": {
"version": "2.19.5",
"id": "91",
"time": 1793074300,
"size": "716624",
"fileType": "jar",
"branch": "snapshot"
},
"update": {
"version": "3.0",
"id": "107",
"time": 1793077900,
"size": "718232",
"fileType": "jar",
"branch": "release",
"title": "Automatic Resource Pack Generation",
"description": "This version adds an automatic resource pack generator to CustomItems!"
}
}
}If your webhook secret is
cjADXfSJvyD3Fgod, then the signature of this
request will be 743aef78b79321a3a47688f7b9bad6252c9890669edddd091794550e135b1c45 product.user.purchase Back to top
This webhook event is called when a user purchases your resource
Format
{
"event": "product.user.purchase",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <resource id>,
"title": <resource title>,
"subtitle": <resource subtitle>,
"url": <resource url>
},
"user": {
"id": <user id>
}
}
}
Example
If your webhook secret is
{
"event": "product.user.purchase",
"time": 1793077900,
"nonce": "0n2ah3a0FUinDYBf",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://polymart.org/resource/1"
},
"user": {
"id": 160341
}
}
}If your webhook secret is
cjADXfSJvyD3Fgod, then the signature of this
request will be c47202b2edd012f2951d2104c064480f7444cf111add6933b9f54fd989d1b9ff product.user.purchaseRemoved Back to top
This webhook event is called when you issue a refund to a user, or they issue a chargeback. This event may be called more than once for a given user
Format
{
"event": "product.user.purchaseRemoved",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <resource id>,
"title": <resource title>,
"subtitle": <resource subtitle>,
"url": <resource url>
},
"user": {
"id": <user id>
}
}
}
Example
If your webhook secret is
{
"event": "product.user.purchaseRemoved",
"time": 1793077900,
"nonce": "4a8UnS8TfJTSj6WP",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://polymart.org/resource/1"
},
"user": {
"id": 130171
}
}
}If your webhook secret is
cjADXfSJvyD3Fgod, then the signature of this
request will be 04e8d85e9b58b2677ffc70d61256a20d0dbb19bc2ff8206e2a0e82f192a68fb8 product.user.firstDownload Back to top
This webhook event is called when a user downloads your resource for the first time
Format
{
"event": "product.user.firstDownload",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <resource id>,
"title": <resource title>,
"subtitle": <resource subtitle>,
"url": <resource url>
},
"user": {
"id": <user id>
}
}
}
Example
If your webhook secret is
{
"event": "product.user.firstDownload",
"time": 1793077900,
"nonce": "b4WKDKefaFzXE6Ri",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://polymart.org/resource/1"
},
"user": {
"id": 105770
}
}
}If your webhook secret is
cjADXfSJvyD3Fgod, then the signature of this
request will be 69d585c472823ec588a72435f616ad3b49396e55217294de50a28ed07fb67a7b