---
title: pydo.security.create_secret()
description: Create Secret
product: Reference
url: https://docs.digitalocean.com/reference/pydo/reference/security/create_secret/
last_updated: "2026-08-03"
---

> **For AI agents:** The documentation index is at [https://docs.digitalocean.com/llms.txt](https://docs.digitalocean.com/llms.txt). Markdown versions of pages use the same URL with `index.html.md` in place of the HTML page (for example, append `index.html.md` to the directory path instead of opening the HTML document).

# pydo.security.create_secret()

Generated on 3 Aug 2026 from `pydo` version [`v0.40.0`](https://github.com/digitalocean/pydo/releases/tag/v0.40.0v0.40.0)

## Usage

```python
client.security.create_secret(
    body={
        "name": "my-database-password",
        "region": "nyc3",
        "values": {...},
    },
)
```

Returns `JSON`Raises `HttpResponseError`

## Description

To create a secret, send a POST request to [`/v2/security/secrets`](https://docs.digitalocean.com/reference/api/reference/security/index.html.md#security_create_secret).

## Parameters

`name` string required

Example: `my-database-password`

The name of the secret to create.

`region` string required

Example: `nyc3`

The region where the secret will be stored.

`values` object required

Example: `{'password': 's3cr3t'}`

Key-value pairs to store in the secret.

## Request Sample

## Show Request Sample

```python
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "name": "my-database-password",
  "region": "nyc3",
  "values": {
    "password": "s3cr3t"
  }
}

resp = client.security.create_secret(body=req)
```

## Response Example

## Show Response Example

```json
{
  "name": "my-database-password",
  "region": "nyc3",
  "version": 1
}
```

## More Information

See [`/v2/security/secrets`](https://docs.digitalocean.com/reference/api/reference/security/index.html.md#security_create_secret) in the API reference for additional detail on responses, headers, parameters, and more.