# Method: projects.tenants.createSessionCookie

- [HTTP request](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#body.aspect)
- [Try it!](https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie#try-it)

Creates a session cookie for the given Identity Platform ID token. The session cookie is used by the client to preserve the user's login state.

### HTTP request

`POST https://identitytoolkit.googleapis.com/v1/projects/{targetProjectId}/tenants/{tenantId}:createSessionCookie`

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

### Path parameters

| Parameters ||
|---|---|
| `targetProjectId` | `string` The ID of the project that the account belongs to. |
| `tenantId` | `string` The tenant ID of the Identity Platform tenant the account belongs to. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "idToken": string, "validDuration": string } ``` |

| Fields ||
|---|---|
| `idToken` | `string` Required. A valid Identity Platform ID token. |
| `validDuration` | `string (https://developers.google.com/discovery/v1/type-format format)` The number of seconds until the session cookie expires. Specify a duration in seconds, between five minutes and fourteen days, inclusively. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/identity-platform/docs/reference/rest/v1/CreateSessionCookieResponse`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/identitytoolkit`
- `
  https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).