---
title: "Test Data Webhook – Form Dynamic URL with IF and Switch Macro"
slug: "test-data-webhook-form-dynamic-url-with-if-and-switch-macro"
updated: 2023-01-06T15:48:57Z
published: 2023-01-06T15:48:57Z
canonical: "docs.catchpoint.com/test-data-webhook-form-dynamic-url-with-if-and-switch-macro"
---

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

# Test Data Webhook – Form Dynamic URL with IF and Switch Macro

## Overview

This article explains how to form dynamic Test Data Webhook URLs based on the test that is pushing the data. This is useful in scenarios where the data pushed from certain tests need to be sent over to one endpoint and others to a separate endpoint. This can be done dynamically by using macros to assign specific values on the fly.

We have added support for the `if`, `switch` and `testid` macros to the URL section of Test Data Webhooks.
![blobid1.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/4416875339291-blobid1.png)

## Syntax and Examples

**Syntax for [\${switch}](https://docs.catchpoint.com/docs/transaction-commands-and-macros) macro:**
`${Switch(key, case1, value1, case2, value2..N)}`

Example using `${testid}` to form dynamic URL with `${switch}` macro:
~~~
https://${switch("${testid}","1884826","enmfvvgl3y0d","1884827","ens76jn94zzo")}.x.pipedream.net
~~~
**Syntax for [\${if}](https://docs.catchpoint.com/docs/transaction-commands-and-macros) macro:**
`If(case1, value1, case2, value2, case3, value3, case4, value4... ,caseN ,valueN, valueX)`

Example to use `${testid}`to form dynamic URL with `${if}`macro:
~~~
https://${if("${testid} = 1884826","enmfvvgl3y0d","${testid} = 1884827","ens76jn94zzo")}.x.pipedream.net
~~~
These examples are functionally equivalent. When the test with id `1884826` posts to the webhook, the macro will form the URL `https://enfvvgl3y02.x.pipedream.net`, and when test `1884827` posts to the webhook, the macro returns `https://ens76jn94zzo.x.pipedream.net`.
