# Method: events.record

- [HTTP request](https://developer.android.com/games/services/web/api/rest/v1/events/record#body.HTTP_TEMPLATE)
- [Query parameters](https://developer.android.com/games/services/web/api/rest/v1/events/record#body.QUERY_PARAMETERS)
- [Request body](https://developer.android.com/games/services/web/api/rest/v1/events/record#body.request_body)
- [Response body](https://developer.android.com/games/services/web/api/rest/v1/events/record#body.response_body)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#body.RecordEventsChangesResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developer.android.com/games/services/web/api/rest/v1/events/record#body.aspect)
- [EventsUpdates](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventsUpdates)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventsUpdates.SCHEMA_REPRESENTATION)
- [EventPeriodUpdate](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodUpdate)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodUpdate.SCHEMA_REPRESENTATION)
- [EventPeriodRange](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodRange)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodRange.SCHEMA_REPRESENTATION)
- [EventUpdateRequest](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateRequest)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateRequest.SCHEMA_REPRESENTATION)
- [EventBatchRecordFailure](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventBatchRecordFailure)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventBatchRecordFailure.SCHEMA_REPRESENTATION)
- [EventFailureCause](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventFailureCause)
- [EventRecordFailure](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventRecordFailure)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventRecordFailure.SCHEMA_REPRESENTATION)
- [EventUpdateFailureCause](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateFailureCause)
- [Try it!](https://developer.android.com/games/services/web/api/rest/v1/events/record#try-it)

Records a batch of changes to the number of times events have occurred for the currently authenticated user of this application.

### HTTP request

`POST https://games.googleapis.com/games/v1/events`

### Query parameters

|                                       Parameters                                        ||
|------------|-----------------------------------------------------------------------------|
| `language` | `string` The preferred language to use for strings returned by this method. |

### Request body

The request body contains an instance of[EventsUpdates](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventsUpdates).

### Response body

An event period update resource.

If successful, the response body contains data with the following structure:

|                                                                                                                                                                                             JSON representation                                                                                                                                                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` { "kind": string, "batchFailures": [ { object (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventBatchRecordFailure) } ], "eventFailures": [ { object (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventRecordFailure) } ], "playerEvents": [ { object (https://developer.android.com/games/services/web/api/rest/v1/PlayerEvent) } ] } ``` |

|                                                                                                         Fields                                                                                                         ||
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `kind`            | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventUpdateResponse`.                                                                                |
| `batchFailures[]` | `object (`[EventBatchRecordFailure](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventBatchRecordFailure)`)` Any batch-wide failures which occurred applying updates. |
| `eventFailures[]` | `object (`[EventRecordFailure](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventRecordFailure)`)` Any failures updating a particular event.                          |
| `playerEvents[]`  | `object (`[PlayerEvent](https://developer.android.com/games/services/web/api/rest/v1/PlayerEvent)`)` The current status of any updated events                                                       |

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/games`
- `
  https://www.googleapis.com/auth/games_lite`

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

## EventsUpdates

An event period update resource.

|                                                                                            JSON representation                                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` { "kind": string, "requestId": string, "currentTimeMillis": string, "timePeriods": [ { object (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodUpdate) } ] } ``` |

|                                                                                                      Fields                                                                                                       ||
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `kind`              | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventRecordRequest`.                                                                          |
| `requestId`         | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` The request ID used to identify this attempt to record events.                                           |
| `currentTimeMillis` | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` The current time when this update was sent, in milliseconds, since 1970 UTC (Unix Epoch).                |
| `timePeriods[]`     | `object (`[EventPeriodUpdate](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodUpdate)`)` A list of the time period updates being made in this request. |

## EventPeriodUpdate

An event period update resource.

|                                                                                                                              JSON representation                                                                                                                              |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` { "timePeriod": { object (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodRange) }, "updates": [ { object (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateRequest) } ], "kind": string } ``` |

|                                                                                           Fields                                                                                            ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `timePeriod` | `object (`[EventPeriodRange](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodRange)`)` The time period being covered by this update.    |
| `updates[]`  | `object (`[EventUpdateRequest](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateRequest)`)` The updates being made for this time period. |
| `kind`       | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventPeriodUpdate`.                                                            |

## EventPeriodRange

An event period time range.

|                                JSON representation                                 |
|------------------------------------------------------------------------------------|
| ``` { "kind": string, "periodStartMillis": string, "periodEndMillis": string } ``` |

|                                                                                          Fields                                                                                           ||
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `kind`              | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventPeriodRange`.                                                    |
| `periodStartMillis` | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` The time when this update period begins, in millis, since 1970 UTC (Unix Epoch). |
| `periodEndMillis`   | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` The time when this update period ends, in millis, since 1970 UTC (Unix Epoch).   |

## EventUpdateRequest

An event period update resource.

|                            JSON representation                            |
|---------------------------------------------------------------------------|
| ``` { "definitionId": string, "updateCount": string, "kind": string } ``` |

|                                                                              Fields                                                                              ||
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `definitionId` | `string` The ID of the event being modified in this update.                                                                                      |
| `updateCount`  | `string (`[int64](https://developers.google.com/discovery/v1/type-format)` format)` The number of times this event occurred in this time period. |
| `kind`         | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventUpdateRequest`.                              |

## EventBatchRecordFailure

A batch update failure resource.

|                                                                                                                        JSON representation                                                                                                                         |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` { "range": { object (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodRange) }, "failureCause": enum (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventFailureCause), "kind": string } ``` |

|                                                                                                      Fields                                                                                                       ||
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `range`        | `object (`[EventPeriodRange](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventPeriodRange)`)` The time range which was rejected; empty for a request-wide failure. |
| `failureCause` | `enum (`[EventFailureCause](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventFailureCause)`)` The cause for the update failure.                                    |
| `kind`         | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventBatchRecordFailure`.                                                                          |

## EventFailureCause

Possible values for an event failure cause.

|                                                 Enums                                                  ||
|-----------------------|---------------------------------------------------------------------------------|
| `TOO_LARGE`           | A batch request was issued with more events than are allowed in a single batch. |
| `TIME_PERIOD_EXPIRED` | A batch was sent with data too far in the past to record.                       |
| `TIME_PERIOD_SHORT`   | A batch was sent with a time range that was too short.                          |
| `TIME_PERIOD_LONG`    | A batch was sent with a time range that was too long.                           |
| `ALREADY_UPDATED`     | An attempt was made to record a batch of data which was already seen.           |
| `RECORD_RATE_HIGH`    | An attempt was made to record data faster than the server will apply updates.   |

## EventRecordFailure

An event update failure resource.

|                                                                           JSON representation                                                                            |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` { "eventId": string, "failureCause": enum (https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateFailureCause), "kind": string } ``` |

|                                                                                           Fields                                                                                           ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `eventId`      | `string` The ID of the event that was not updated.                                                                                                                         |
| `failureCause` | `enum (`[EventUpdateFailureCause](https://developer.android.com/games/services/web/api/rest/v1/events/record#EventUpdateFailureCause)`)` The cause for the update failure. |
| `kind`         | `string` Uniquely identifies the type of this resource. Value is always the fixed string`games#eventRecordFailure`.                                                        |

## EventUpdateFailureCause

Possible values for the cause of an event update failure.

|                                           Enums                                            ||
|------------------------|--------------------------------------------------------------------|
| `NOT_FOUND`            | An attempt was made to set an event that was not defined.          |
| `INVALID_UPDATE_VALUE` | An attempt was made to increment an event by a non-positive value. |