---
title: secrets.get() function
description: secrets.get() retrieves a secret from the InfluxDB secret store.
url: https://docs.influxdata.com/flux/v0/stdlib/influxdata/influxdb/secrets/get/
estimated_tokens: 1066
product: Flux
version: v0
---

# secrets.get() function

-   Flux 0.41.0+
-   View InfluxDB support

`secrets.get()` retrieves a secret from the InfluxDB secret store.

##### Function type signature

```js
(key: string) => string
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### key

(Required) Secret key to retrieve.

## Examples

-   [Retrieve a key from the InfluxDB secret store](#retrieve-a-key-from-the-influxdb-secret-store)
-   [Populate sensitive credentials with secrets//](#populate-sensitive-credentials-with-secrets)

### Retrieve a key from the InfluxDB secret store

```js
import "influxdata/influxdb/secrets"

secrets.get(key: "KEY_NAME")
```

### Populate sensitive credentials with secrets//

```js
import "sql"
import "influxdata/influxdb/secrets"

username = secrets.get(key: "POSTGRES_USERNAME")
password = secrets.get(key: "POSTGRES_PASSWORD")

sql.from(
    driverName: "postgres",
    dataSourceName: "postgresql://${username}:${password}@localhost",
    query: "SELECT * FROM example-table",
)
```

#### Related

-   [Manage secrets in InfluxDB](/influxdb/v2/security/secrets/)

[secrets](/flux/v0/tags/secrets/) [security](/flux/v0/tags/security/)
