# Set a Secret

Create or replace a secret in the secret store.

## Request

```curl
curl https://api.stripe.com/v1/apps/secrets \
  -u "<<YOUR_SECRET_KEY>>" \
  -d name=my-api-key \
  -d payload=secret_key_xxxxxx \
  -d "scope[type]=account"
```

### Response

```json
{
  "id": "appsecret_5110hHS1707T6fjBnah1LkdIwHu7ix",
  "object": "apps.secret",
  "created": 1680209063,
  "expires_at": null,
  "livemode": false,
  "name": "my-api-key",
  "scope": {
    "type": "account"
  }
}
```

## Returns

Returns a secret object.

## Parameters

- `name` (string, required)
  A name for the secret that’s unique within the scope.

- `payload` (string, required)
  The plaintext secret value to be stored.

- [`scope`](https://docs.stripe.com/api/apps/secret_store/set.md?query=scope) (object, required)
  Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.

- `expires_at` (timestamp, optional)
  The Unix timestamp for the expiry time of the secret, after which the secret deletes.
