# How can I get list of secrets by API request

**URL:** <https://discuss.hashicorp.com/t/how-can-i-get-list-of-secrets-by-api-request/11210>\
**Category:** Vault\
**Tags:** vault\
**Created:** [July 8, 2020, 8:17pm UTC](https://discuss.hashicorp.com/t/how-can-i-get-list-of-secrets-by-api-request/11210 "2020-07-08T20:17:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leavinus](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/leavinus/32/9170_2.png) [@leavinus](https://discuss.hashicorp.com/u/leavinus)\
**Post date:** [July 8, 2020, 8:17pm UTC](https://discuss.hashicorp.com/t/how-can-i-get-list-of-secrets-by-api-request/11210/1 "2020-07-08T20:17:37Z")

</div>

I created KV2 engine named “test”.  
I want to list all secrets defined in this scope by api request.

`vault kv list test/`

What is API equivalent of this CLI ?  
Is any way to get this information ?

---

<div class="post-metadata">

**Author:** ![mgritter](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mgritter/32/844_2.png) [@mgritter](https://discuss.hashicorp.com/u/mgritter)\
**Post date:** [July 8, 2020, 8:45pm UTC](https://discuss.hashicorp.com/t/how-can-i-get-list-of-secrets-by-api-request/11210/2 "2020-07-08T20:45:38Z")

</div>

Hi, leavinus.

Vault CLI requests usually take the -output-curl-string argument that will show the Curl arguments (and thus the exact URL) corresponding to the command. In this case:

```auto
$ vault kv list -output-curl-string test/
curl -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" http://localhost:8200/v1/test/metadata?list=true

```

Note that ‘kv list’ does a pre-check so this command will fail if tried against a nonexistent mount, or one to which your token lacks permissions. (which was a little surprising to me.)

You can also find the API for the KV version 2 secrets engine here: [https://www.vaultproject.io/api/secret/kv/kv-v2](https://www.vaultproject.io/api/secret/kv/kv-v2)

best,  
Mark
