Skip to main content
These are the requirements and steps for decrypting a webhook. Every webhook Rio sends has the same two fields. data is the encrypted payload as a hex string, and iv is the initialization vector used to encrypt it, also as a hex string.
Structure of the message that our webhooks send
Secret is used to decrypt the webhook payload.
Standard decryption for aes-256-cbc using the data, the iv, and the secret returned during the webhook registration.
1

Load the secret from the webhook registration

The secret you saved when you registered the webhook is base64 encoded, so decode it into a buffer before using it as the key. If you no longer have it, it cannot be recovered and you need to register the webhook again.

Go to register a webhook

2

Converts the hexadecimal IV to a byte buffer

  • [Recommendation] Check if the key length is 32 bytes, which is the required size for the AES-256 encryption algorithm.
TypeScript Example
  • Converts the hexadecimal IV to a byte buffer. Use the iv exactly as it came in the request body, since a new one is generated for every message and the payload cannot be decrypted without the matching one.
TypeScript Example
3

Decryption

  • Creates a decryptor object using the AES-256 algorithm in CBC (Cipher Block Chaining) mode, the key and the IV.
TypeScript Example
  • Start decrypting the data and store the result.
TypeScript Example
4

Read the event

The decrypted result is a JSON string, so parse it to get the event. For an orders webhook this is the order, which means you can read its status field to react to where the order is in its lifecycle without polling.
TypeScript Example
Disclaimer: All technical documentation is subject to the terms and conditions, which apply supplementarily and take precedence over the documentation.