# How to Use URL Query Strings

A URL query string is a data delivery method that provides input data at the end of the URL.\
**E.g.,** <mark style="color:purple;">`https://zep.us/play/{mapHashId}?{parameter}={value}`</mark>

You can deliver data to a ZEP Space or ZEP Script using a URL query strings.

## URL Query String Parameters Available in ZEP

### 1. name

When users who are not signed in enter a Space, you can set their nickname as the value passed as the name parameter.

* Example: <mark style="color:purple;">`https://zep.us/play/{mapHashId}?name=A`</mark>

  <figure><img src="/files/UtYonPLK6sMVavC8doxB" alt=""><figcaption></figcaption></figure>

:warning: Make sure to deactivate nickname settings pop-up for guests!

<figure><img src="/files/zx2hFeuTdTWAfyeTbe2d" alt=""><figcaption></figcaption></figure>

### 2. customData

You can pass data to ZEP Script player objects.\
You can create a whitelist function, such as identifying users by passing user identification information such as SSO token information to ZEP Script.

**Example 1** \
Receive user information with customData and apply it. (Normal app, sidebar app recommended)

⚡ URL used for example

<mark style="color:purple;">`https://zep.us/play/{mapHashId}?customData={"name":"customUser", "moveSpeed":150, "title":"customTitle"}`</mark>

```jsx
App.onJoinPlayer.Add(function (player) {
  // Checks if there is customData passed
	if (player.customData) {
		// Converts customData to object and uses
		let playerCustomData = JSON.parse(player.customData);
		if (playerCustomData.hasOwnProperty("name")) {
			player.name = playerCustomData["name"];
		}
		if (playerCustomData.hasOwnProperty("moveSpeed")) {
			player.moveSpeed = playerCustomData["moveSpeed"];
		}
		if (playerCustomData.hasOwnProperty("title")) {
			player.title = playerCustomData["title"];
		}
		App.sayToAll("customData applied");
		player.sendUpdated();
	}
  // Displays message if there is no customData passed
  else {
		App.sayToAll("customData not delivered.");
	}
});
```

<figure><img src="/files/eAaqDH0HGfFvxLjPgQ5g" alt=""><figcaption><p>When customData is Successfully Applied</p></figcaption></figure>

<figure><img src="/files/wfhPWbV0Lbmzxml4qPU3" alt=""><figcaption><p>When Failed to Receive customData</p></figcaption></figure>

**Example 2**

Create a simple token-based whitelist function. (Normal app, sidebar app recommended)

{% file src="/files/O7bDMCIodHZcWxeLsOK9" %}

✅ A token with base64 encryption in the browser developer tools (F12) has been created as follows:

<figure><img src="/files/a9Oyo0Eh1OuW022EOcbn" alt=""><figcaption></figcaption></figure>

⚡ URL used for example

<mark style="color:purple;">`https://zep.us/play/{mapHashId}?customData=JTdCJTIydG9rZW4lMjIlM0ElMjIlRUMlOUMlQTAlRUMlQTAlODAxJTJGd2hpdGVMaXN0JTIyJTdE`</mark>

```jsx
App.onJoinPlayer.Add(function (player) {
	player.tag = {};
	if (player.customData) {
		let token = player.customData;
		// Sends token to widget to decrypt
		player.tag.widget = player.showWidget("main.html", "topleft", 1, 1);
		player.tag.widget.sendMessage({
			type: "decode",
			token: token,
		});
		player.tag.widget.onMessage.Add(function (player, data) {
			if (data.type == "decode") {
				let decodedToken = data.decodedToken;
				App.sayToAll(decodedToken);
				// Receives the decrypted code and converts it to an object
				let playerData = JSON.parse(decodedToken);

				let playerName = playerData["token"].split("/")[0];
				let isTrusted = playerData["token"].split("/")[1];

				if (isTrusted == "whiteList") {
					player.name = playerName;
					player.title = "verified user";
					player.sendUpdated();
				}
				player.tag.widget.destroy();
				player.tag.widget = null;
			}
		});
	} else {
		App.sayToAll("customData not delivered.");
	}
});
```

```powershell
// Script used in widget
window.addEventListener("message", function (e) {
  if (e.data.type == "decode") {
		// Decrypt the base64 token
    decodedToken = decodeURIComponent(atob(e.data.token));
    window.parent.postMessage({
      type: "decode",
      decodedToken: decodedToken
    }, "*")
  }
})
```

<figure><img src="/files/08bvMq3lnjxxflwTvsCw" alt=""><figcaption><p>When Successfully Verified with a Token</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zep.us/zep-script/zep-script-guide/appendix/how-to-use-url-query-strings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
