Many parts of Anvilize 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
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-Anvilize-Webhook-Version: 1

X-Anvilize-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": 1796199729,
  "nonce": "ILihHQNkMWnGIBE-",
  "payload": <...>
}
Putting it all together, this is what a full valid request to https://example.com/polymartWebhook might look like, given the webhook secret tqbXKZjxviiSQnqZ
POST /polymartWebhook HTTP/1.1
X-Anvilize-Webhook-Version: 1
X-Anvilize-Signature: 2883af473c9e490921e6eb3efb4674bd918a23d48f96bae801af0e3b7020c8e3
Content-Type: application/json
Content-Length: 166

{
    "event": "testEvent",
    "time": 1796199729,
    "nonce": "t6EfZntlN2_kK9yY",
    "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": 1796199729,
  "nonce": "MDQEkuP3rP3BOPBq",
  "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 tqbXKZjxviiSQnqZ, then the signature of this request will be f6edb0e3c5deeb6367495525ed72b45c4a610e9124a89e2cb922d2993cd73e71
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": 1796199729,
  "nonce": "6Zcj1gJpZP8SWR6W",
  "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": 1796196129,
      "size": "716624",
      "fileType": "jar",
      "branch": "snapshot"
    },
    "update": {
      "version": "3.0",
      "id": "107",
      "time": 1796199729,
      "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 tqbXKZjxviiSQnqZ, then the signature of this request will be 362bf3bd5745cb5007244c920460f5548a5f19c1e9e5d5ea45fb9710dc52b006
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": 1796199729,
  "nonce": "LjgAA45scYUZj1lF",
  "payload": {
    "product": {
      "id": "1",
      "title": "CustomItems",
      "subtitle": "Design new Custom items and blocks!",
      "url": "https://anvilize.com/resource/1"
    },
    "user": {
      "id": 17962
    }
  }
}

If your webhook secret is tqbXKZjxviiSQnqZ, then the signature of this request will be 4e949b12595951969dcc68482e76c5959198e01a2b9e3966b2dc444d34a67d9c
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": 1796199729,
  "nonce": "zzjtcqtQbbnSKGkZ",
  "payload": {
    "product": {
      "id": "1",
      "title": "CustomItems",
      "subtitle": "Design new Custom items and blocks!",
      "url": "https://anvilize.com/resource/1"
    },
    "user": {
      "id": 58831
    }
  }
}

If your webhook secret is tqbXKZjxviiSQnqZ, then the signature of this request will be d1121182f469782c6d60b02def128daf4116ccfd461954113d83e5caad9272d8
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": 1796199729,
  "nonce": "wOS8lMNiDuBTLNyZ",
  "payload": {
    "product": {
      "id": "1",
      "title": "CustomItems",
      "subtitle": "Design new Custom items and blocks!",
      "url": "https://anvilize.com/resource/1"
    },
    "user": {
      "id": 172314
    }
  }
}

If your webhook secret is tqbXKZjxviiSQnqZ, then the signature of this request will be 176ddd632d0987ae402db6d2458e496aa4b003fbe1c7019b149d79a3cb274f9c
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": 1796199729,
  "nonce": "HWweONmweohzC2Bl",
  "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 tqbXKZjxviiSQnqZ, then the signature of this request will be 169a631327334d3e3a701a056e3434e350c0c702203055fb67e0b8f21c70194b
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": 1796199729,
  "nonce": "P3Fe6CKSrE26RyIn",
  "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 tqbXKZjxviiSQnqZ, then the signature of this request will be f73cfd16267eeabca7732c40bb8e6b7503a3168ed36b626e0d54054bbff36f5c