# REST Resource: projects.locations.secrets

- [Resource: Secret](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret)
  - [JSON representation](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.SCHEMA_REPRESENTATION)
  - [CustomerManagedEncryption](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption)
    - [JSON representation](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption.SCHEMA_REPRESENTATION)
  - [Topic](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Topic)
    - [JSON representation](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Topic.SCHEMA_REPRESENTATION)
  - [Rotation](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation)
    - [JSON representation](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#METHODS_SUMMARY)

## Resource: Secret

A `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` is a logical secret whose value and versions can be accessed.

A `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` is made up of zero or more `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion` that represent the secret data.

| JSON representation |
|---|
| ``` { "name": string, "createTime": string, "labels": { string: string, ... }, "topics": [ { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Topic`) } ], "etag": string, "rotation": { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation`) }, "versionAliases": { string: string, ... }, "annotations": { string: string, ... }, "versionDestroyTtl": string, "customerManagedEncryption": { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption`) }, // Union field `expiration` can be only one of the following: "expireTime": string, "ttl": string // End of list of possible types for union field `expiration`. } ``` |

| Fields ||
|---|---|
| `name` | `string` Output only. The resource name of the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` in the format `projects/*/locations/*/secrets/*`. |
| `createTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The time at which the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` was created. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `labels` | `map (key: string, value: string)` The labels assigned to this Secret. Label keys must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, and must conform to the following PCRE regular expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}` Label values must be between 0 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, and must conform to the following PCRE regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` No more than 64 labels can be assigned to a given resource. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `topics[]` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Topic`)`` Optional. A list of up to 10 Pub/Sub topics to which messages are published when control plane operations are called on the secret or its versions. |
| `etag` | `string` Optional. Etag of the currently stored `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. |
| `rotation` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation`)`` Optional. Rotation policy attached to the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. May be excluded if there is no rotation policy. |
| `versionAliases` | `map (key: string, value: string (https://developers.google.com/discovery/v1/type-format format))` Optional. Mapping from version alias to version name. A version alias is a string with a maximum length of 63 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore ('_') characters. An alias string must start with a letter and cannot be the string 'latest' or 'NEW'. No more than 50 aliases can be assigned to a given secret. Version-Alias pairs will be viewable via secrets.get and modifiable via secrets.patch. Access by alias is only be supported on GetSecretVersion and AccessSecretVersion. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `annotations` | `map (key: string, value: string)` Optional. Custom metadata about the secret. Annotations are distinct from various forms of labels. Annotations exist to allow client tools to store their own state information without requiring a database. Annotation keys must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, begin and end with an alphanumeric character (\[a-z0-9A-Z\]), and may have dashes (-), underscores (_), dots (.), and alphanumerics in between these symbols. The total size of annotation keys and values must be less than 16KiB. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `versionDestroyTtl` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Optional. Secret Version TTL after destruction request This is a part of the Delayed secret version destroy feature. For secret with TTL\>0, version destruction doesn't happen immediately on calling destroy instead the version goes to a disabled state and destruction happens after the TTL expires. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `customerManagedEncryption` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption`)`` Optional. The customer-managed encryption configuration of the regionalized secrets. If no configuration is provided, Google-managed default encryption is used. Updates to the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` encryption configuration only apply to `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion` added afterwards. They do not apply retroactively to existing `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion`. |
| Union field `expiration`. Expiration policy attached to the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. If specified the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` and all `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion` will be automatically deleted at expiration. Expired secrets are irreversibly deleted. Expiration is *not* the recommended way to set time-based permissions. [IAM Conditions](https://cloud.google.com/secret-manager/docs/access-control#conditions) is recommended for granting time-based permissions because the operation can be reversed. `expiration` can be only one of the following: ||
| `expireTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Optional. Timestamp in UTC when the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` is scheduled to expire. This is always provided on output, regardless of what was sent on input. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `ttl` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Input only. The TTL for the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |

### Replication

A policy that defines the replication and encryption configuration of data.

| JSON representation |
|---|
| ``` { // Union field `replication` can be only one of the following: "automatic": { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Automatic`) }, "userManaged": { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.UserManaged`) } // End of list of possible types for union field `replication`. } ``` |

| Fields ||
|---|---|
| Union field `replication`. The replication policy for this secret. `replication` can be only one of the following: ||
| `automatic` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Automatic`)`` The `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` will automatically be replicated without any restrictions. |
| `userManaged` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.UserManaged`)`` The `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` will only be replicated into the locations specified. |

### Automatic

A replication policy that replicates the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` payload without any restrictions.

| JSON representation |
|---|
| ``` { "customerManagedEncryption": { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption`) } } ``` |

| Fields ||
|---|---|
| `customerManagedEncryption` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption`)`` Optional. The customer-managed encryption configuration of the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. If no configuration is provided, Google-managed default encryption is used. Updates to the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` encryption configuration only apply to `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion` added afterwards. They do not apply retroactively to existing `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion`. |

### CustomerManagedEncryption

Configuration for encrypting secret payloads using customer-managed encryption keys (CMEK).

| JSON representation |
|---|
| ``` { "kmsKeyName": string } ``` |

| Fields ||
|---|---|
| `kmsKeyName` | `string` Required. The resource name of the Cloud KMS CryptoKey used to encrypt secret payloads. For secrets using the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.UserManaged` replication policy type, Cloud KMS CryptoKeys must reside in the same location as the \[replica location\]\[Secret.UserManaged.Replica.location\]. For secrets using the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Automatic` replication policy type, Cloud KMS CryptoKeys must reside in `global`. The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`. |

### UserManaged

A replication policy that replicates the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` payload into the locations specified in \[Secret.replication.user_managed.replicas\]\[\]

| JSON representation |
|---|
| ``` { "replicas": [ { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Replica`) } ] } ``` |

| Fields ||
|---|---|
| `replicas[]` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Replica`)`` Required. The list of Replicas for this `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. Cannot be empty. |

### Replica

Represents a Replica for this `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`.

| JSON representation |
|---|
| ``` { "location": string, "customerManagedEncryption": { object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption`) } } ``` |

| Fields ||
|---|---|
| `location` | `string` The canonical IDs of the location to replicate data. For example: `"us-east1"`. |
| `customerManagedEncryption` | ``object (`https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.CustomerManagedEncryption`)`` Optional. The customer-managed encryption configuration of the \[User-Managed Replica\]\[Replication.UserManaged.Replica\]. If no configuration is provided, Google-managed default encryption is used. Updates to the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` encryption configuration only apply to `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion` added afterwards. They do not apply retroactively to existing `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion`. |

### Topic

A Pub/Sub topic which Secret Manager will publish to when control plane events occur on this secret.

| JSON representation |
|---|
| ``` { "name": string } ``` |

| Fields ||
|---|---|
| `name` | `string` Identifier. The resource name of the Pub/Sub topic that will be published to, in the following format: `projects/*/topics/*`. For publication to succeed, the Secret Manager service agent must have the `pubsub.topic.publish` permission on the topic. The Pub/Sub Publisher role (`roles/pubsub.publisher`) includes this permission. |

### Rotation

The rotation time and period for a `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. At nextRotationTime, Secret Manager will send a Pub/Sub notification to the topics configured on the Secret. `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.FIELDS.topics` must be set to configure rotation.

| JSON representation |
|---|
| ``` { "nextRotationTime": string, "rotationPeriod": string } ``` |

| Fields ||
|---|---|
| `nextRotationTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Optional. Timestamp in UTC at which the `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` is scheduled to rotate. Cannot be set to less than 300s (5 min) in the future and at most 3153600000s (100 years). `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation.FIELDS.next_rotation_time` MUST be set if `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation.FIELDS.rotation_period` is set. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `rotationPeriod` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Input only. The Duration between rotation notifications. Must be in seconds and at least 3600s (1h) and at most 3153600000s (100 years). If `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation.FIELDS.rotation_period` is set, `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation.FIELDS.next_rotation_time` must be set. `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret.Rotation.FIELDS.next_rotation_time` will be advanced by this period when the service automatically sends rotation notifications. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/addVersion` | Creates a new `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion` containing secret data and attaches it to an existing `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/create` | Creates a new `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret` containing no `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets.versions#SecretVersion`. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/delete` | Deletes a `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/get` | Gets metadata for a given `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/getIamPolicy` | Gets the access control policy for a secret. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/list` | Lists `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/patch` | Updates metadata of an existing `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets#Secret`. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/setIamPolicy` | Sets the access control policy on the specified secret. |
| ### `https://docs.cloud.google.com/secret-manager/docs/reference/rest/v1/projects.locations.secrets/testIamPermissions` | Returns permissions that a caller has for the specified secret. |