# Method: projects.getMetrics

- [HTTP request](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.HTTP_TEMPLATE)
- [Path parameters](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.PATH_PARAMETERS)
- [Query parameters](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.QUERY_PARAMETERS)
- [Request body](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.request_body)
- [Response body](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.response_body)
  - [JSON representation](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.Metrics.SCHEMA_REPRESENTATION)
- [Authorization Scopes](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#body.aspect)
- [MetricsGranularity](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsGranularity)
- [MetricsFilter](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsFilter)
  - [JSON representation](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsFilter.SCHEMA_REPRESENTATION)
- [MetricsValue](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue)
  - [JSON representation](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue.SCHEMA_REPRESENTATION)
- [Try it!](https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#try-it)

Get metrics data for scripts, such as number of executions and active users.

### HTTP request

`GET https://script.googleapis.com/v1/projects/{scriptId}/metrics`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `scriptId` | `string` Required field indicating the script to get metrics for. |

### Query parameters

| Parameters ||
|---|---|
| `metricsGranularity` | ``enum (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsGranularity`)`` Required field indicating what granularity of metrics are returned. |
| `metricsFilter` | ``object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsFilter`)`` Optional field containing filters to apply to the request. This limits the scope of the metrics returned to those specified in the filter. |

### Request body

The request body must be empty.

### Response body

If successful, the response body contains data with the following structure:
Resource containing usage stats for a given script, based on the supplied filter and mask present in the request.

| JSON representation |
|---|
| ``` { "activeUsers": [ { object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue`) } ], "totalExecutions": [ { object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue`) } ], "failedExecutions": [ { object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue`) } ] } ``` |

| Fields ||
|---|---|
| `activeUsers[]` | ``object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue`)`` Number of active users. |
| `totalExecutions[]` | ``object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue`)`` Number of total executions. |
| `failedExecutions[]` | ``object (`https://developers.google.com/apps-script/api/reference/rest/v1/projects/getMetrics#MetricsValue`)`` Number of failed executions. |

### Authorization Scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/script.metrics`

For more information, see the [OAuth 2.0 Overview](https://developers.google.com/identity/protocols/OAuth2).

## MetricsGranularity

The granularity of metric to return data for.

| Enums ||
|---|---|
| `UNSPECIFIED_GRANULARITY` | Default metric granularity used to query no metrics. |
| `WEEKLY` | Represents weekly metrics. |
| `DAILY` | Represents daily metrics over a period of 7 days. |

## MetricsFilter

Filter used to reduce the scope of the request.

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

| Fields ||
|---|---|
| `deploymentId` | `string` Optional field indicating a specific deployment to retrieve metrics from. |

## MetricsValue

Metrics value that holds number of executions counted.

| JSON representation |
|---|
| ``` { "value": string, "startTime": string, "endTime": string } ``` |

| Fields ||
|---|---|
| `value` | `string` Indicates the number of executions counted. |
| `startTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` Required field indicating the start time of the interval. 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"`. |
| `endTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` Required field indicating the end time of the interval. 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"`. |