---
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: 292
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/influxdata/influxdb/secrets/get/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.41.0+

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/)
