# Webhooks and signature verification

> Learn how to receive Transfer V3 webhooks, read the common notification envelope, verify signatures, and acknowledge notifications.

Transfer V3 sends webhook notifications using HTTP POST. Verify the signature before processing the business data according to the event type.

## Source IP allowlist

Onerway sends all Transfer V3 webhook notifications from the following IP addresses. If your webhook endpoint restricts source IPs, allow all addresses for the corresponding environment in your firewall, WAF, or application.

| Environment | Webhook source IPs |
| --- | --- |
| Sandbox | `27.109.125.90` |
| Production | `20.68.8.122`<br /><br>`18.207.78.37`<br /><br>`52.70.96.9`<br /><br>`54.160.200.158`<br /><br>`44.219.164.167` |

After allowing these IPs, you must still verify the notification signature as described below.

## Common notification envelope

| Field | Description |
| --- | --- |
| `requestId` | Notification request identifier. |
| `eventType` | Identifies the business event that triggered the notification. |
| `createdAt` | Event creation time. |
| `version` | Current notification message version: `V3`. |
| `data` | Business data whose field structure depends on the event type. |

Refer to the corresponding webhook API reference for each event type, its business fields, and processing requirements. For example, see the [payment webhook](/transfer/api-reference/webhooks/v3-transfer-result) for payment events.

## Headers and signature verification

| Header | Description |
| --- | --- |
| `Content-Type` | `application/json;charset=UTF-8`. |
| `x-timestamp` | Unix timestamp in seconds when this notification was generated. Included in the signing input when calculating the signature. |
| `x-signature` | HMAC-SHA256 signature encoded as a hexadecimal string. |

Preserve the original request body and calculate the signature with the corresponding notification verification key:

```text
signingInput = x-timestamp + "." + rawBody
signature = hex(HMAC-SHA256(key, signingInput))
```

Process the notification only after the result matches `x-signature`. Do not parse and serialize the JSON before verification: changes to field order, whitespace or number formatting alter the signed content. Keep the key on your server; obtain it through the configuration provided during onboarding.

## Multiple signatures

During key rotation, `x-signature` can contain multiple signatures separated by commas (,). Calculate the signature with your configured notification secret and compare it with each entry. A match with any entry passes signature verification.

## Signature test vector

The following simplified payment event demonstrates the common verification method for checking your implementation. Refer to the corresponding webhook API reference for complete business fields.

| Parameter | Example value |
| --- | --- |
| `x-timestamp` | `1792634400` |
| Notification signing key | `demo_webhook_secret` (for demonstration only) |

The raw notification body is:

```json
{
  "requestId": "demo_event_001",
  "eventType": "transfer.transaction.status.change",
  "createdAt": "2026-10-22T10:00:00",
  "version": "V3",
  "data": {
    "transferId": "demo_transfer_001",
    "status": "S"
  }
}
```

This test vector uses UTF-8 encoding, two-space indentation, and LF (`\n`) line endings, with no trailing newline. Use the exact text in the code block; do not minify or serialize the JSON again.

Build the signing input as `x-timestamp + "." + rawBody` and calculate HMAC-SHA256 with the demonstration key. The expected hexadecimal signature is:

```text
e828b5dd8e90b033f0315fe002f3d6b1d1bccdd74ed5c1b15faf7f55c1856955
```

## Code examples

These implementations calculate the signature from the received `x-timestamp` and raw HTTP request body, then securely compare it with each signature in `x-signature`. Pass the raw body, `x-timestamp`, `x-signature`, and notification signing key for the environment to the verification function. A match with any signature passes verification. Parse business data only after verification succeeds.

<code-collapse name="Code examples">
<code-group sync="webhook-verification-lang">

```php [PHP]
<?php

function verifyWebhook(
    string $rawBody,
    string $timestamp,
    string $signatureHeader,
    string $secret
): bool {
    $expected = hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret, true);
    foreach (explode(',', $signatureHeader) as $value) {
        $value = trim($value);
        if (preg_match('/\A[0-9a-fA-F]{64}\z/', $value)
            && hash_equals($expected, hex2bin($value))) {
            return true;
        }
    }
    return false;
}
```

```java [Java]
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public final class WebhookVerifier {
    public static boolean verify(
            byte[] rawBody, String timestamp, String signatureHeader,
            String secret) throws Exception {
        if (timestamp == null
                || signatureHeader == null) {
            return false;
        }

        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
        mac.update((timestamp + ".").getBytes(StandardCharsets.UTF_8));
        byte[] expected = mac.doFinal(rawBody);
        for (String entry : signatureHeader.split(",")) {
            String value = entry.trim();
            if (!value.matches("[0-9a-fA-F]{64}")) {
                continue;
            }
            byte[] supplied = new byte[32];
            for (int i = 0; i < supplied.length; i++) {
                supplied[i] = (byte) Integer.parseInt(value.substring(i * 2, i * 2 + 2), 16);
            }
            if (MessageDigest.isEqual(expected, supplied)) {
                return true;
            }
        }
        return false;
    }
}
```

```go [Go]
package webhook

import (
    "crypto/hmac"
    "crypto/sha256"
    "encoding/hex"
    "regexp"
    "strings"
)

var signaturePattern = regexp.MustCompile(`^[0-9a-fA-F]{64}$`)

func VerifyWebhook(rawBody []byte, timestamp, signatureHeader, secret string) bool {
    mac := hmac.New(sha256.New, []byte(secret))
    mac.Write([]byte(timestamp + "."))
    mac.Write(rawBody)
    expected := mac.Sum(nil)
    for _, entry := range strings.Split(signatureHeader, ",") {
        value := strings.TrimSpace(entry)
        if !signaturePattern.MatchString(value) {
            continue
        }
        supplied, err := hex.DecodeString(value)
        if err == nil && hmac.Equal(expected, supplied) {
            return true
        }
    }
    return false
}
```

```javascript [JavaScript]
import { createHmac, timingSafeEqual } from 'node:crypto';

function verifyWebhook(rawBody, timestamp, signatureHeader, secret) {
  if (typeof timestamp !== 'string'
      || typeof signatureHeader !== 'string') {
    return false;
  }

  const expected = createHmac('sha256', secret)
    .update(timestamp + '.', 'utf8')
    .update(rawBody)
    .digest();
  return signatureHeader.split(',').some((entry) => {
    const value = entry.trim();
    if (!/^[0-9a-fA-F]{64}$/.test(value)) return false;
    return timingSafeEqual(expected, Buffer.from(value, 'hex'));
  });
}
```

</code-group>
</code-collapse>

In production, pass the raw body as a string in PHP, a `byte[]` in Java, a `[]byte` in Go, or a `Buffer` in JavaScript.

## Acknowledgement and duplicate notifications

Return HTTP 2xx, such as HTTP 200, after successfully receiving and processing the notification. Request errors and non-2xx responses are treated as notification failures.

You may receive duplicate notifications for the same business event. Process notifications idempotently using the identifiers and business semantics of the specific event, and persist the result. Do not deduplicate on the business object ID alone, as that could suppress subsequent events for the same object. For out-of-order or uncertain updates, follow the corresponding event API reference to check the current business state.
