Many parts of Polymart require JavaScript to function correctly.
Click here to enable JavaScript.

Webhooks

You can edit webhooks on your resource by going to your resource page and clicking the "Webhooks" button in the edit section.

Automatic Discord Integration
Polymart 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, Polymart 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": 1796198890,
  "nonce": "mooB3J-Pc8q_LgcB",
  "payload": <...>
}
Putting it all together, this is what a full valid request to https://example.com/polymartWebhook might look like, given the webhook secret UxZ0AHT14b7PzAIu
POST /polymartWebhook HTTP/1.1
X-Polymart-Webhook-Version: 1
X-Polymart-Signature: 3250c3839bfbeab4029a068702f6c73278fbb3873a3cb65606494157d8be185b
Content-Type: application/json
Content-Length: 166

{
    "event": "testEvent",
    "time": 1796198890,
    "nonce": "oHNTWR3FzWMbUhSZ",
    "payload": {
        "webhook": "https://example.com/polymartWebhook"
    }
}
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
{
  "event": "ping",
  "time": 1796198890,
  "nonce": "oNe6X3aNFmT3v3iX",
  "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 UxZ0AHT14b7PzAIu, then the signature of this request will be ea80f1db888c84bbc5f04b6db08df843ee3e20e11f9c7fd7edbea74c0aeae4c3
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
{
  "event": "product.update",
  "time": 1796198890,
  "nonce": "f8QImi4ikmLyDr9X",
  "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": 1796195290,
      "size": "716624",
      "fileType": "jar",
      "branch": "snapshot"
    },
    "update": {
      "version": "3.0",
      "id": "107",
      "time": 1796198890,
      "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 UxZ0AHT14b7PzAIu, then the signature of this request will be abb36022e2c455cc50f86a1cde0d17a0ee66c2a344bc1aad265c4a9a4479a790
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
{
  "event": "product.user.purchase",
  "time": 1796198890,
  "nonce": "ftaY-UeBsz0UC0dU",
  "payload": {
    "product": {
      "id": "1",
      "title": "CustomItems",
      "subtitle": "Design new Custom items and blocks!",
      "url": "https://anvilize.com/resource/1"
    },
    "user": {
      "id": 165378
    }
  }
}

If your webhook secret is UxZ0AHT14b7PzAIu, then the signature of this request will be 7aab176c6fdb667690b4a41d6876139ecd788a3e130be9c24272d2ace4204a41
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
{
  "event": "product.user.purchaseRemoved",
  "time": 1796198890,
  "nonce": "JZ7LywI5-JAN43oC",
  "payload": {
    "product": {
      "id": "1",
      "title": "CustomItems",
      "subtitle": "Design new Custom items and blocks!",
      "url": "https://anvilize.com/resource/1"
    },
    "user": {
      "id": 37447
    }
  }
}

If your webhook secret is UxZ0AHT14b7PzAIu, then the signature of this request will be 07ce5f513c5e0851e6379337a9b9bf8dd03002794ba472bfb595522f1e0c3dad
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
{
  "event": "product.user.firstDownload",
  "time": 1796198890,
  "nonce": "Z-wmnPCcPtcHkjM5",
  "payload": {
    "product": {
      "id": "1",
      "title": "CustomItems",
      "subtitle": "Design new Custom items and blocks!",
      "url": "https://anvilize.com/resource/1"
    },
    "user": {
      "id": 67585
    }
  }
}

If your webhook secret is UxZ0AHT14b7PzAIu, then the signature of this request will be ab50167f309498773b4ea74cb0c8bb452f22a3d60bf2660eacf5d1e05dc6668c
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
{
  "event": "product.addon.new",
  "time": 1796198890,
  "nonce": "xjnXw6uj7tDIIW-6",
  "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 UxZ0AHT14b7PzAIu, then the signature of this request will be 904ccd67a9261aa220df6e6024907336b1aa860d9a956d346f18042b5a29afcc
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
{
  "event": "product.addon.update",
  "time": 1796198890,
  "nonce": "CP0eai4n92a6Z7mU",
  "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 UxZ0AHT14b7PzAIu, then the signature of this request will be 2ca48920cecd17e4eaf94cb8483e74791ec8f697b950b060b82964b3d54e9b30