# Delete

Delete a vault.





```http
DELETE /api/public/v1/vaults/{vault_id}
```

## Example [#example]

<Tabs items="[&#x22;bash&#x22;, &#x22;TypeScript&#x22;, &#x22;Ruby&#x22;, &#x22;Python&#x22;, &#x22;Go&#x22;]">
  <Tab value="bash">
    ```bash
    curl -X DELETE https://api.nairi.ai/api/public/v1/vaults/VAULT_ID \
      -H "Authorization: Bearer $NAIRI_API_KEY"
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    await fetch(`https://api.nairi.ai/api/public/v1/vaults/${vaultId}`, {
      method: "DELETE",
      headers: {
        Authorization: `Bearer ${process.env.NAIRI_API_KEY}`,
      },
    });
    ```
  </Tab>

  <Tab value="Ruby">
    ```ruby
    require "net/http"
    require "uri"

    uri = URI("https://api.nairi.ai/api/public/v1/vaults/#{vault_id}")
    req = Net::HTTP::Delete.new(uri)
    req["Authorization"] = "Bearer #{ENV['NAIRI_API_KEY']}"

    Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
    ```
  </Tab>

  <Tab value="Python">
    ```python
    import os
    import requests

    requests.delete(
        f"https://api.nairi.ai/api/public/v1/vaults/{vault_id}",
        headers={"Authorization": f"Bearer {os.environ['NAIRI_API_KEY']}"},
    )
    ```
  </Tab>

  <Tab value="Go">
    ```go
    package main

    import (
    	"net/http"
    	"os"
    )

    func main() {
    	vaultID := os.Getenv("VAULT_ID")
    	req, _ := http.NewRequest("DELETE", "https://api.nairi.ai/api/public/v1/vaults/"+vaultID, nil)
    	req.Header.Set("Authorization", "Bearer "+os.Getenv("NAIRI_API_KEY"))
    	res, _ := http.DefaultClient.Do(req)
    	defer res.Body.Close()
    }
    ```
  </Tab>
</Tabs>



<Callout type="info">
  Deletion fails with `400 Bad Request` if the vault is assigned to any agent, or if it still contains secrets. Unassign and empty the vault first.
</Callout>

## Response: `204 No Content` [#response-204-no-content]

## Error responses [#error-responses]

| HTTP  | Body                                                                | When                                                      |
| ----- | ------------------------------------------------------------------- | --------------------------------------------------------- |
| `400` | `{"error":"cannot delete vault: still assigned to N agent(s)"}`     | The vault is still attached to one or more agents.        |
| `400` | `{"error":"cannot delete vault: vault still contains N secret(s)"}` | The vault still has secrets — delete them first.          |
| `404` | `{"error":"vault not found"}`                                       | No vault with that ID exists in the calling organization. |
