Users.sessions: update

Updates or insert a given session. Try it now.

Request

HTTP request

PUT https://www.googleapis.com/fitness/v1/users/userId/sessions/sessionId

Parameters

Parameter name Value Description
Path parameters
sessionId string The ID of the session to be created.
userId string Create sessions for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.

Authorization

This request requires authorization with the following scope:

Scope
https://www.googleapis.com/auth/fitness.activity.write

For more information, see the authentication and authorization page.

Request body

In the request body, supply data with the following structure:

{
  "id": string,
  "name": string,
  "description": string,
  "startTimeMillis": long,
  "endTimeMillis": long,
  "modifiedTimeMillis": long,
  "application": {
    "packageName": string,
    "version": string,
    "detailsUrl": string,
    "name": string
  },
  "activityType": integer,
  "activeTimeMillis": long
}
Property name Value Description Notes
id string A client-generated identifier that is unique across all sessions owned by this particular user.
name string A human readable name of the session.
description string A description for this session.
startTimeMillis long A start time, in milliseconds since epoch, inclusive.
endTimeMillis long An end time, in milliseconds since epoch, inclusive.
modifiedTimeMillis long A timestamp that indicates when the session was last modified.
application nested object The application that created the session.
application.packageName string Package name for this application. This is used as a unique identifier when created by Android applications, but cannot be specified by REST clients. REST clients will have their developer project number reflected into the Data Source data stream IDs, instead of the packageName.
application.version string Version of the application. You should update this field whenever the application changes in a way that affects the computation of the data.
application.detailsUrl string An optional URI that can be used to link back to the application.
application.name string The name of this application. This is required for REST clients, but we do not enforce uniqueness of this name. It is provided as a matter of convenience for other developers who would like to identify which REST created an Application or Data Source.
activityType integer The type of activity this session represents.
activeTimeMillis long Session active time. While start_time_millis and end_time_millis define the full session time, the active time can be shorter and specified by active_time_millis. If the inactive time during the session is known, it should also be inserted via a com.google.activity.segment data point with a STILL activity value

Response

If successful, this method returns a response body with the following structure:

{
  "id": string,
  "name": string,
  "description": string,
  "startTimeMillis": long,
  "endTimeMillis": long,
  "modifiedTimeMillis": long,
  "application": {
    "packageName": string,
    "version": string,
    "detailsUrl": string,
    "name": string
  },
  "activityType": integer,
  "activeTimeMillis": long
}
Property name Value Description Notes
id string A client-generated identifier that is unique across all sessions owned by this particular user.
name string A human readable name of the session.
description string A description for this session.
startTimeMillis long A start time, in milliseconds since epoch, inclusive.
endTimeMillis long An end time, in milliseconds since epoch, inclusive.
modifiedTimeMillis long A timestamp that indicates when the session was last modified.
application nested object The application that created the session.
application.packageName string Package name for this application. This is used as a unique identifier when created by Android applications, but cannot be specified by REST clients. REST clients will have their developer project number reflected into the Data Source data stream IDs, instead of the packageName.
application.version string Version of the application. You should update this field whenever the application changes in a way that affects the computation of the data.
application.detailsUrl string An optional URI that can be used to link back to the application.
application.name string The name of this application. This is required for REST clients, but we do not enforce uniqueness of this name. It is provided as a matter of convenience for other developers who would like to identify which REST created an Application or Data Source.
activityType integer The type of activity this session represents.
activeTimeMillis long Session active time. While start_time_millis and end_time_millis define the full session time, the active time can be shorter and specified by active_time_millis. If the inactive time during the session is known, it should also be inserted via a com.google.activity.segment data point with a STILL activity value

Try it!

Use the APIs Explorer below to call this method on live data and see the response.