---
title: "POST /v1/partners/{partnersId}/userSessions:generate"
method: POST
path: "/v1/partners/{partnersId}/userSessions:generate"
tags: ["partners"]
---

# POST /v1/partners/{partnersId}/userSessions:generate

`POST /v1/partners/{partnersId}/userSessions:generate`

## Request

- Base URL: `https://paymentsresellersubscription.googleapis.com`
- URL: `https://paymentsresellersubscription.googleapis.com/v1/partners/{partnersId}/userSessions:generate`
- Auth: OAuth 2 and OAuth 2
  - Implicit: `https://accounts.google.com/o/oauth2/auth`
  - Scopes: `https://www.googleapis.com/auth/sdm.service`
  - Authorization code: `https://accounts.google.com/o/oauth2/auth`
  - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/sdm.service`
- TypeScript: <https://skmtc.dev/google/apis/paymentsresellersubscription/docs/v1/partners/:partnersId/userSessions:generate/post.ts> (a function with typed inputs; its response is checked against the schema)

This API replaces user authorized OAuth consent based APIs (Create, Entitle). Issues a timed session token for the given user intent. You can use the session token to redirect the user to Google to finish the signup flow. You can re-generate new session token repeatedly for the same request if necessary, regardless of the previous tokens being expired or not. By default, the session token is valid for 1 hour.

## Path parameters

- `partnersId` string, required

## Request body

- GenerateUserSessionRequest: Request to generate a user session.
  - `intentPayload` IntentPayload: The payload that describes the user intent.
    - `createIntent` CreateSubscriptionIntent: Intent message for creating a Subscription resource.
      - `cycleOptions` CycleOptions: The cycle options when starting and resuming a subscription.
        - `initialCycleDuration` Duration: Describes the length of a period of a time.
          - `count` integer: number of duration units to be included.
          - `unit` 'UNIT_UNSPECIFIED' | 'MONTH' | 'DAY' | 'HOUR': The unit used for the duration
      - `parent` string: Optional. Deprecated: Use the `parent` field in `GenerateUserSessionRequest` instead. The parent resource name, which is the identifier of the partner.
      - `subscription` Subscription: Acts as a central billing entity between an external partner and Google. Google services use the subscription state to grant or revoke the user's service entitlement. Note: The subscription state might not perfectly align with the user's service entitlement. Some services might continue providing access until the current cycle ends, even if the subscription is immediately canceled. Consult the relevant contract or product policy for specific details.
        - `cancellationDetails` SubscriptionCancellationDetails: Describes the details of a cancelled or cancelling subscription.
          - `reason` 'CANCELLATION_REASON_UNSPECIFIED' | 'CANCELLATION_REASON_FRAUD' | 'CANCELLATION_REASON_REMORSE' | 'CANCELLATION_REASON_ACCIDENTAL_PURCHASE' | 'CANCELLATION_REASON_PAST_DUE' | 'CANCELLATION_REASON_ACCOUNT_CLOSED' | 'CANCELLATION_REASON_UPGRADE_DOWNGRADE' | 'CANCELLATION_REASON_USER_DELINQUENCY' | 'CANCELLATION_REASON_SYSTEM_ERROR' | 'CANCELLATION_REASON_SYSTEM_CANCEL' | 'CANCELLATION_REASON_BILLING_SYSTEM_SWITCH' | 'CANCELLATION_REASON_OTHER': Output only. The reason of the cancellation.
        - `createTime` string, google-datetime: Output only. System generated timestamp when the subscription is created. UTC timezone.
        - `cycleEndTime` string, google-datetime: Output only. The time at which the subscription is expected to be extended, in ISO 8061 format. UTC timezone. For example: "2019-08-31T17:28:54.564Z"
        - `endUserEntitled` boolean: Output only. Indicates if the subscription is entitled to the end user.
        - `freeTrialEndTime` string, google-datetime: Output only. End of the free trial period, in ISO 8061 format. For example, "2019-08-31T17:28:54.564Z". It will be set the same as createTime if no free trial promotion is specified.
        - `lineItems` SubscriptionLineItem[]: Required. The line items of the subscription.
          - `amount` Amount: Describes the amount unit including the currency code.
            - `amountMicros` string, int64: Required. Amount in micros (1_000_000 micros = 1 currency unit)
            - `currencyCode` string: Required. Currency codes in accordance with [ISO-4217 Currency Codes] (https://en.wikipedia.org/wiki/ISO_4217). For example, USD.
          - `bundleDetails` SubscriptionLineItemBundleDetails: The bundle details for a line item corresponding to a hard bundle.
            - `bundleElementDetails` SubscriptionLineItemBundleDetailsBundleElementDetails[]: Output only. The details for each element in the hard bundle.
              - …
          - `description` string: Output only. Description of this line item.
          - `finiteBillingCycleDetails` FiniteBillingCycleDetails: Details for a subscription line item with finite billing cycles.
            - `billingCycleCountLimit` string, int64: The number of a subscription line item billing cycles after which billing will stop automatically.
          - `lineItemFreeTrialEndTime` string, google-datetime: Output only. The free trial end time will be populated after the line item is successfully processed. End time of the line item free trial period, in ISO 8061 format. For example, "2019-08-31T17:28:54.564Z". It will be set the same as createTime if no free trial promotion is specified.
          - `lineItemIndex` integer: Output only. A unique index of the subscription line item.
          - `lineItemPromotionSpecs` SubscriptionPromotionSpec[]: Optional. The promotions applied on the line item. It can be: - an introductory pricing promotion. - a free trial promotion. This feature is not enabled. If used, the request will be rejected. When used as input in Create or Provision API, specify its resource name only.
            - `freeTrialDuration` Duration: Describes the length of a period of a time.
              - …
            - `introductoryPricingDetails` PromotionIntroductoryPricingDetails: The details of a introductory pricing promotion.
              - …
            - `promotion` string: Required. Promotion resource name that identifies a promotion. The format is 'partners/{partner_id}/promotions/{promotion_id}'.
            - `type` 'PROMOTION_TYPE_UNSPECIFIED' | 'PROMOTION_TYPE_FREE_TRIAL' | 'PROMOTION_TYPE_INTRODUCTORY_PRICING': Output only. The type of the promotion for the spec.
          - `name` string: Identifier. Resource name of the line item. Format: partners/{partner}/subscriptions/{subscription}/lineItems/{lineItem}
          - `oneTimeRecurrenceDetails` SubscriptionLineItemOneTimeRecurrenceDetails: Details for a ONE_TIME recurrence line item.
            - `servicePeriod` ServicePeriod: A description of what time period or moment in time the product or service is being delivered over.
              - …
          - `planType` 'LINE_ITEM_PLAN_TYPE_UNSPECIFIED' | 'LINE_ITEM_PLAN_TYPE_BASE' | 'LINE_ITEM_PLAN_TYPE_ADDON': Optional. Output only. The plan type of the line item.
          - `product` string: Required. Product resource name that identifies the product associated with this line item. The format is 'partners/{partner_id}/products/{product_id}'.
          - `productPayload` ProductPayload: Specifies product specific payload.
            - `googleHomePayload` GoogleHomePayload: Payload specific for Google Home products.
              - …
            - `googleOnePayload` GoogleOnePayload: Payload specific to Google One products.
              - …
            - `youtubePayload` YoutubePayload: Payload specific to Youtube products.
              - …
          - `recurrenceType` 'LINE_ITEM_RECURRENCE_TYPE_UNSPECIFIED' | 'LINE_ITEM_RECURRENCE_TYPE_PERIODIC' | 'LINE_ITEM_RECURRENCE_TYPE_ONE_TIME': Output only. The recurrence type of the line item.
          - `state` 'LINE_ITEM_STATE_UNSPECIFIED' | 'LINE_ITEM_STATE_ACTIVE' | 'LINE_ITEM_STATE_INACTIVE' | 'LINE_ITEM_STATE_NEW' | 'LINE_ITEM_STATE_ACTIVATING' | 'LINE_ITEM_STATE_DEACTIVATING' | 'LINE_ITEM_STATE_WAITING_TO_DEACTIVATE' | 'LINE_ITEM_STATE_OFF_CYCLE_CHARGING': Output only. The state of the line item.
        - `migrationDetails` SubscriptionMigrationDetails: Describes the details of the migrated subscription.
          - `legacyCreationTime` string, google-datetime: Output only. The creation time of the migrated subscription in the legacy system.
          - `migratedSubscriptionId` string: Output only. The migrated subscription id in the legacy system.
        - `name` string: Identifier. Resource name of the subscription. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}". This is available for authorizeAddon, but otherwise is response only.
        - `partnerUserToken` string: Required. Identifier of the end-user in partner’s system. The value is restricted to 63 ASCII characters at the maximum.
        - `processingState` 'PROCESSING_STATE_UNSPECIFIED' | 'PROCESSING_STATE_CANCELLING' | 'PROCESSING_STATE_RECURRING' | 'PROCESSING_STATE_RESUMING' | 'PROCESSING_STATE_SUSPENDING': Output only. Describes the processing state of the subscription. See more details at [the lifecycle of a subscription](/payments/reseller/subscription/reference/index/Receive.Notifications#payments-subscription-lifecycle).
        - `products` string[]: Optional. Deprecated: consider using `line_items` as the input. Required. Resource name that identifies the purchased products. The format will be 'partners/{partner_id}/products/{product_id}'.
        - `promotionSpecs` SubscriptionPromotionSpec[]: Optional. Subscription-level promotions. Only free trial is supported on this level. It determines the first renewal time of the subscription to be the end of the free trial period. Specify the promotion resource name only when used as input.
          - `freeTrialDuration` Duration: Describes the length of a period of a time.
            - `count` integer: number of duration units to be included.
            - `unit` 'UNIT_UNSPECIFIED' | 'MONTH' | 'DAY' | 'HOUR': The unit used for the duration
          - `introductoryPricingDetails` PromotionIntroductoryPricingDetails: The details of a introductory pricing promotion.
            - `introductoryPricingSpecs` PromotionIntroductoryPricingDetailsIntroductoryPricingSpec[]: Output only. Specifies the introductory pricing periods.
              - …
          - `promotion` string: Required. Promotion resource name that identifies a promotion. The format is 'partners/{partner_id}/promotions/{promotion_id}'.
          - `type` 'PROMOTION_TYPE_UNSPECIFIED' | 'PROMOTION_TYPE_FREE_TRIAL' | 'PROMOTION_TYPE_INTRODUCTORY_PRICING': Output only. The type of the promotion for the spec.
        - `promotions` string[]: Optional. Deprecated: consider using the top-level `promotion_specs` as the input. Optional. Resource name that identifies one or more promotions that can be applied on the product. A typical promotion for a subscription is Free trial. The format will be 'partners/{partner_id}/promotions/{promotion_id}'.
        - `purchaseTime` string, google-datetime: Optional. The timestamp when the user transaction was made with the Partner. Specify for the case of "bundle with choice", and it must be before the provision_time (when the user makes a selection).
        - `redirectUri` string: Output only. The place where partners should redirect the end-user to after creation. This field might also be populated when creation failed. However, Partners should always prepare a default URL to redirect the user in case this field is empty.
        - `renewalTime` string, google-datetime: Output only. The time at which the subscription is expected to be renewed by Google - a new charge will be incurred and the service entitlement will be renewed. A non-immediate cancellation will take place at this time too, before which, the service entitlement for the end user will remain valid. UTC timezone in ISO 8061 format. For example: "2019-08-31T17:28:54.564Z"
        - `serviceLocation` Location: Describes a location of an end user.
          - `postalCode` string: The postal code this location refers to. Ex. "94043"
          - `regionCode` string: 2-letter ISO region code for current content region. Ex. “US” Please refers to: https://en.wikipedia.org/wiki/ISO_3166-1
        - `state` 'STATE_UNSPECIFIED' | 'STATE_CREATED' | 'STATE_ACTIVE' | 'STATE_CANCELLED' | 'STATE_IN_GRACE_PERIOD' | 'STATE_CANCEL_AT_END_OF_CYCLE' | 'STATE_SUSPENDED': Output only. Describes the state of the subscription. See more details at [the lifecycle of a subscription](/payments/reseller/subscription/reference/index/Receive.Notifications#payments-subscription-lifecycle).
        - `updateTime` string, google-datetime: Output only. System generated timestamp when the subscription is most recently updated. UTC timezone.
        - `upgradeDowngradeDetails` SubscriptionUpgradeDowngradeDetails: Details about the previous subscription that this new subscription upgrades/downgrades from.
          - `billingCycleSpec` 'BILLING_CYCLE_SPEC_UNSPECIFIED' | 'BILLING_CYCLE_SPEC_ALIGN_WITH_PREVIOUS_SUBSCRIPTION' | 'BILLING_CYCLE_SPEC_START_IMMEDIATELY' | 'BILLING_CYCLE_SPEC_DEFERRED_TO_NEXT_RECURRENCE': Required. Specifies the billing cycle spec for the new upgraded/downgraded subscription.
          - `previousSubscriptionId` string: Required. The previous subscription id to be replaced. The format can be one of the following: 1. `subscription_id`: the old subscription id under the same partner_id. 2. `partners/{partner_id}/subscriptions/{subscription_id}`. A different partner_id is allowed. But they must be under the same partner group.
      - `subscriptionId` string: Required. Identifies the subscription resource on the Partner side. The value is restricted to 63 ASCII characters at the maximum. If a subscription was previously created with the same subscription_id, we will directly return that one.
    - `entitleIntent` EntitleSubscriptionIntent: Intent for entitling the previously provisioned subscription to an end user.
      - `name` string: Required. The name of the subscription resource that is entitled to the current end user. It is in the format of "partners/{partner_id}/subscriptions/{subscriptionId}".
    - `intentOptions` IntentPayloadIntentOptions: The options for the intent.
      - `enableOfferOverride` boolean: Optional. If true, Google may use a different product and promotion id from the ones in the `create_intent` based on the user's eligibility. Only applicable for certain YouTube free trial offers.

## Response `200`

Successful response

- GenerateUserSessionResponse: Response that contains the details for generated user session.
  - `userSession` UserSession: Contains a short-lived token containing information required to interact with the Google Payments Reseller Platform via web endpoints. - Generate a user session token dynamically for an authenticated user. Do not share a token directly with a user in an unauthenticated context, such as SMS or email. - You can regenerate new session tokens repeatedly for the same `generate` request if necessary, regardless of whether previous tokens have expired. Multiple sessions will not result in duplicate fulfillments because the `subscription ID` guarantees uniqueness. For more integration details, see the [Google Managed Signup](/payments/reseller/subscription/reference/index/User.Signup.Integration/Google.Managed.Signup) documentation.
    - `expireTime` string, google-datetime: Output only. The time at which the user session expires.
    - `token` string: Output only. The encrypted token of the user session, including the information of the user's intent and request. This token should be provided when redirecting the user to Google.

---

[API](https://skmtc.dev/google/apis/paymentsresellersubscription.md) - [All operations](https://skmtc.dev/google/apis/paymentsresellersubscription/llms.txt) - [OpenAPI document](https://skmtc.dev/google/apis/paymentsresellersubscription/revisions/88dd477f884b?raw)
