# name2key

Returns an avatar’s UUID by their Second Life name.

```csharp
// See "LSL Helper Functions" page for this function
smartbotsAPI("name2key", [
  "name", "BarKeeeper",
  "request_case", 1
]);
```

# Variables

The following table shows input values (you send them with the API call) and returned output values.


:::info
This API command applies only for **Standard bots**.

:::

## Input basic parameters

| Variable | Required | Description |
|----------|----------|-------------|
| action   | yes      | = name2key  |
| apikey   | yes      | Your personal [developer's API key](/doc/developers-api-key-tw8bQj4LSJ) |
| botname  | yes      | Your bot's SL login |
| secret   | yes      | [Bot access code](https://www.mysmartbots.com/docs/Bot_access_code) of your bot |
| dataType | optional | Set to "json" to get JSON reply instead of URL-encoded string |
| custom   | optional | The custom data (string) to be passed back to caller script. This value will be returned back to the caller in HTTP response |

## Input

| Variable | Required | Description |
|----------|----------|-------------|
| name     | yes      | The Second Life name of the avatar |
| request_case | optional | Set to `1` to get the exact avatar name case from Second Life (see **Name case**) |

## Output

*(To be received in* `*http_response*` *LSL event, see* [*docs for details*](/doc/doing-http-api-calls-c6FSEMF7bP)*)*

| Variable | Description |
|----------|-------------|
| result   | OK - command completed successfully<br>FAIL - command failed |
| resulttext | Detailed reason for the failure |
| custom   | The value from input "custom" parameter. See above |
| key      | Avatar’s UUID |
| name     | Second Life name you’ve sent |
| normalname | Second Life name, normalized (see **Return value**) |

# Return value

The command returns an avatar’s UUID by searching its Second Life name.  
It provides two name fields:

* `name` — the exact name as you sent it
* `normalname` — the “normalized” name (the system adds “Resident” if necessary)

# Name case

Second Life ignores name case (e.g., `glaznah gassner` equals `Glaznah GASSner`),  
so `normalname` may appear in lowercase.

If you want the exact name case from Second Life servers, set `request_case` to `1`.

# Examples

**1. Requesting the avatar UUID by Second Life name:**

```
https://www.mysmartbots.com/api/bot.html?action=name2key&name=barKeeeper&...
```

**Result:**

```
name = barKeeeper

normalname = barkeeeper resident

key = 76e96174-ddcf-482f-86aa-c9394664082f
```

**Or, with** `**request_case=1**`**:**

```
name = barKeeeper

normalname = BarKeeeper Resident

key = 76e96174-ddcf-482f-86aa-c9394664082f
```

**2. Looking for a nonexistent avatar:**

```
https://www.mysmartbots.com/api/bot.html?action=name2key&name=ThisAvatarNotExists&...
```

**Result:**

```
result = FAIL

resulttext = name lookup failed, ThisAvatarNotExists Resident

normalname = ThisAvatarNotExists Resident

name = ThisAvatarNotExists
```