---
name: Secret
last_updated: 2026-06-10T23:09:12Z
type: datatype
summary: "Stores secret non-printable content."
---

# Secret

Stores secret non-printable content.

**Type:** datatype

## Description

The [Secret](/docs/reference/engine/datatypes/Secret.md) data type stores the secret content returned by
[HttpService:GetSecret()](/docs/reference/engine/classes/HttpService.md). It cannot be printed or logged, but can be
modified using built-in functions:

```lua
local HttpService = game:GetService("HttpService")

local mySiteApiKey = HttpService:GetSecret("my_site")
local url = "https://apis.mysite.com?apiKey="
local urlWithKey = mySiteApiKey:AddPrefix(url)
local params = "&request=join&user=myname"
local resultingUrl = urlWithKey:AddSuffix(params)
```

## Methods

### Secret:AddPrefix

**Signature:** `Secret:AddPrefix(prefix: string): Secret`

Returns a secret formed by concatenating the supplied string to the secret
content, for example prepending `"Bearer"` to the API key.

```lua
local HttpService = game:GetService("HttpService")

local secret = HttpService:GetSecret("yelp")
local authHeader = secret:AddPrefix("Bearer ")
```

**Parameters:**

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `prefix` | `string` |  |  |

**Returns:** `Secret`

### Secret:AddSuffix

**Signature:** `Secret:AddSuffix(suffix: string): Secret`

Returns a secret formed by concatenating the original secret and the
supplied string parameter. Useful when creating a URL containing a key and
query parameters.

```lua
local HttpService = game:GetService("HttpService")

local googleMapsApiKey = HttpService:GetSecret("google_map")

local baseUrl = "https://maps.googleapis.com/maps/api/distancematrix/json?key="
local queryParams = "&destinations=" .. destination .. "&origins=" .. origin .. "&departure_time=now&units=imperial"
local authedUrl = googleMapsApiKey:AddPrefix(baseUrl)
local queryUrl = authedUrl:AddSuffix(queryParams)
```

**Parameters:**

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `suffix` | `string` |  |  |

**Returns:** `Secret`