# REST Resource: projects.deviceSessions

- [Resource: DeviceSession](https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#DeviceSession)
  - [JSON representation](https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#DeviceSession.SCHEMA_REPRESENTATION)
- [SessionState](https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionState)
- [SessionStateEvent](https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionStateEvent)
  - [JSON representation](https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionStateEvent.SCHEMA_REPRESENTATION)
- [Methods](https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#METHODS_SUMMARY)

## Resource: DeviceSession

Protobuf message describing the device message, used from several RPCs.

| JSON representation |
|---|
| ``` { "name": string, "displayName": string, "state": enum (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionState`), "stateHistories": [ { object (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionStateEvent`) } ], "inactivityTimeout": string, "createTime": string, "activeStartTime": string, "androidDevice": { object (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/AndroidDevice`) }, // Union field `expiration` can be only one of the following: "ttl": string, "expireTime": string // End of list of possible types for union field `expiration`. } ``` |

| Fields ||
|---|---|
| `name` | `string` Optional. Name of the DeviceSession, e.g. "projects/{projectId}/deviceSessions/{session_id}" |
| `displayName` | `string` Output only. The title of the DeviceSession to be presented in the UI. |
| `state` | ``enum (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionState`)`` Output only. Current state of the DeviceSession. |
| `stateHistories[]` | ``object (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionStateEvent`)`` Output only. The historical state transitions of the sessionState message including the current session state. |
| `inactivityTimeout` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Output only. The interval of time that this device must be interacted with before it transitions from ACTIVE to TIMEOUT_INACTIVITY. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `createTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The time that the Session was created. 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"`. |
| `activeStartTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The timestamp that the session first became ACTIVE. 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"`. |
| `androidDevice` | ``object (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/AndroidDevice`)`` Required. The requested device |
| Union field `expiration`. `expiration` can be only one of the following: ||
| `ttl` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Optional. The amount of time that a device will be initially allocated for. This can eventually be extended with the deviceSessions.patch RPC. Default: 15 minutes. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `expireTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Optional. If the device is still in use at this time, any connections will be ended and the SessionState will transition from ACTIVE to FINISHED. 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"`. |

## SessionState

The state that the device session resides.

| Enums ||
|---|---|
| `SESSION_STATE_UNSPECIFIED` | Default value. This value is unused. |
| `REQUESTED` | Initial state of a session request. The session is being validated for correctness and a device is not yet requested. |
| `PENDING` | The session has been validated and is in the queue for a device. |
| `ACTIVE` | The session has been granted and the device is accepting connections. |
| `EXPIRED` | The session duration exceeded the device's reservation time period and timed out automatically. |
| `FINISHED` | The user is finished with the session and it was canceled by the user while the request was still getting allocated or after allocation and during device usage period. |
| `UNAVAILABLE` | Unable to complete the session because the device was unavailable and it failed to allocate through the scheduler. For example, a device not in the catalog was requested or the request expired in the allocation queue. |
| `ERROR` | Unable to complete the session for an internal reason, such as an infrastructure failure. |

## SessionStateEvent

A message encapsulating a series of Session states and the time that the DeviceSession first entered those states.

| JSON representation |
|---|
| ``` { "sessionState": enum (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionState`), "eventTime": string, "stateMessage": string } ``` |

| Fields ||
|---|---|
| `sessionState` | ``enum (`https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions#SessionState`)`` Output only. The sessionState tracked by this event |
| `eventTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The time that the sessionState first encountered that state. 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"`. |
| `stateMessage` | `string` Output only. A human-readable message to explain the state. |

| ## Methods ||
|---|---|
| ### `https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions/cancel` | POST /v1/projects/{project_id}/deviceSessions/{device_session_id}:cancel Changes the DeviceSession to state FINISHED and terminates all connections. |
| ### `https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions/create` | POST /v1/projects/{project_id}/deviceSessions |
| ### `https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions/get` | GET /v1/projects/{project_id}/deviceSessions/{device_session_id} Return a DeviceSession, which documents the allocation status and whether the device is allocated. |
| ### `https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions/list` | GET /v1/projects/{project_id}/deviceSessions Lists device Sessions owned by the project user. |
| ### `https://firebase.google.com/docs/test-lab/reference/testing/rest/v1/projects.deviceSessions/patch` | PATCH /v1/projects/{projectId}/deviceSessions/deviceSessionId}:updateDeviceSession Updates the current device session to the fields described by the update_mask. |