Set a Secret 

Connect
Secrets
Set a Secret

Create or replace a secret in the secret store.

Parameters

  • namestringRequired

    A name for the secret that’s unique within the scope.

  • payloadstringRequired

    The plaintext secret value to be stored.

  • scopemapRequired

    Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.

    • scope.typeenumRequired

      The secret scope type.

      Possible enum values
      account

      A secret scoped to an account. Use this for API keys or other secrets that should be accessible by all UI Extension contexts.

      user

      A secret scoped to a specific user. Use this for oauth tokens or other per-user secrets. If this is set, scope.user must also be set.

    • scope.userstring

      The user ID. This field is required if type is set to user, and should not be provided if type is set to account.

  • expires_attimestamp

    The Unix timestamp for the expiry time of the secret, after which the secret deletes.

Returns

Returns a secret object.

POST /v1/apps/secrets
stripe.Key = "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2"
params := &stripe.AppsSecretParams{
Name: stripe.String("my-api-key"),
Payload: stripe.String("secret_key_xxxxxx"),
Scope: &stripe.AppsSecretScopeParams{
Type: stripe.String(stripe.AppsSecretScopeTypeAccount),
},
}
result, err := secret.New(params)
Response
{
"id": "appsecret_5110hHS1707T6fjBnah1LkdIwHu7ix",
"object": "apps.secret",
"created": 1680209063,
"expires_at": null,
"livemode": false,
"name": "my-api-key",
"scope": {
"type": "account"
}
}