Skip to main content

Webhooks

RapidCompact uses webhooks to notify your application when an event happens in your account. Webhooks are particularly useful for upload and optimization events. Instead of polling the API to know the status of your upload or optimization, RapidCompact sends an event to your webhook.

Begin using webhooks with your RapidCompact integration in just three steps:

  1. Create a webhook endpoint on your server
  2. Register the endpoint with RapidCompact to go live
  3. Test your endpoint by clicking the test button in the webhooks page

What are webhooks

The webhook endpoint is just more code on your server, which could be written in Ruby, PHP, Node.js, or whatever. The webhook endpoint has an associated URL (e.g., https://example.com/webhooks). The RapidCompact notifications are Event objects sent as POST requests (Fire-and-forget, no retry). This Event object contains all the relevant information about what just happened, including the type of event and the data associated with that event. The webhook endpoint uses the event details to take any required actions, such as indicating that an optimization should be done.

Validation

In order to validate an incoming webhook event you need to first set up a secret when creating it on RapidCompact. This secret will be used to sign the body and send the signature as part of the requests header. You can use this secret on your receiving endpoint to validate the content of the body by signing it with the same secret. For an example check out this repository: https://github.com/DGG3D/webhook-api-example

Optimization Events

RapidCompact sends the "optimization_finished" event. You can see an example on the right side

  {
"event_type": "optimization_finished",
"timestamp": "2023-01-19T15:03:08.076920Z",
"data": {
"status": "Successful",
"message": "Optimization has ended and your rapid model is available to download.",
"rawmodel_id": 1961,
"rapidmodel_id": 4213,
"rapidmodel": {
"rapid.glb": "link to rapid model"
}
}
}

Upload Events

RapidCompact sends an "analysis_finished" event when your uploaded model has been finished being analyzed and is now ready to be optimized. You can see an two examples for the successful and failed state on the right side.

For uploaded zip files RapidCompact sends an "unzip_finished" event when your model has been finished being unzipped and is going to be analysed next. You can see an two examples for the successful and failed state on the right side.

  {
"event_type": "analysis_finished",
"timestamp": "2023-01-02T15:03:08.076920Z",
"data": {
"status": "Successful",
"message": "Model analysis has ended and your base asset is ready to be optimized.",
"rawmodel_id": 1961,
}
}
  {
"event_type": "analysis_finished",
"timestamp": "2023-01-02T15:03:08.076920Z",
"data": {
"status": "Failed",
"message": "Analysis failed",
"rawmodel_id": 1961,
}
}
  {
"event_type": "unzip_finished",
"timestamp": "2024-01-02T15:03:08.076920Z",
"data": {
"status": "Successful",
"message": "Model successfully unzipped.",
"rawmodel_id": 1961,
}
}
  {
"event_type": "unzip_finished",
"timestamp": "2024-01-02T15:03:08.076920Z",
"data": {
"status": "Failed",
"message": "Unzip failed",
"rawmodel_id": 1961,
}
}