Automatic Discord Integration
Anvilize 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
product.addon.new — Sent when an add-on is listed in your resource's add-on hub
product.addon.update — Sent when an add-on in your resource's add-on hub posts a release
About Webhooks
When a webhook event is called, Anvilize 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 is 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": 1796198882,
"nonce": "_t0uMNi_e8y1tBM3",
"payload": <...>
} Putting it all together, this is what a full valid request to https://example.com/polymartWebhook might look like, given the webhook secret GpiIBCNv_w9upHKy POST /polymartWebhook HTTP/1.1
X-Polymart-Webhook-Version: 1
X-Polymart-Signature: 0d2935d911dcd42bdda61e1769c43b33905cd5dd58afce6f966fb9ed3813cd95
Content-Type: application/json
Content-Length: 166
{
"event": "testEvent",
"time": 1796198882,
"nonce": "puGJ5QrwSGm8B9fh",
"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": 1796198882,
"nonce": "PI2JjCxKUQg101Td",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://anvilize.com/resource/1"
},
"webhook": {
"url": "https://example.com/polymartWebhook"
}
}
}If your webhook secret is
GpiIBCNv_w9upHKy, then the signature of this request will be e4b1b847b1fd5b20c6d1054d0e203c0464fb8d16ed5831fee3840918cb2b3e01 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": 1796198882,
"nonce": "1cyqkHwtDB2XqU3e",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://anvilize.com/resource/1"
},
"previous": {
"version": "2.19.5",
"id": "91",
"time": 1796195282,
"size": "716624",
"fileType": "jar",
"branch": "snapshot"
},
"update": {
"version": "3.0",
"id": "107",
"time": 1796198882,
"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
GpiIBCNv_w9upHKy, then the signature of this request will be db66f82d2936e74bb86cd826329def7165e8eb4bae4257b10f2eaebd428d64cc 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": 1796198882,
"nonce": "gZ7kF5Kc5ucym28g",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://anvilize.com/resource/1"
},
"user": {
"id": 130741
}
}
}If your webhook secret is
GpiIBCNv_w9upHKy, then the signature of this request will be 844b660fdf9c8530a3b8a690b50065521102d259d05c943994a782b8900bb5ab 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": 1796198882,
"nonce": "uPIFjMZQMyW5bmxl",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://anvilize.com/resource/1"
},
"user": {
"id": 140119
}
}
}If your webhook secret is
GpiIBCNv_w9upHKy, then the signature of this request will be d583c94b86850e21d84837d5fddf001319cd8433a456fa857f0d4de4cf5a3349 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": 1796198882,
"nonce": "9-MLqFzyeusw-8fU",
"payload": {
"product": {
"id": "1",
"title": "CustomItems",
"subtitle": "Design new Custom items and blocks!",
"url": "https://anvilize.com/resource/1"
},
"user": {
"id": 144036
}
}
}If your webhook secret is
GpiIBCNv_w9upHKy, then the signature of this request will be bf77cc588b35f689d1dd8a08e4b3d7270dd5ed04404294bb2990aab1e8dd59ef product.addon.new Back to top
This webhook event is called when an add-on is listed in your resource's add-on hub, either straight away or once you approve it. Turn on the Add-ons option for the webhook to receive it
Format
{
"event": "product.addon.new",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <your resource's id>,
"title": <your resource's title>
},
"addon": {
"id": <add-on id>,
"title": <add-on title>,
"subtitle": <add-on subtitle>,
"url": <add-on url>,
"version": <new version, or null for product.addon.new>
}
}
}
Example
If your webhook secret is
{
"event": "product.addon.new",
"time": 1796198882,
"nonce": "0S0-0pNS0YR5s6N8",
"payload": {
"product": {
"id": 1,
"title": "CustomItems"
},
"addon": {
"id": 2,
"title": "Fantasy Weapons Pack",
"subtitle": "Forty new swords and bows",
"url": "https://anvilize.com/resource/2",
"version": null
}
}
}If your webhook secret is
GpiIBCNv_w9upHKy, then the signature of this request will be 5b44f66f4049d9aee5183a5e3fafe189c95fe4baf04550abcce866a072432ae0 product.addon.update Back to top
This webhook event is called when an add-on in your resource's add-on hub posts a new release. Turn on the Add-ons option for the webhook to receive it
Format
{
"event": "product.addon.update",
"time": <current unix time>,
"nonce": <random nonce>,
"payload": {
"product": {
"id": <your resource's id>,
"title": <your resource's title>
},
"addon": {
"id": <add-on id>,
"title": <add-on title>,
"subtitle": <add-on subtitle>,
"url": <add-on url>,
"version": <new version, or null for product.addon.new>
}
}
}
Example
If your webhook secret is
{
"event": "product.addon.update",
"time": 1796198882,
"nonce": "Uh1-zzwOjqrN3tRQ",
"payload": {
"product": {
"id": 1,
"title": "CustomItems"
},
"addon": {
"id": 2,
"title": "Fantasy Weapons Pack",
"subtitle": "Forty new swords and bows",
"url": "https://anvilize.com/resource/2",
"version": "1.2.0"
}
}
}If your webhook secret is
GpiIBCNv_w9upHKy, then the signature of this request will be 7b84d9f7adcdec14b70d59339754e569de1434204bf56997943b89369719fc7e