---
title: "POST /v2/{+parent}/buckets"
method: POST
path: "/v2/{+parent}/buckets"
tags: ["locations"]
---

# POST /v2/{+parent}/buckets

`POST /v2/{+parent}/buckets`

Creates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.

## Path parameters

- `parent` string, required

## Query parameters

- `bucketId` string

## Request body

- LogBucket — Describes a repository in which log entries are stored.
  - `description` string — Optional. Describes this bucket.
  - `indexConfigs` IndexConfig[] — Optional. A list of indexed fields and related configuration data.
    - `createTime` string, google-datetime — Output only. The timestamp when the index was last modified.This is used to return the timestamp, and will be ignored if supplied during update.
    - `fieldPath` string — Required. The LogEntry field path to index.Note that some paths are automatically indexed, and other paths are not eligible for indexing. See indexing documentation( https://docs.cloud.google.com/logging/docs/analyze/custom-index) for details.For example: jsonPayload.request.status
    - `type` 'INDEX_TYPE_UNSPECIFIED' | 'INDEX_TYPE_STRING' | 'INDEX_TYPE_INTEGER' — Required. The type of data in this index.
  - `cmekSettings` CmekSettings — Describes the customer-managed encryption key (CMEK) settings associated with a project, folder, organization, billing account, or flexible resource.Note: CMEK for the Log Router can currently only be configured for Google Cloud organizations. Once configured, it applies to all projects and folders in the Google Cloud organization.See Configure CMEK for Cloud Logging (https://docs.cloud.google.com/logging/docs/routing/managed-encryption) for more information.
    - `kmsKeyVersionName` string — Output only. The CryptoKeyVersion resource name for the configured Cloud KMS key.KMS key name format: "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[KEYRING]/cryptoKeys/[KEY]/cryptoKeyVersions/[VERSION]" For example:"projects/my-project/locations/us-central1/keyRings/my-ring/cryptoKeys/my-key/cryptoKeyVersions/1"This is a read-only field used to convey the specific configured CryptoKeyVersion of kms_key that has been configured. It will be populated in cases where the CMEK settings are bound to a single key version.If this field is populated, the kms_key is tied to a specific CryptoKeyVersion.
    - `name` string — Output only. The resource name of the CMEK settings.
    - `kmsKeyName` string — Optional. The resource name for the configured Cloud KMS key.KMS key name format: "projects/[PROJECT_ID]/locations/[LOCATION]/keyRings/[KEYRING]/cryptoKeys/[KEY]" For example:"projects/my-project/locations/us-central1/keyRings/my-ring/cryptoKeys/my-key"To enable CMEK for the Log Router, set this field to a valid kms_key_name for which the associated service account has the needed cloudkms.cryptoKeyEncrypterDecrypter roles assigned for the key.The Cloud KMS key used by the Log Router can be updated by changing the kms_key_name to a new valid key name or disabled by setting the key name to an empty string. Encryption operations that are in progress will be completed with the key that was in use when they started. Decryption operations will be completed using the key that was used at the time of encryption unless access to that key has been revoked.To disable CMEK for the Log Router, set this field to an empty string.See Configure CMEK for Cloud Logging (https://docs.cloud.google.com/logging/docs/routing/managed-encryption) for more information.
    - `serviceAccountId` string — Output only. The service account that will be used by the Log Router to access your Cloud KMS key.Before enabling CMEK for Log Router, you must first assign the cloudkms.cryptoKeyEncrypterDecrypter role to the service account that the Log Router will use to access your Cloud KMS key. Use GetCmekSettings to obtain the service account ID.See Configure CMEK for Cloud Logging (https://docs.cloud.google.com/logging/docs/routing/managed-encryption) for more information.
  - `name` string — Output only. The resource name of the bucket.For example:projects/my-project/locations/global/buckets/my-bucketFor a list of supported locations, see Supported Regions (https://docs.cloud.google.com/logging/docs/region-support)For the location of global it is unspecified where log entries are actually stored.After a bucket has been created, the location cannot be changed.
  - `analyticsEnabled` boolean — Optional. Whether log analytics is enabled for this bucket.Once enabled, log analytics features cannot be disabled.
  - `updateTime` string, google-datetime — Output only. The last update timestamp of the bucket.
  - `locked` boolean — Optional. Whether the bucket is locked.The retention period on a locked bucket cannot be changed. Locked buckets may only be deleted if they are empty.
  - `restrictedFields` string[] — Optional. Log entry field paths that are denied access in this bucket.The following fields and their children are eligible: textPayload, jsonPayload, protoPayload, httpRequest, labels, sourceLocation.Restricting a repeated field will restrict all values. Adding a parent will block all child fields. (e.g. foo.bar will block foo.bar.baz)
  - `lifecycleState` 'LIFECYCLE_STATE_UNSPECIFIED' | 'ACTIVE' | 'DELETE_REQUESTED' | 'UPDATING' | 'CREATING' | 'FAILED' — Output only. The bucket lifecycle state.
  - `createTime` string, google-datetime — Output only. The creation timestamp of the bucket. This is not set for any of the default buckets.
  - `retentionDays` integer — Optional. Logs will be retained by default for this amount of time, after which they will automatically be deleted. The minimum retention period is 1 day. If this value is set to zero at bucket creation time, the default time of 30 days will be used.

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/logging.md) · [All operations](https://skmtc.dev/google/apis/logging/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/logging/revisions/820c4b0f7358/schema)
