> ## Documentation Index
> Fetch the complete documentation index at: https://www.vobiz.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Validate Vobiz Webhook Signatures (HMAC)

> Every Vobiz callback includes HMAC-SHA256 signatures in request headers. Learn how to verify them in Python, Node.js, and Go to prevent spoofed or tampered webhooks.

Every callback Vobiz sends to your endpoint includes HMAC signatures in the request headers. Validating them proves the request came from Vobiz. The signatures differ in what they protect: only V1 covers the callback parameters (see [What each signature covers](#what-each-signature-covers)).

> [!NOTE]
>
> **Your auth token is the signing key, and there is nothing to set up.** Vobiz signs every callback automatically with your account's auth token (visible in the [Vobiz Console](https://console.vobiz.ai)). There are no separate callback credentials or shared secrets to configure. Keep the auth token secret - anyone who has it can forge valid signatures. If you rotate it, signatures switch to the new token.

## Signature headers

Vobiz sends the following headers with every callback:

| Header | Description |
| - | - |
| `X-Vobiz-Signature` | V1 - HMAC-SHA1, base64-encoded. The only signature that covers the callback parameters |
| `X-Vobiz-Signature-V2` | V2 - HMAC-SHA256, base64-encoded |
| `X-Vobiz-Signature-V2-Nonce` | Random 20-digit nonce used to produce the V2 signature |
| `X-Vobiz-Signature-MA-V2` | V2 signed with the **parent (main) account** auth token. Always sent; for a main account it equals `X-Vobiz-Signature-V2` |
| `X-Vobiz-Signature-V3` | V3 - HMAC-SHA256, base64-encoded |
| `X-Vobiz-Signature-V3-Nonce` | Random 20-digit nonce used to produce the V3 signature |
| `X-Vobiz-Signature-MA-V3` | V3 signed with the **parent (main) account** auth token. Always sent; for a main account it equals `X-Vobiz-Signature-V3` |

> [!TIP]
>
> **Recommended:** Validate `X-Vobiz-Signature-V3` (or V2) to confirm the request came from Vobiz, **and** `X-Vobiz-Signature` (V1) if your handler acts on parameter values such as `CallStatus` or `From`. V2 and V3 sign only the URL and a nonce, so they do not detect a changed parameter; V1 does.

### Signature versions compared

| Version | Signature header | Nonce header | Algorithm | Message signed | Status |
| - | - | - | - | - | - |
| V1 | `X-Vobiz-Signature` | - | HMAC-SHA1, base64 | `baseURL + "k1=v1&k2=v2..."` (all parameters, sorted by name) | Validate when you act on parameter values |
| V2 | `X-Vobiz-Signature-V2` | `X-Vobiz-Signature-V2-Nonce` | HMAC-SHA256, base64 | `baseURL + nonce` | Recommended for origin |
| V3 | `X-Vobiz-Signature-V3` | `X-Vobiz-Signature-V3-Nonce` | HMAC-SHA256, base64 | `baseURL + "." + nonce` | Recommended for origin |

### What each signature covers

| Signature | Covers the URL | Covers the parameters | Covers the query string, headers or raw body |
| - | - | - | - |
| V1 | Yes (base URL) | **Yes** | No |
| V2 | Yes (base URL) | No | No |
| V3 | Yes (base URL) | No | No |

The **base URL** is your callback URL with the query string removed.

## How signatures are computed

### V1 signature

1. Take your callback URL and strip all query parameters to get the **base URL**.
2. Take every parameter in the callback (the decoded form fields of the request body), sort them by name, and join them as `key=value` pairs separated by `&`.
3. Concatenate: `baseURL + sortedParams`.
4. Compute `HMAC-SHA1` of that string using your auth token as the key, then base64-encode it.

```
X-Vobiz-Signature = base64( HMAC-SHA1( key=authToken, msg=baseURL + "k1=v1&k2=v2&..." ) )
```

```python Python - V1 theme={null}
import base64, hashlib, hmac
from urllib.parse import urlparse, urlunparse

def validate_v1(callback_url: str, auth_token: str, form: dict, request_headers: dict) -> bool:
    signature = request_headers.get("X-Vobiz-Signature", "")
    parsed    = urlparse(callback_url)
    base_url  = urlunparse((parsed.scheme, parsed.netloc, parsed.path, "", "", ""))
    msg       = base_url + "&".join(f"{k}={form[k]}" for k in sorted(form))
    expected  = base64.b64encode(hmac.new(auth_token.encode(), msg.encode(), hashlib.sha1).digest()).decode()
    return hmac.compare_digest(expected, signature)

# form = the decoded form fields, e.g. request.form.to_dict() in Flask
```

### V2 signature

1. Take your callback URL and strip all query parameters to get the **base URL** (e.g. `https://your-domain.com/webhook`).
2. Concatenate: `baseURL + nonce` (where nonce is the value of `X-Vobiz-Signature-V2-Nonce`).
3. Compute `HMAC-SHA256` of that string using your auth token as the key.
4. Base64-encode the result.

```
X-Vobiz-Signature-V2 = base64( HMAC-SHA256( key=authToken, msg=baseURL + nonce ) )
```

### V3 signature

Identical to V2 except the nonce is joined to the base URL with a `.` separator:

```
X-Vobiz-Signature-V3 = base64( HMAC-SHA256( key=authToken, msg=baseURL + "." + nonce ) )
```

For a callback sent to `https://your-domain.com/webhook?CallUUID=abc`, the inputs are:

| Input | V2 | V3 |
| - | - | - |
| Base URL | `https://your-domain.com/webhook` | `https://your-domain.com/webhook` |
| Nonce | Value of `X-Vobiz-Signature-V2-Nonce` | Value of `X-Vobiz-Signature-V3-Nonce` |
| Message | `https://your-domain.com/webhook` + nonce | `https://your-domain.com/webhook` + `.` + nonce |
| Key | Your auth token | Your auth token |
| Compare against | `X-Vobiz-Signature-V2` | `X-Vobiz-Signature-V3` |

### Multi-account (MA) variants

> [!NOTE]
>
> **Signatures are sent on every voice callback, with no setup.** This includes the
> `answer_url` request, `ring_url`, `hangup_url`, and status callbacks. Fail closed:
> reject a callback whose signature headers are missing or do not validate.
>
> Voice callbacks are delivered as `application/x-www-form-urlencoded`. V2 and V3
> sign only the URL and a nonce; V1 also signs the decoded form parameters. No
> signature hashes the raw body bytes, so a scheme that hashes the body will not
> verify.

For callbacks on sub-accounts, Vobiz additionally signs with the **parent account's** auth token and sends the result in `X-Vobiz-Signature-MA-V2` / `X-Vobiz-Signature-MA-V3`. The algorithm is identical - only the key differs. This lets you verify callbacks using either the sub-account or the main account auth token.

***

## Validation examples

Each example defines a V2 and a V3 validator and shows how to call one from a web handler. Every validator follows the same steps:

1. Read the signature and its nonce from the request headers.
2. Strip the query string from the callback URL to get the base URL.
3. Compute `HMAC-SHA256` over the base URL and nonce (joined with `.` for V3), using your auth token as the key, and base64-encode it.
4. Compare the result to the received signature in constant time.

| Language | Constant-time comparison used |
| - | - |
| Python | `hmac.compare_digest` |
| Node.js | `crypto.timingSafeEqual` |
| Go | `hmac.Equal` |
| Ruby | `ActiveSupport::SecurityUtils.secure_compare` |

| Language | HMAC and base64 from | Web handler shown | Response on a bad signature |
| - | - | - | - |
| Python | `hmac`, `hashlib`, `base64` | Flask | `abort(403)` |
| Node.js | `crypto` | Express | `403` with a JSON error |
| Go | `crypto/hmac`, `crypto/sha256`, `encoding/base64` | `net/http` | `http.StatusForbidden` |
| Ruby | `openssl`, `base64` | Validator functions only | - |

```python Python theme={null}
import hmac
import hashlib
import base64
from urllib.parse import urlparse, urlunparse

def get_base_url(url: str) -> str:
    parsed = urlparse(url)
    return urlunparse((parsed.scheme, parsed.netloc, parsed.path, "", "", ""))

def validate_v2(callback_url: str, auth_token: str, request_headers: dict) -> bool:
    signature = request_headers.get("X-Vobiz-Signature-V2", "")
    nonce     = request_headers.get("X-Vobiz-Signature-V2-Nonce", "")

    base_url = get_base_url(callback_url)
    msg      = (base_url + nonce).encode()
    key      = auth_token.encode()

    expected = base64.b64encode(hmac.new(key, msg, hashlib.sha256).digest()).decode()
    return hmac.compare_digest(signature, expected)

def validate_v3(callback_url: str, auth_token: str, request_headers: dict) -> bool:
    signature = request_headers.get("X-Vobiz-Signature-V3", "")
    nonce     = request_headers.get("X-Vobiz-Signature-V3-Nonce", "")

    base_url = get_base_url(callback_url)
    msg      = (base_url + "." + nonce).encode()
    key      = auth_token.encode()

    expected = base64.b64encode(hmac.new(key, msg, hashlib.sha256).digest()).decode()
    return hmac.compare_digest(signature, expected)

# Usage (e.g. Flask)
from flask import request, abort

AUTH_TOKEN = "your_auth_token_here"

@app.route("/webhook", methods=["POST"])
def webhook():
    url = request.url
    if not validate_v2(url, AUTH_TOKEN, request.headers):
        abort(403, "Invalid signature")
    # ... handle event
```

```javascript Node.js theme={null}
const crypto = require("crypto");

function getBaseUrl(url) {
  const parsed = new URL(url);
  return `${parsed.protocol}//${parsed.host}${parsed.pathname}`;
}

function validateV2(callbackUrl, authToken, headers) {
  const signature = headers["x-vobiz-signature-v2"] ?? "";
  const nonce     = headers["x-vobiz-signature-v2-nonce"] ?? "";

  const baseUrl  = getBaseUrl(callbackUrl);
  const expected = crypto
    .createHmac("sha256", authToken)
    .update(baseUrl + nonce)
    .digest("base64");

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

function validateV3(callbackUrl, authToken, headers) {
  const signature = headers["x-vobiz-signature-v3"] ?? "";
  const nonce     = headers["x-vobiz-signature-v3-nonce"] ?? "";

  const baseUrl  = getBaseUrl(callbackUrl);
  const expected = crypto
    .createHmac("sha256", authToken)
    .update(baseUrl + "." + nonce)
    .digest("base64");

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

// Usage (Express)
const AUTH_TOKEN = "your_auth_token_here";

app.post("/webhook", (req, res) => {
  const callbackUrl = `${req.protocol}://${req.get("host")}${req.originalUrl}`;
  if (!validateV2(callbackUrl, AUTH_TOKEN, req.headers)) {
    return res.status(403).json({ error: "Invalid signature" });
  }
  // ... handle event
  res.sendStatus(200);
});
```

```go Go theme={null}
package main

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/base64"
	"fmt"
	"net/http"
	"net/url"
)

func getBaseURL(rawURL string) (string, error) {
	parsed, err := url.Parse(rawURL)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%s://%s%s", parsed.Scheme, parsed.Host, parsed.Path), nil
}

func computeHMAC(key, msg string) string {
	h := hmac.New(sha256.New, []byte(key))
	h.Write([]byte(msg))
	return base64.StdEncoding.EncodeToString(h.Sum(nil))
}

func validateV2(callbackURL, authToken string, headers http.Header) bool {
	signature := headers.Get("X-Vobiz-Signature-V2")
	nonce     := headers.Get("X-Vobiz-Signature-V2-Nonce")

	baseURL, err := getBaseURL(callbackURL)
	if err != nil {
		return false
	}

	expected := computeHMAC(authToken, baseURL+nonce)
	return hmac.Equal([]byte(signature), []byte(expected))
}

func validateV3(callbackURL, authToken string, headers http.Header) bool {
	signature := headers.Get("X-Vobiz-Signature-V3")
	nonce     := headers.Get("X-Vobiz-Signature-V3-Nonce")

	baseURL, err := getBaseURL(callbackURL)
	if err != nil {
		return false
	}

	expected := computeHMAC(authToken, baseURL+"."+nonce)
	return hmac.Equal([]byte(signature), []byte(expected))
}

// Usage
const authToken = "your_auth_token_here"

func webhookHandler(w http.ResponseWriter, r *http.Request) {
	callbackURL := "https://your-domain.com" + r.URL.RequestURI()
	if !validateV2(callbackURL, authToken, r.Header) {
		http.Error(w, "Invalid signature", http.StatusForbidden)
		return
	}
	// ... handle event
	w.WriteHeader(http.StatusOK)
}
```

```ruby Ruby theme={null}
require "openssl"
require "base64"
require "uri"

def get_base_url(url)
  uri = URI.parse(url)
  "#{uri.scheme}://#{uri.host}#{uri.path}"
end

def validate_v2(callback_url, auth_token, headers)
  signature = headers["X-Vobiz-Signature-V2"].to_s
  nonce     = headers["X-Vobiz-Signature-V2-Nonce"].to_s

  base_url = get_base_url(callback_url)
  expected = Base64.strict_encode64(
    OpenSSL::HMAC.digest("SHA256", auth_token, base_url + nonce)
  )

  ActiveSupport::SecurityUtils.secure_compare(signature, expected)
end

def validate_v3(callback_url, auth_token, headers)
  signature = headers["X-Vobiz-Signature-V3"].to_s
  nonce     = headers["X-Vobiz-Signature-V3-Nonce"].to_s

  base_url = get_base_url(callback_url)
  expected = Base64.strict_encode64(
    OpenSSL::HMAC.digest("SHA256", auth_token, "#{base_url}.#{nonce}")
  )

  ActiveSupport::SecurityUtils.secure_compare(signature, expected)
end
```

***

## Sub-account callbacks

If your Vobiz account uses sub-accounts, callback requests include both the sub-account signature and the parent (main) account signature. You can validate using either auth token.

| Header | Signed with |
| - | - |
| `X-Vobiz-Signature-V2` | Sub-account auth token |
| `X-Vobiz-Signature-MA-V2` | Parent account auth token |
| `X-Vobiz-Signature-V3` | Sub-account auth token |
| `X-Vobiz-Signature-MA-V3` | Parent account auth token |

The algorithm for MA variants is identical - only the key differs. Use the same validation code, substituting your parent account auth token as the key.

***

## Best practices

> [!WARNING]
>
> Always use **constant-time comparison** when comparing signatures. Standard string equality (`==`) is vulnerable to timing attacks. Use `hmac.compare_digest` (Python), `crypto.timingSafeEqual` (Node.js), or `hmac.Equal` (Go).

* **Validate on every request.** Reject any callback missing the signature headers with HTTP 403.
* **Use HTTPS.** Plaintext HTTP exposes the nonce and signature, which an attacker could replay before you process the request.
* **Check the nonce is fresh (optional but recommended).** Nonces are randomly generated per request, not time-based, so replay protection requires you to store and check seen nonces for a short window (e.g. 5 minutes).
* **Validate V1 when you act on parameter values.** V2 and V3 use HMAC-SHA256 but do not cover the parameters. V1 uses HMAC-SHA1, which is still sound as an HMAC, and is the only signature that does.
* **Rotate your auth token if compromised.** Rotating your auth token immediately invalidates all signatures computed with the old key.

## Troubleshooting

| Symptom | Likely cause | Fix |
| - | - | - |
| Callbacks arrive with no signature headers | Every voice callback should carry them; there is nothing to configure. A request without them did not come through Vobiz's callback delivery. | Reject the request. If you believe it is a genuine Vobiz callback, contact support with the `CallUUID`. |
| The computed signature never matches | The query string was left on the URL. | Strip all query parameters to get the base URL before signing. |
| The signature never matches when you hash the request body | No signature hashes the raw body. V2/V3 sign the URL and a nonce; V1 signs the URL plus the decoded form parameters. Voice webhooks are `application/x-www-form-urlencoded`. | Sign `baseURL + nonce` (V2), `baseURL + "." + nonce` (V3), or `baseURL` + sorted `k=v` pairs joined with `&` (V1). |
| V3 fails while V2 passes | The `.` separator is missing from the V3 message. | Join the base URL and nonce with `.` for V3. |
| A sub-account callback fails with your main account token | `X-Vobiz-Signature-V2` and `X-Vobiz-Signature-V3` are signed with the sub-account token. | Validate the `-MA-` headers with the parent token, or the plain headers with the sub-account token. |
| A valid signature does not stop a replayed request | Nonces are random per request, not time-based, so a signature alone cannot show freshness. | Use HTTPS, store seen nonces for a short window (e.g. 5 minutes), and reject repeats. |

> [card] [Callbacks overview](https://www.vobiz.ai/docs/concepts/callbacks.md)
>
> Understand how Vobiz delivers callbacks and what parameters to expect.

> [card] [Callback configurations](https://www.vobiz.ai/docs/concepts/callback-configurations.md)
>
> Configure callback URLs, methods, and retry behaviour for your applications.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.