Demonstrates the Environment Variables API for managing secrets and configuration in Tinybird.
| Method | Description |
|---|---|
list() |
List all variables (values hidden) |
retrieve(name) |
Get variable details (value hidden) |
create(name, value, type?) |
Create a new variable |
update(name, value) |
Update variable value |
remove(name) |
Delete a variable |
- Workspace admin token is required for all Variables API operations
- Copy environment file:
cp env.example .env- Edit
.envwith your admin token:
TINYBIRD_TOKEN=p.eyJ... # Must be admin token
TINYBIRD_LOCAL=false- Install dependencies:
composer install- Run the example:
php index.php$list = $client->variables()->list();
foreach ($list as $var) {
echo $var->name;
echo $var->type->value; // 'secret'
}
// Or access as array
$vars = $list->getVariables();$var = $client->variables()->retrieve('my_variable');
echo $var->name;
echo $var->type->value;
echo $var->createdAt->format('Y-m-d');
// Note: value is NOT returned for securityuse Brd6\TinybirdSdk\Enum\VariableType;
$var = $client->variables()->create(
'db_password',
'my_secret_value',
VariableType::SECRET, // optional, default
);$var = $client->variables()->update('db_password', 'new_secret_value');$result = $client->variables()->remove('db_password');
if ($result->isSuccess()) {
echo "Deleted!";
}After creating variables, use them in your Pipes with tb_secret():
%
SELECT *
FROM postgresql(
'host:port',
'database',
'table',
'user',
{{tb_secret('db_password')}}
)- 5 requests per second
- 100 variables per Workspace
- 8 KB max value size
- Values are encrypted at rest
- Values are never returned via API (only name, type, timestamps)
- Variables with
type=secretcannot be exposed in API Endpoint SELECT clauses