---
title: "POST /v1/projects/{projectsId}/locations/{locationsId}/sessions"
method: POST
path: "/v1/projects/{projectsId}/locations/{locationsId}/sessions"
tags: ["projects"]
---

# POST /v1/projects/{projectsId}/locations/{locationsId}/sessions

`POST /v1/projects/{projectsId}/locations/{locationsId}/sessions`

## Request

- Base URL: `https://dataproc.googleapis.com`
- URL: `https://dataproc.googleapis.com/v1/projects/{projectsId}/locations/{locationsId}/sessions`
- Auth: one of:
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/cloud-platform`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/cloud-platform`
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/dataproc`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/dataproc`
- TypeScript: <https://skmtc.dev/google/apis/dataproc/docs/v1/projects/:projectsId/locations/:locationsId/sessions/post.ts> (a function with typed inputs; its response is checked against the schema)

Create an interactive session asynchronously.

## Path parameters

- `projectsId` string, required
- `locationsId` string, required

## Query parameters

- `requestId` string
- `sessionId` string

## Request body

- Session: A representation of a session.
  - `createTime` string, google-datetime: Output only. The time when the session was created.
  - `creator` string: Output only. The email address of the user who created the session.
  - `environmentConfig` EnvironmentConfig: Environment configuration for a workload.
    - `executionConfig` ExecutionConfig: Execution configuration for a workload.
      - `authenticationConfig` AuthenticationConfig: Authentication configuration for a workload is used to set the default identity for the workload execution. The config specifies the type of identity (service account or user) that will be used by workloads to access resources on the project(s).
        - `userWorkloadAuthenticationType` 'AUTHENTICATION_TYPE_UNSPECIFIED' | 'SERVICE_ACCOUNT' | 'END_USER_CREDENTIALS': Optional. Authentication type for the user workload running in containers.
      - `idleTtl` string, google-duration: Optional. Applies to sessions only. The duration to keep the session alive while it's idling. Exceeding this threshold causes the session to terminate. This field cannot be set on a batch workload. Minimum value is 10 minutes; maximum value is 14 days (see JSON representation of Duration (https://developers.google.com/protocol-buffers/docs/proto3#json)). Defaults to 1 hour if not set. If both ttl and idle_ttl are specified for an interactive session, the conditions are treated as OR conditions: the workload will be terminated when it has been idle for idle_ttl or when ttl has been exceeded, whichever occurs first.
      - `kmsKey` string: Optional. The Cloud KMS key to use for encryption.
      - `networkTags` string[]: Optional. Tags used for network traffic control.
      - `networkUri` string: Optional. Network URI to connect workload to.
      - `resourceManagerTags` object: Optional. Associates Resource Manager tags with the workload nodes. There is a max limit of 30 tags. Keys and values can be either in numeric format, such as tagKeys/{tag_key_id} and tagValues/{tag_value_id}, or in namespaced format, such as {org_id|project_id}/{tag_key_short_name} and {tag_value_short_name}.
      - `serviceAccount` string: Optional. Service account that used to execute workload.
      - `stagingBucket` string: Optional. A Cloud Storage bucket used to stage workload dependencies, config files, and store workload output and other ephemeral data, such as Spark history files. If you do not specify a staging bucket, Cloud Dataproc will determine a Cloud Storage location according to the region where your workload is running, and then create and manage project-level, per-location staging and temporary buckets. This field requires a Cloud Storage bucket name, not a gs://... URI to a Cloud Storage bucket.
      - `subnetworkUri` string: Optional. Subnetwork URI to connect workload to.
      - `ttl` string, google-duration: Optional. The duration after which the workload will be terminated, specified as the JSON representation for Duration (https://protobuf.dev/programming-guides/proto3/#json). When the workload exceeds this duration, it will be unconditionally terminated without waiting for ongoing work to finish. If ttl is not specified for a batch workload, the workload will be allowed to run until it exits naturally (or run forever without exiting). If ttl is not specified for an interactive session, it defaults to 24 hours. If ttl is not specified for a batch that uses 2.1+ runtime version, it defaults to 4 hours. Minimum value is 10 minutes; maximum value is 14 days. If both ttl and idle_ttl are specified (for an interactive session), the conditions are treated as OR conditions: the workload will be terminated when it has been idle for idle_ttl or when ttl has been exceeded, whichever occurs first.
    - `peripheralsConfig` PeripheralsConfig: Auxiliary services configuration for a workload.
      - `metastoreService` string: Optional. Resource name of an existing Dataproc Metastore service.Example: projects/[project_id]/locations/[region]/services/[service_id]
      - `sparkHistoryServerConfig` SparkHistoryServerConfig: Spark History Server configuration for the workload.
        - `dataprocCluster` string: Optional. Resource name of an existing Dataproc Cluster to act as a Spark History Server for the workload.Example: projects/[project_id]/regions/[region]/clusters/[cluster_name]
  - `jupyterSession` JupyterConfig: Jupyter configuration for an interactive session.
    - `displayName` string: Optional. Display name, shown in the Jupyter kernelspec card.
    - `kernel` 'KERNEL_UNSPECIFIED' | 'PYTHON' | 'SCALA': Optional. Kernel
  - `labels` object: Optional. The labels to associate with the session. Label keys must contain 1 to 63 characters, and must conform to RFC 1035 (https://www.ietf.org/rfc/rfc1035.txt). Label values may be empty, but, if present, must contain 1 to 63 characters, and must conform to RFC 1035 (https://www.ietf.org/rfc/rfc1035.txt). No more than 32 labels can be associated with a session.
  - `name` string: Identifier. The resource name of the session.
  - `runtimeConfig` RuntimeConfig: Runtime configuration for a workload.
    - `autotuningConfig` AutotuningConfig: Autotuning configuration of the workload.
      - `scenarios` string[]: Optional. Scenarios for which tunings are applied.
    - `cohort` string: Optional. Cohort identifier. Identifies families of the workloads that have the same shape, for example, daily ETL jobs.
    - `containerImage` string: Optional. Optional custom container image for the job runtime environment. If not specified, a default container image will be used.
    - `properties` object: Optional. A mapping of property names to values, which are used to configure workload execution.
    - `repositoryConfig` RepositoryConfig: Configuration for dependency repositories
      - `pypiRepositoryConfig` PyPiRepositoryConfig: Configuration for PyPi repository
        - `pypiRepository` string: Optional. The PyPi repository address. Note: This field is not available for batch workloads.
    - `version` string: Optional. Version of the batch runtime.
  - `runtimeInfo` RuntimeInfo: Runtime information about workload execution.
    - `approximateUsage` UsageMetrics: Usage metrics represent approximate total resources consumed by a workload.
      - `acceleratorType` string: Optional. Accelerator type being used, if any Deprecated: This field is only used in runtime versions below 3.0.
      - `milliAcceleratorSeconds` string, int64: Optional. Accelerator usage in (milliAccelerator x seconds) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)). Deprecated: This field is only used in runtime versions below 3.0.
      - `milliAcceleratorSecondsA10040` string, int64: Optional. A100-40 accelerator usage in (milliAccelerator x seconds) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `milliAcceleratorSecondsA10080` string, int64: Optional. A100-80 accelerator usage in (milliAccelerator x seconds) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `milliAcceleratorSecondsL4` string, int64: Optional. L4 accelerator usage in (milliAccelerator x seconds) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `milliDcuSeconds` string, int64: Optional. DCU (Dataproc Compute Units) usage in (milliDCU x seconds) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `shuffleStorageGbSeconds` string, int64: Optional. Shuffle storage usage in (GB x seconds) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `updateTime` string, google-datetime: Optional. The timestamp of the usage metrics.
    - `cohortInfo` CohortInfo: Information about the cohort that the workload belongs to.
      - `cohort` string: Output only. Final cohort that was used to tune the workload.
      - `cohortSource` 'COHORT_SOURCE_UNSPECIFIED' | 'USER_PROVIDED' | 'AIRFLOW': Output only. Source of the cohort.
    - `currentUsage` UsageSnapshot: The usage snapshot represents the resources consumed by a workload at a specified time.
      - `acceleratorType` string: Optional. Accelerator type being used, if any Deprecated: This field is only used in runtime versions below 3.0.
      - `milliAccelerator` string, int64: Optional. Milli (one-thousandth) accelerator. (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)) Deprecated: This field is only used in runtime versions below 3.0.
      - `milliAcceleratorA10040` string, int64: Optional. Milli (one-thousandth) accelerator for A100-40 accelerators. (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing))
      - `milliAcceleratorA10080` string, int64: Optional. Milli (one-thousandth) accelerator for A100-80 accelerators. (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing))
      - `milliAcceleratorL4` string, int64: Optional. Milli (one-thousandth) accelerator for L4 accelerators. (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing))
      - `milliDcu` string, int64: Optional. Milli (one-thousandth) Dataproc Compute Units (DCUs) (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `milliDcuPremium` string, int64: Optional. Milli (one-thousandth) Dataproc Compute Units (DCUs) charged at premium tier (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing)).
      - `shuffleStorageGb` string, int64: Optional. Shuffle Storage in gigabytes (GB). (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing))
      - `shuffleStorageGbPremium` string, int64: Optional. Shuffle Storage in gigabytes (GB) charged at premium tier. (see Dataproc Serverless pricing (https://cloud.google.com/dataproc-serverless/pricing))
      - `snapshotTime` string, google-datetime: Optional. The timestamp of the usage snapshot.
    - `diagnosticOutputUri` string: Output only. A URI pointing to the location of the diagnostics tarball.
    - `endpoints` object: Output only. Map of remote access endpoints (such as web interfaces and APIs) to their URIs.
    - `outputUri` string: Output only. A URI pointing to the location of the stdout and stderr of the workload.
    - `propertiesInfo` PropertiesInfo: Properties of the workload organized by origin.
      - `autotuningProperties` object: Output only. Properties set by autotuning engine.
  - `sessionTemplate` string: Optional. The session template used by the session.Resource names and short template IDs are valid. Examples: * projects/[project_id]/locations/[dataproc_region]/sessionTemplates/[template_id] * [template_id]The template must be in the same project and Dataproc region as the session.
  - `sparkConnectSession` SparkConnectConfig: Spark connect configuration for an interactive session.
  - `state` 'STATE_UNSPECIFIED' | 'CREATING' | 'ACTIVE' | 'TERMINATING' | 'TERMINATED' | 'FAILED': Output only. A state of the session.
  - `stateHistory` SessionStateHistory[]: Output only. Historical state information for the session.
    - `state` 'STATE_UNSPECIFIED' | 'CREATING' | 'ACTIVE' | 'TERMINATING' | 'TERMINATED' | 'FAILED': Output only. The state of the session at this point in the session history.
    - `stateMessage` string: Output only. Details about the state at this point in the session history.
    - `stateStartTime` string, google-datetime: Output only. The time when the session entered the historical state.
  - `stateMessage` string: Output only. Session state details, such as the failure description if the state is FAILED.
  - `stateTime` string, google-datetime: Output only. The time when the session entered the current state.
  - `user` string: Optional. The email address of the user who owns the session.
  - `uuid` string: Output only. A session UUID (Unique Universal Identifier). The service generates this value when it creates the session.

## Response `200`

Successful response

- Operation: This resource represents a long-running operation that is the result of a network API call.
  - `done` boolean: If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.
  - `error` Status: The Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by gRPC (https://github.com/grpc). Each Status message contains three pieces of data: error code, error message, and error details.You can find out more about this error model and how to work with it in the API Design Guide (https://cloud.google.com/apis/design/errors).
    - `code` integer: The status code, which should be an enum value of google.rpc.Code.
    - `details` object[]: A list of messages that carry the error details. There is a common set of message types for APIs to use.
    - `message` string: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
  - `metadata` object: Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
  - `name` string: The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the name should be a resource name ending with operations/{unique_id}.
  - `response` object: The normal, successful response of the operation. If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is standard Get/Create/Update, the response should be the resource. For other methods, the response should have the type XxxResponse, where Xxx is the original method name. For example, if the original method name is TakeSnapshot(), the inferred response type is TakeSnapshotResponse.

## Changes

- **2026-10-29** `99b75ef6e002`: 4 info
  - the security scope `https://www.googleapis.com/auth/cloud-platform` was added to the endpoint's security scheme `Oauth2`
  - the security scope `https://www.googleapis.com/auth/cloud-platform` was added to the endpoint's security scheme `Oauth2c`
  - the security scope `https://www.googleapis.com/auth/dataproc` was removed from the endpoint's security scheme `Oauth2`
  - the security scope `https://www.googleapis.com/auth/dataproc` was removed from the endpoint's security scheme `Oauth2c`

[Operation history](https://skmtc.dev/google/apis/dataproc/changes/v1/projects/:projectsId/locations/:locationsId/sessions/post.md)

---

[API](https://skmtc.dev/google/apis/dataproc.md) - [All operations](https://skmtc.dev/google/apis/dataproc/llms.txt) - [OpenAPI document](https://skmtc.dev/google/apis/dataproc/revisions/99b75ef6e002?raw)
