Secret

Constructors

NameDescription
HttpService:GetSecret(key: string):SecretReturns the Secret stored under the given key in the experience's secret store. Called on HttpService, not on Secret itself - Secret has no direct new() constructor and cannot be created from a plain string in a script. Its content cannot be printed or logged.

Code Snippet

local HttpService = game:GetService("HttpService")

local apiKey = HttpService:GetSecret("weather_api_key")
local url = apiKey:AddPrefix("https://api.example.com/weather?key=")

local response = HttpService:RequestAsync({
    Url = url,
    Method = "GET",
})

print(response.StatusCode, response.Body)

Methods

NameParametersReturnsDescription
AddPrefix(prefix: string):Secretprefix: stringSecretReturns a new Secret formed by prepending the given string to the secret's content, for example prepending "Bearer " to an API key.
AddSuffix(suffix: string):Secretsuffix: stringSecretReturns a new Secret formed by appending the given string to the secret's content, useful for building a URL that contains a key followed by query parameters.