---
title: "GET /projects/{projectsId}/datasets/{datasetsId}/routines/{routinesId}"
method: GET
path: "/projects/{projectsId}/datasets/{datasetsId}/routines/{routinesId}"
tags: ["routines"]
---

# GET /projects/{projectsId}/datasets/{datasetsId}/routines/{routinesId}

`GET /projects/{projectsId}/datasets/{datasetsId}/routines/{routinesId}`

## Request

- Base URL: `https://bigquery.googleapis.com/bigquery/v2`
- URL: `https://bigquery.googleapis.com/bigquery/v2/projects/{projectsId}/datasets/{datasetsId}/routines/{routinesId}`
- Auth: one of:
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/bigquery`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/bigquery`
  - 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/cloud-platform.read-only`
    - 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.read-only`

Gets the specified routine resource by routine ID. # IAM Permissions Requires the `bigquery.routines.get` permission on the routine.

## Path parameters

- `projectsId` string, required
- `datasetsId` string, required
- `routinesId` string, required

## Query parameters

- `readMask` string, google-fieldmask

## Response `200`

Successful response

- Routine: A user-defined function or a stored procedure.
  - `arguments` Argument[]: Optional.
    - `argumentKind` 'ARGUMENT_KIND_UNSPECIFIED' | 'FIXED_TYPE' | 'ANY_TYPE' | 'FIXED_TABLE' | 'ANY_TABLE': Optional. Defaults to FIXED_TYPE.
    - `dataType` StandardSqlDataType: The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
      - `arrayElementType` StandardSqlDataType (recursive)
      - `rangeElementType` StandardSqlDataType (recursive)
      - `structType` StandardSqlStructType: The representation of a SQL STRUCT type.
        - `fields` StandardSqlField[]: Fields within the struct.
          - `name` string: Optional. The name of this field. Can be absent for struct fields.
          - `type` StandardSqlDataType (recursive)
      - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' | 'UUID': Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
    - `isAggregate` boolean: Optional. Whether the argument is an aggregate function parameter. Must be Unset for routine types other than AGGREGATE_FUNCTION. For AGGREGATE_FUNCTION, if set to false, it is equivalent to adding "NOT AGGREGATE" clause in DDL; Otherwise, it is equivalent to omitting "NOT AGGREGATE" clause in DDL.
    - `mode` 'MODE_UNSPECIFIED' | 'IN' | 'OUT' | 'INOUT': Optional. Specifies whether the argument is input or output. Can be set for procedures only.
    - `name` string: Optional. The name of this argument. Can be absent for function return argument.
    - `tableType` StandardSqlTableType: A table type
      - `columns` StandardSqlField[]: The columns in this table type
        - `name` string: Optional. The name of this field. Can be absent for struct fields.
        - `type` StandardSqlDataType: The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
          - `arrayElementType` StandardSqlDataType (recursive)
          - `rangeElementType` StandardSqlDataType (recursive)
          - `structType` StandardSqlStructType: The representation of a SQL STRUCT type.
            - `fields` StandardSqlField[]: Fields within the struct.
          - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' | 'UUID': Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
  - `buildStatus` RoutineBuildStatus: The status of a routine build.
    - `buildDuration` string, google-duration: Output only. The time taken for the image build. Populated only after the build succeeds or fails.
    - `buildState` 'BUILD_STATE_UNSPECIFIED' | 'IN_PROGRESS' | 'SUCCEEDED' | 'FAILED': Output only. The current build state of the routine.
    - `buildStateUpdateTime` string, google-datetime: Output only. The time when the build state was updated last.
    - `errorResult` ErrorProto: Error details.
      - `debugInfo` string: Debugging information. This property is internal to Google and should not be used.
      - `location` string: Specifies where the error occurred, if present.
      - `message` string: A human-readable description of the error.
      - `reason` string: A short error code that summarizes the error.
    - `imageSizeBytes` string, int64: Output only. The size of the image in bytes. Populated only after the build succeeds.
  - `creationTime` string, int64: Output only. The time when this routine was created, in milliseconds since the epoch.
  - `dataGovernanceType` 'DATA_GOVERNANCE_TYPE_UNSPECIFIED' | 'DATA_MASKING': Optional. If set to `DATA_MASKING`, the function is validated and made available as a masking function. For more information, see [Create custom masking routines](https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask).
  - `definitionBody` string: Required. The body of the routine. For functions, this is the expression in the AS clause. If `language = "SQL"`, it is the substring inside (but excluding) the parentheses. For example, for the function created with the following statement: `CREATE FUNCTION JoinLines(x string, y string) as (concat(x, "\n", y))` The definition_body is `concat(x, "\n", y)` (\n is not replaced with linebreak). If `language="JAVASCRIPT"`, it is the evaluated string in the AS clause. For example, for the function created with the following statement: `CREATE FUNCTION f() RETURNS STRING LANGUAGE js AS 'return "\n";\n'` The definition_body is `return "\n";\n` Note that both \n are replaced with linebreaks. If `definition_body` references another routine, then that routine must be fully qualified with its project ID.
  - `description` string: Optional. The description of the routine, if defined.
  - `determinismLevel` 'DETERMINISM_LEVEL_UNSPECIFIED' | 'DETERMINISTIC' | 'NOT_DETERMINISTIC': Optional. The determinism level of the JavaScript UDF, if defined.
  - `etag` string: Output only. A hash of this resource.
  - `externalRuntimeOptions` ExternalRuntimeOptions: Options for the runtime of the external system.
    - `containerCpu` number, double: Optional. Amount of CPU provisioned for a Python UDF container instance. For more information, see [Configure container limits for Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python#configure-container-limits)
    - `containerMemory` string: Optional. Amount of memory provisioned for a Python UDF container instance. Format: {number}{unit} where unit is one of "M", "G", "Mi" and "Gi" (e.g. 1G, 512Mi). If not specified, the default value is 512Mi. For more information, see [Configure container limits for Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python#configure-container-limits)
    - `containerRequestConcurrency` string, int64: Optional. Maximum number of requests that a Python UDF instance can handle concurrently. If absent or if `0`, the default concurrency value is used. For more information, see [Configure container limits for Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python#configure-container-limits).
    - `maxBatchingRows` string, int64: Optional. Maximum number of rows in each batch sent to the external runtime. If absent or if 0, BigQuery dynamically decides the number of rows in a batch.
    - `runtimeConnection` string: Optional. Fully qualified name of the connection whose service account will be used to execute the code in the container. Format: ```"projects/{project_id}/locations/{location_id}/connections/{connection_id}"```
    - `runtimeVersion` string: Optional. Language runtime version. Example: `python-3.11`.
    - `volumeMounts` ExternalVolumeMount[]: Optional. List of volume mounts for the Python UDF container that executes the managed function.
      - `mountPath` string: Optional. The absolute path within the container where the volume should be mounted.
      - `sourcePath` string: Optional. The absolute path of the source to be mounted, only support Google Cloud Storage bucket or folder now. Eg: gs://bucket-xxx for Google Cloud Storage bucket, gs://bucket-xxx/folder1/folder2 for Google Cloud Storage folder.
  - `importedLibraries` string[]: Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.
  - `language` 'LANGUAGE_UNSPECIFIED' | 'SQL' | 'JAVASCRIPT' | 'PYTHON' | 'JAVA' | 'SCALA': Optional. Defaults to "SQL" if remote_function_options field is absent, not set otherwise.
  - `lastModifiedTime` string, int64: Output only. The time when this routine was last modified, in milliseconds since the epoch.
  - `pythonOptions` PythonOptions: Options for a user-defined Python function.
    - `buildConnection` string: Optional. Fully qualified name of the connection whose service account will be used to authenticate to private package repositories during build-time. Format: "projects/{project_id}/locations/{location_id}/connections/{connection_id}"
    - `entryPoint` string: Required. The name of the function defined in Python code as the entry point when the Python UDF is invoked.
    - `extraPackageRepositories` string[]: Optional. The list of additional package repositories to search when resolving Python packages. These repositories are searched in addition to the default public PyPI. Only repositories hosted in Artifact Registry (.pkg.dev) are supported. Only pre-compiled Wheel (.whl) packages are supported from these repositories. E.g. ['https://my-region-python.pkg.dev/my-project/my-repo/simple']
    - `packages` string[]: Optional. A list of Python package names along with versions to be installed. Example: ["pandas>=2.1", "google-cloud-translate==3.11"]. For more information, see [Use third-party packages](https://cloud.google.com/bigquery/docs/user-defined-functions-python#third-party-packages).
  - `remoteFunctionOptions` RemoteFunctionOptions: Options for a remote user-defined function.
    - `connection` string: Fully qualified name of the user-provided connection object which holds the authentication information to send requests to the remote service. Format: ```"projects/{projectId}/locations/{locationId}/connections/{connectionId}"```
    - `endpoint` string: Endpoint of the user-provided remote service, e.g. ```https://us-east1-my_gcf_project.cloudfunctions.net/remote_add```
    - `maxBatchingRows` string, int64: Max number of rows in each batch sent to the remote service. If absent or if 0, BigQuery dynamically decides the number of rows in a batch.
    - `userDefinedContext` object: User-defined context as a set of key/value pairs, which will be sent as function invocation context together with batched arguments in the requests to the remote service. The total number of bytes of keys and values must be less than 8KB.
  - `returnTableType` StandardSqlTableType: A table type
    - `columns` StandardSqlField[]: The columns in this table type
      - `name` string: Optional. The name of this field. Can be absent for struct fields.
      - `type` StandardSqlDataType: The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
        - `arrayElementType` StandardSqlDataType (recursive)
        - `rangeElementType` StandardSqlDataType (recursive)
        - `structType` StandardSqlStructType: The representation of a SQL STRUCT type.
          - `fields` StandardSqlField[]: Fields within the struct.
        - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' | 'UUID': Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
  - `returnType` StandardSqlDataType: The data type of a variable such as a function argument. Examples include: * INT64: `{"typeKind": "INT64"}` * ARRAY: { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "STRING"} } * STRUCT>: { "typeKind": "STRUCT", "structType": { "fields": [ { "name": "x", "type": {"typeKind": "STRING"} }, { "name": "y", "type": { "typeKind": "ARRAY", "arrayElementType": {"typeKind": "DATE"} } } ] } } * RANGE: { "typeKind": "RANGE", "rangeElementType": {"typeKind": "DATE"} }
    - `arrayElementType` StandardSqlDataType (recursive)
    - `rangeElementType` StandardSqlDataType (recursive)
    - `structType` StandardSqlStructType: The representation of a SQL STRUCT type.
      - `fields` StandardSqlField[]: Fields within the struct.
        - `name` string: Optional. The name of this field. Can be absent for struct fields.
        - `type` StandardSqlDataType (recursive)
    - `typeKind` 'TYPE_KIND_UNSPECIFIED' | 'INT64' | 'BOOL' | 'FLOAT64' | 'STRING' | 'BYTES' | 'TIMESTAMP' | 'DATE' | 'TIME' | 'DATETIME' | 'INTERVAL' | 'GEOGRAPHY' | 'NUMERIC' | 'BIGNUMERIC' | 'JSON' | 'ARRAY' | 'STRUCT' | 'RANGE' | 'UUID': Required. The top level type of this field. Can be any GoogleSQL data type (e.g., "INT64", "DATE", "ARRAY").
  - `routineReference` RoutineReference: Id path of a routine.
    - `datasetId` string: Required. The ID of the dataset containing this routine.
    - `projectId` string: Required. The ID of the project containing this routine.
    - `routineId` string: Required. The ID of the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
  - `routineType` 'ROUTINE_TYPE_UNSPECIFIED' | 'SCALAR_FUNCTION' | 'PROCEDURE' | 'TABLE_VALUED_FUNCTION' | 'AGGREGATE_FUNCTION': Required. The type of routine.
  - `securityMode` 'SECURITY_MODE_UNSPECIFIED' | 'DEFINER' | 'INVOKER': Optional. The security mode of the routine, if defined. If not defined, the security mode is automatically determined from the routine's configuration.
  - `sparkOptions` SparkOptions: Options for a user-defined Spark routine.
    - `archiveUris` string[]: Archive files to be extracted into the working directory of each executor. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `connection` string: Fully qualified name of the user-provided Spark connection object. Format: ```"projects/{project_id}/locations/{location_id}/connections/{connection_id}"```
    - `containerImage` string: Custom container image for the runtime environment.
    - `fileUris` string[]: Files to be placed in the working directory of each executor. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `jarUris` string[]: JARs to include on the driver and executor CLASSPATH. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `mainClass` string: The fully qualified name of a class in jar_uris, for example, com.example.wordcount. Exactly one of main_class and main_jar_uri field should be set for Java/Scala language type.
    - `mainFileUri` string: The main file/jar URI of the Spark application. Exactly one of the definition_body field and the main_file_uri field must be set for Python. Exactly one of main_class and main_file_uri field should be set for Java/Scala language type.
    - `properties` object: Configuration properties as a set of key/value pairs, which will be passed on to the Spark application. For more information, see [Apache Spark](https://spark.apache.org/docs/latest/index.html) and the [procedure option list](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#procedure_option_list).
    - `pyFileUris` string[]: Python files to be placed on the PYTHONPATH for PySpark application. Supported file types: `.py`, `.egg`, and `.zip`. For more information about Apache Spark, see [Apache Spark](https://spark.apache.org/docs/latest/index.html).
    - `runtimeVersion` string: Runtime version. If not specified, the default runtime version is used.
  - `strictMode` boolean: Optional. Use this option to catch many common errors. Error checking is not exhaustive, and successfully creating a procedure doesn't guarantee that the procedure will successfully execute at runtime. If `strictMode` is set to `TRUE`, the procedure body is further checked for errors such as non-existent tables or columns. The `CREATE PROCEDURE` statement fails if the body fails any of these checks. If `strictMode` is set to `FALSE`, the procedure body is checked only for syntax. For procedures that invoke themselves recursively, specify `strictMode=FALSE` to avoid non-existent procedure errors during validation. Default value is `TRUE`.

## Changes

- **2026-11-05** `33188b5cf151`: 4 info
  - the security scope `https://www.googleapis.com/auth/bigquery` was added to the endpoint's security scheme `Oauth2`
  - the security scope `https://www.googleapis.com/auth/bigquery` was added to the endpoint's security scheme `Oauth2c`
  - the security scope `https://www.googleapis.com/auth/cloud-platform.read-only` was removed from the endpoint's security scheme `Oauth2`
  - the security scope `https://www.googleapis.com/auth/cloud-platform.read-only` was removed from the endpoint's security scheme `Oauth2c`
- **2026-10-29** `1c22958240fa`: 4 info
  - the security scope `https://www.googleapis.com/auth/bigquery` was added to the endpoint's security scheme `Oauth2`
  - the security scope `https://www.googleapis.com/auth/bigquery` was added to the endpoint's security scheme `Oauth2c`
  - the security scope `https://www.googleapis.com/auth/cloud-platform.read-only` was removed from the endpoint's security scheme `Oauth2`
  - the security scope `https://www.googleapis.com/auth/cloud-platform.read-only` was removed from the endpoint's security scheme `Oauth2c`

[Operation history](https://skmtc.dev/google/apis/bigquery/changes/projects/:projectsId/datasets/:datasetsId/routines/:routinesId/get.md)

---

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