Skip to content
Start here

Duplicate Secret

client.SecretsStore.Stores.Secrets.Duplicate(ctx, storeID, secretID, params) (*StoreSecretDuplicateResponse, error)
POST/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}/duplicate

Duplicates the secret, keeping the value

Security

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Secrets Store Write
ParametersExpand Collapse
storeID string

Store Identifier

maxLength32
secretID string

Secret identifier tag.

maxLength32
params StoreSecretDuplicateParams
AccountID param.Field[string]

Path param: Account Identifier

maxLength32
Name param.Field[string]

Body param: The name of the secret

Scopes param.Field[[]string]

Body param: The list of services that can use this secret.

Comment param.Field[string]Optional

Body param: Freeform text describing the secret

ReturnsExpand Collapse
type StoreSecretDuplicateResponse struct{…}
ID string

Secret identifier tag.

maxLength32
Created Time

Whenthe secret was created.

formatdate-time
Modified Time

When the secret was modified.

formatdate-time
Name string

The name of the secret

Status StoreSecretDuplicateResponseStatus
One of the following:
const StoreSecretDuplicateResponseStatusPending StoreSecretDuplicateResponseStatus = "pending"
const StoreSecretDuplicateResponseStatusActive StoreSecretDuplicateResponseStatus = "active"
const StoreSecretDuplicateResponseStatusDeleted StoreSecretDuplicateResponseStatus = "deleted"
StoreID string

Store Identifier

maxLength32
Comment stringOptional

Freeform text describing the secret

Scopes []stringOptional

The list of services that can use this secret.

Duplicate Secret

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/secrets_store"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  response, err := client.SecretsStore.Stores.Secrets.Duplicate(
    context.TODO(),
    "023e105f4ecef8ad9ca31a8372d0c353",
    "3fd85f74b32742f1bff64a85009dda07",
    secrets_store.StoreSecretDuplicateParams{
      AccountID: cloudflare.F("985e105f4ecef8ad9ca31a8372d0c353"),
      Name: cloudflare.F("MY_API_KEY"),
      Scopes: cloudflare.F([]string{"workers", "ai_gateway", "dex", "access"}),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "3fd85f74b32742f1bff64a85009dda07",
    "created": "2023-09-21T18:56:32.624632Z",
    "modified": "2023-09-21T18:56:32.624632Z",
    "name": "MY_API_KEY",
    "status": "pending",
    "store_id": "023e105f4ecef8ad9ca31a8372d0c353",
    "comment": "info about my secret",
    "scopes": [
      "workers",
      "ai_gateway",
      "dex",
      "access"
    ]
  },
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "3fd85f74b32742f1bff64a85009dda07",
    "created": "2023-09-21T18:56:32.624632Z",
    "modified": "2023-09-21T18:56:32.624632Z",
    "name": "MY_API_KEY",
    "status": "pending",
    "store_id": "023e105f4ecef8ad9ca31a8372d0c353",
    "comment": "info about my secret",
    "scopes": [
      "workers",
      "ai_gateway",
      "dex",
      "access"
    ]
  },
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}