> ## Documentation Index
> Fetch the complete documentation index at: https://www.octoparse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create or update a secret

> Write a secret value. Overwrites an existing value on rotate.

**`PUT`** `https://api-datahub.octoparse.com/v1/secrets/{name}`

Authentication: API key required (`Authorization: Bearer <API Key>`).

Creates or rotates an upstream credential secret. Plaintext is accepted on write and never returned on read.

## Request

### Path parameters

<ParamField path="name" type="string" required>
  Secret name. Letters, digits, and underscore. Referenced by apps as `env.<name>`.
</ParamField>

### Request body

<ParamField body="value" type="string" required>
  Plaintext secret value.
</ParamField>

### Example request

```bash theme={null}
curl -X PUT   -H "Authorization: Bearer $OCTOPARSE_API_KEY"   -H "Content-Type: application/json"   -d '{"value": "sk-live-example"}'   "https://api-datahub.octoparse.com/v1/secrets/EXAMPLE_API_KEY"
```

## Response

### 200 success

```json theme={null}
{
  "data": {
    "name": "EXAMPLE_API_KEY",
    "mask": "sk-****mple",
    "updated_at": "2026-09-01T08:00:00+00:00"
  }
}
```

The payload is wrapped in `data`. Fields:

<ResponseField name="name" type="string" required>
  Secret name.
</ResponseField>

<ResponseField name="mask" type="string" required>
  Masked value after write.
</ResponseField>

<ResponseField name="updated_at" type="string" required>
  Update time, ISO 8601.
</ResponseField>

### Errors

| HTTP | `code`          | `category`      | Description                 |
| ---- | --------------- | --------------- | --------------------------- |
| 400  | `invalid-input` | `invalid_input` | Name or value is invalid.   |
| 401  | `unauthorized`  | `forbidden`     | Missing or invalid API key. |

Error responses use `{"error": {code, category, message, retryable}}`. See <a href="/docs/en/datahub/api/reference/introduction#errors">Errors</a>.

## Client libraries

The Python and JavaScript SDKs do not wrap this endpoint yet. Call REST directly.
