> Portal Navigation:
>
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt
# CreateRedirectSession
# Package: headless
# Namespace: RedirectSessionService
# Method link: https://dev.wix.com/docs/api-reference/business-management/headless/redirects/create-redirect-session.md
## Permission Scopes:
View SEO Settings: SCOPE.PROMOTE.VIEW-SEO
## Introduction
Creates a URL for redirecting a visitor from an external client site to a Wix page for Wix-managed functionality.
The Create Redirect Session method enables your external Wix Headless client site, built on any platform, to integrate Wix-managed frontend functionality for specific processes.
For example, your site can temporarily redirect a visitor to Wix for authentication, or for a checkout process for bookings, eCommerce, events, or paid plans transactions.
To initiate a redirect session:
1. Call Create Redirect Session with the details required for Wix to take care of one specific process (for example, authentication or a bookings checkout). Provide one or more callback URLs, so Wix can redirect the visitor back to your site as appropriate when the process is over.
1. Redirect your visitor to the URL provided in the response. This URL includes query parameters informing Wix where to redirect the visitor back to on your external site.
1. Make sure the pages at the callback URLs you provided take care of the next stages in your visitor flow.
> **Note**: When creating a redirect session for a multilingual site:
>
> * If you don't specify the `lang` parameter in `additional_query_parameters` and the request contains an `x-wix-linguist` header, the language from the header will be added to the redirect URL as `lang`.
> * If you specify the `lang` parameter, it takes priority over the header.
---
## REST API
### Schema
```
Method: createRedirectSession
Description: Creates a URL for redirecting a visitor from an external client site to a Wix page for Wix-managed functionality. The Create Redirect Session method enables your external Wix Headless client site, built on any platform, to integrate Wix-managed frontend functionality for specific processes. For example, your site can temporarily redirect a visitor to Wix for authentication, or for a checkout process for bookings, eCommerce, events, or paid plans transactions. To initiate a redirect session: 1. Call Create Redirect Session with the details required for Wix to take care of one specific process (for example, authentication or a bookings checkout). Provide one or more callback URLs, so Wix can redirect the visitor back to your site as appropriate when the process is over. 1. Redirect your visitor to the URL provided in the response. This URL includes query parameters informing Wix where to redirect the visitor back to on your external site. 1. Make sure the pages at the callback URLs you provided take care of the next stages in your visitor flow. > **Note**: When creating a redirect session for a multilingual site: > > * If you don't specify the `lang` parameter in `additional_query_parameters` and the request contains an `x-wix-linguist` header, the language from the header will be added to the redirect URL as `lang`. > * If you specify the `lang` parameter, it takes priority over the header.
URL: https://www.wixapis.com/headless/v1/redirect-session
Method: POST
Method parameters:
param name: callbacks | type: CallbackParams
- name: thankYouPageUrl | type: string | description: The URL for a custom thank you page implemented on a site outside of Wix. The visitor is directed to this page after the Wix-managed process is completed. When redirecting to this URL, Wix passes different query parameters depending on the preceding transaction: After a pricing plans checkout: + `planOrderId`: GUID of a pricing plan order. After an eCommerce checkout: + `orderId`: GUID of an eCommerce order. After an Events checkout: + `orderNumber`: Unique order number for the transaction. + `eventId`: GUID of the event. If the process is abandoned or interrupted, the visitor is redirected to the URL specified in `postFlowUrl` instead. Default: If you don't specify a URL, the visitor is redirected to a Wix thank you page, and from there to the URL specified in `postFlowUrl`.
- name: postFlowUrl | type: string | description: The URL Wix should redirect the visitor to when the Wix-managed process is completed, abandoned, or interrupted. **Note**: For an authentication redirect, don't specify a URL here. Instead, specify one in `auth.authRequest.redirectUri`.
- name: loginUrl | type: string | description: The URL for a custom login page implemented outside of Wix. Default: If you don't specify a URL, a Wix login page is used.
- name: bookingsServiceListUrl | type: string | description: The URL for a custom bookings services page implemented outside of Wix. Default: If you don't specify a URL, a Wix bookings services page is used.
- name: cartPageUrl | type: string | description: The URL for a custom eCommerce cart page implemented outside of Wix. Default: If you don't specify a URL, a Wix cart page is used.
- name: planListUrl | type: string | description: The URL for a custom pricing plans page implemented outside of Wix. When redirecting to this URL, Wix specifies the following query parameters: + `planIds`: GUIDs of the pricing plans on the custom page. + `checkoutData`: Pass this string back in `paidPlansCheckout.checkoutData` when redirecting back to Wix for checkout. Default: If you don't specify a URL, a Wix pricing plans page is used.
- ONE-OF:
- name: bookingsCheckout | type: RedirectSessionBookingsCheckoutParams | description: Information required for generating a custom URL for a Wix Bookings checkout.
- name: timezone | type: string | description: The timezone to use when presenting the selected slot to users, in [tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) format. For example, `America/Santiago`. Default: If you don't specify a timezone, the timezone in `slotAvailability.slot.timezone` is used.
- name: slotAvailability | type: SlotAvailability | description: Required. The selected calendar slots to begin a booking checkout.
- name: slot | type: Slot | description: The slot for the corresponding session, when the session is either a single session or a specific session generated from a recurring session.
- name: serviceId | type: string | description: Service GUID.
- name: scheduleId | type: string | description: Schedule GUID.
- name: startDate | type: string | description: The start time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format. If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `start_date` is ignored.
- name: endDate | type: string | description: The end time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format. If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `end_date` is ignored.
- name: timezone | type: string | description: The timezone for which slot availability is to be calculated. Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones) when calculating availability.
- name: resource | type: SlotResource | description: The resource required for this slot. Currently, the only supported resource is the relevant staff member for the slot.
- name: name | type: string | description: Resource name. Read only.
- name: location | type: Location | description: Geographic location of the slot.
- name: id | type: string | description: Business location GUID. Available only for locations that are business locations, meaning the `location_type` is `"OWNER_BUSINESS"`.
- name: name | type: string | description: Location name.
- name: formattedAddress | type: string | description: The full address of this location.
- name: formattedAddressTranslated | type: string | description: The full translated address of this location.
- name: locationType | type: LocationType | description: Location type.
- enum:
- UNDEFINED: Undefined location type.
- OWNER_BUSINESS: The business address, as set in the site’s general settings.
- OWNER_CUSTOM: The address as set when creating the service.
- CUSTOM: The address as set for the individual session.
- name: eventId | type: string | description: GUID for the slot's corresponding event, when the event is either a single event or a specific event generated from a recurring event.
- name: bookable | type: boolean | description: Whether the slot is bookable. Bookability is determined by checking a session's open slots and booking policies. Locks are not taken into account.
- name: totalSpots | type: integer | description: Total number of spots for this slot. For example, if a session has a total of 10 spots and 3 spots are booked, `spotsTotal` is 10 and `openSpots` is 7.
- name: openSpots | type: integer | description: Number of open spots for this slot.
- name: waitingList | type: WaitingList | description: An object describing the slot's waitlist and its occupancy.
- name: totalSpots | type: integer | description: Total number of spots and open spots for this waitlist. For example, a Yoga class with 10 waitlist spots and 3 registered on the waitlist has 10 `total_spots` and 7 `open_spots`.
- name: openSpots | type: integer | description: Number of open spots for this waitlist.
- name: bookingPolicyViolations | type: BookingPolicyViolations | description: Booking policy violations for the slot.
- name: tooEarlyToBook | type: boolean | description: Bookings policy violation. Too early to book this slot.
- name: tooLateToBook | type: boolean | description: Bookings policy violation. Too late to book this slot.
- name: bookOnlineDisabled | type: boolean | description: Bookings policy violation. Online booking is disabled for this slot.
- name: validSubmissionRequired | type: boolean | description: Bookings policy violation. Intake Form submission is required for this slot.
- name: locked | type: boolean | description: Indicates whether the slot is locked because a waitlist exists. When a slot frees up, the slot is offered to the next customer on the waitlist. Read-only.
- name: ecomCheckout | type: RedirectSessionEcomCheckoutParams | description: Information required for generating a custom URL for a Wix eCommerce checkout.
- name: checkoutId | type: string | description: Required. GUID of the checkout to process. To retrieve this GUID, create a checkout and the relevant GUID is returned in the response. Create a checkout using one of the following: - SDK: [Create Checkout](https://dev.wix.com/docs/sdk/backend-modules/ecom/checkout/create-checkout.md) or [Create Checkout From Current Cart](https://dev.wix.com/docs/sdk/backend-modules/ecom/current-cart/create-checkout-from-current-cart.md). - REST: [Create Checkout From Cart](https://dev.wix.com/docs/rest/business-solutions/e-commerce/cart/create-checkout-from-cart.md).
- name: eventsCheckout | type: RedirectSessionEventsCheckoutParams | description: Information required for generating a custom URL for a Wix Events checkout.
- name: reservationId | type: string | description: Required. GUID of the temporary event reservation. Call Create Reservation ([SDK](https://dev.wix.com/docs/sdk/backend-modules/events/orders/create-reservation.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/events/orders/create-reservation.md)) to reserve a ticket temporarily and obtain a reservation GUID.
- name: eventSlug | type: string | description: Required. URL-friendly event slug, generated from the event title of the event. For example, `my-event-4`. To obtain an event slug, call Get Event ([SDK](https://dev.wix.com/docs/sdk/backend-modules/calendar/events/get-event.md) | [REST](https://dev.wix.com/docs/rest/business-management/calendar/events-v3/get-event.md)).
- name: paidPlansCheckout | type: RedirectSessionPaidPlansCheckoutParams | description: Information required for generating a custom URL for a Wix Paid Plans checkout.
- name: planId | type: string | description: Required. GUID of the paid plan selected. To get a plan GUID, call Query Public Plans ([SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/plans/query-public-plans.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/pricing-plans/pricing-plans/plans/query-public-plans.md)).
- name: checkoutData | type: string | description: For use when pricing plan selection is part of a checkout flow, only if the paid plan selection page is implemented on an external Wix Headless client site. In this case, a string is received by the external pricing plans page as a `checkoutData` query parameter. Pass this string back here when redirecting back to Wix for checkout.
- name: login | type: RedirectSessionLoginParams | description: Specify an empty object in this parameter to generate a URL for Wix login without first checking whether the visitor is authenticated.
EMPTY-OBJECT {}
- name: logout | type: RedirectSessionLogoutParams | description: Information required for generating a custom URL to log out from a Wix account. This process invalidates the visitor or member token and clears cookies associated with the Wix domain from their browser.
- name: clientId | type: string | description: Required. GUID of the OAuth app authorizing the client. To get this GUID, go to your [Headless settings](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2F{{oauth-apps-settings/manage}}) and copy the Client GUID of your OAuth app.
- name: auth | type: RedirectSessionAuthParams | description: Information required for generating a custom URL for Wix authentication.
- name: authRequest | type: AuthorizeRequest | description: Required. Details of the authorization request.
- name: clientId | type: string | description: GUID of the Wix OAuth app requesting authorization.
- name: responseType | type: string | description: Desired authorization [grant type](https://auth0.com/docs/authenticate/protocols/oauth#grant-types). Supported values: + `code`: The endpoint returns an authorization code that can be used to obtain an access token.
- name: redirectUri | type: string | description: URI to redirect the browser to after authentication and authorization. The browser is redirected to this URI whether the authentication and authorization process is successful or not.
- name: scope | type: string | description: Desired scope of access. If this field is left empty, only an access token is granted. To received a refresh token, pass `offline_access` as the value of this field.
- name: state | type: string | description: A value used to confirm the state of an application before and after it makes an authorization request. If a value for this field is set in the request, it's added to the `redirectUri` when the browser is redirected there. Learn more about [using the state parameter](https://auth0.com/docs/secure/attack-protection/state-parameters).
- name: responseMode | type: string | description: esired response format. Supported values: + `query`: The response parameters are encoded as query string parameters and added to the `redirectUri` when redirecting. + `fragment`: The response parameters are encoded as URI fragment parameters and added to the `redirectUri` when redirecting. + `web_message`: The response parameters are encoded as a JSON object and added to the body of a [web message response](https://datatracker.ietf.org/doc/html/draft-sakimura-oauth-wmrm-00). Default value: `query`
- name: codeChallenge | type: string | description: Code challenge to use for PKCE verification. This field is only used if `responseType` is set to `code`.
- name: codeChallengeMethod | type: string | description: Code challenge method to use for PKCE verification. This field is only used if `responseType` is set to `code`. Supported values: + `S256`: The code challenge is transformed using SHA-256 encyption. + `S512`: The code challenge is transformed using SHA-512 encyption.
- name: sessionToken | type: string | description: Session token of the site visitor to authorize.
- name: signInUrl | type: string | description: URL to redirect user to sign in
- name: userConsented | type: boolean | description: Indicates whether the user has consented to the requested scopes
- name: optionalLogin | type: boolean | description: Indicates whether login is optional. If true, will not redirect to the sign_in_url if user is not logged in.
- name: metaSiteId | type: string | description: The site id the authorization is requested for.
- name: prompt | type: Prompt | description: The type of prompt to use during the authorization process.
- enum:
- login: Display the login page to the member, prompting them to enter their credentials.
- none: Bypass the Wix login page and redirect the member directly to your site. This option checks if the member has an active session from a previous login and, if so, immediately redirects to the specified URL while retrieving tokens.
- name: storesProduct | type: RedirectSessionStoresProductParams | description: Information required for generating a custom URL for a Wix stores product page.
- name: productSlug | type: string | description: Required. Unique slug of the product to redirect to. To obtain a product slug, call Query Products [SDK](https://dev.wix.com/docs/sdk/backend-modules/stores/catalog-v3/products-v3/get-product-by-slug.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/stores/catalog-v3/products-v3/query-products.md)).
- name: bookingsBook | type: RedirectSessionBookingsBookParams | description: Information required for generating a custom URL for Wix bookings book page.
- name: resourceId | type: string | description: For use when filtering the bookings page by a specific resource.
param name: origin | type: origin | description: The origin of the request
param name: preferences | type: RedirectSessionPreferences
- name: useGenericWixPages | type: boolean | description: Whether to use a standard Wix template for Wix-managed pages the visitor is redirected to. Set to `false` only if your client site connects with a Wix site that has custom pages. Default: `true`
- name: maintainIdentity | type: boolean | description: Whether to maintain the identity used in the redirect to Wix (not relevant for `logout` and `auth` intents), or to use a new visitor identity. Default: `true`
- name: additionalQueryParameters | type: object | description: Map of global query parameters to append to the Wix URL. Common parameters include: - [UTM parameters](https://en.wikipedia.org/wiki/UTM_parameters): Use to track the source of site traffic. - `lang`: Use to control the displayed language of the Wix-managed page. For supported values, see [ISO 639 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).
- name: checkIfPublish | type: boolean | description: Check if Wix page for the requested intent is published and return it if possible. Otherwise, return a standard Wix template for it. Default: `false`
Return type: CreateRedirectSessionResponse
- name: redirectSession | type: RedirectSession | description: Details for redirecting the visitor to a Wix page.
- name: id | type: string | description: GUID of the redirect session created.
- name: fullUrl | type: string | description: The full URL of the Wix page to redirect the visitor to. This URL includes query parameters informing Wix where to redirect the visitor back to on the Wix Headless client site.
- name: urlDetails | type: URLDetails | description: Details about the URL of the redirect session.
- name: endpoint | type: string | description: Endpoint of the url. This includes the base URL and the path to the endpoint, without query parameters. For example: `https://mysite.com/_api/oauth2/authorize`.
- name: searchParams | type: object | description: URL query parameters.
- name: sessionToken | type: string | description: The session token to pass to the Wix page to maintain the visitor's identity.
- name: shortUrl | type: string | description: The short URL of the Wix page to redirect the visitor to. This URL includes query parameters informing Wix where to redirect the visitor back to on the Wix Headless client site.
```
### Examples
### Create a redirect session for an eCommerce checkout
```curl
curl -X POST 'https://www.wixapis.com/redirect-session/v1/redirect-session' \
-H 'authorization: ' \
-d '{
"ecomCheckout": {
"checkoutId": "7d2b240c-5c60-4580-8bc3-948bca6b4e4e"
},
"callbacks": {
"postFlowUrl": "https://www.my-store.com"
}
}'
```
---
## JavaScript SDK
### Schema
```
Method: wixClientAdmin.headless.RedirectSessionService.createRedirectSession(options)
Description: Creates a URL for redirecting a visitor from an external client site to a Wix page for Wix-managed functionality. The Create Redirect Session method enables your external Wix Headless client site, built on any platform, to integrate Wix-managed frontend functionality for specific processes. For example, your site can temporarily redirect a visitor to Wix for authentication, or for a checkout process for bookings, eCommerce, events, or paid plans transactions. To initiate a redirect session: 1. Call Create Redirect Session with the details required for Wix to take care of one specific process (for example, authentication or a bookings checkout). Provide one or more callback URLs, so Wix can redirect the visitor back to your site as appropriate when the process is over. 1. Redirect your visitor to the URL provided in the response. This URL includes query parameters informing Wix where to redirect the visitor back to on your external site. 1. Make sure the pages at the callback URLs you provided take care of the next stages in your visitor flow. > **Note**: When creating a redirect session for a multilingual site: > > * If you don't specify the `lang` parameter in `additional_query_parameters` and the request contains an `x-wix-linguist` header, the language from the header will be added to the redirect URL as `lang`. > * If you specify the `lang` parameter, it takes priority over the header.
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
Required parameters: options
Method parameters:
param name: options | type: CreateRedirectSessionOptions none | required: true
- ONE-OF: - required: true
- name: bookingsCheckout | type: RedirectSessionBookingsCheckoutParams | description: Information required for generating a custom URL for a Wix Bookings checkout.
- name: timezone | type: string | description: The timezone to use when presenting the selected slot to users, in [tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) format. For example, `America/Santiago`. Default: If you don't specify a timezone, the timezone in `slotAvailability.slot.timezone` is used.
- name: slotAvailability | type: SlotAvailability | description: Required. The selected calendar slots to begin a booking checkout.
- name: slot | type: Slot | description: The slot for the corresponding session, when the session is either a single session or a specific session generated from a recurring session.
- name: serviceId | type: string | description: Service GUID.
- name: scheduleId | type: string | description: Schedule GUID.
- name: startDate | type: string | description: The start time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format. If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `start_date` is ignored.
- name: endDate | type: string | description: The end time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format. If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `end_date` is ignored.
- name: timezone | type: string | description: The timezone for which slot availability is to be calculated. Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones) when calculating availability.
- name: resource | type: SlotResource | description: The resource required for this slot. Currently, the only supported resource is the relevant staff member for the slot.
- name: name | type: string | description: Resource name. Read only.
- name: location | type: Location | description: Geographic location of the slot.
- name: _id | type: string | description: Business location GUID. Available only for locations that are business locations, meaning the `location_type` is `"OWNER_BUSINESS"`.
- name: name | type: string | description: Location name.
- name: formattedAddress | type: string | description: The full address of this location.
- name: formattedAddressTranslated | type: string | description: The full translated address of this location.
- name: locationType | type: LocationType | description: Location type.
- enum:
- UNDEFINED: Undefined location type.
- OWNER_BUSINESS: The business address, as set in the site’s general settings.
- OWNER_CUSTOM: The address as set when creating the service.
- CUSTOM: The address as set for the individual session.
- name: eventId | type: string | description: GUID for the slot's corresponding event, when the event is either a single event or a specific event generated from a recurring event.
- name: bookable | type: boolean | description: Whether the slot is bookable. Bookability is determined by checking a session's open slots and booking policies. Locks are not taken into account.
- name: totalSpots | type: integer | description: Total number of spots for this slot. For example, if a session has a total of 10 spots and 3 spots are booked, `spotsTotal` is 10 and `openSpots` is 7.
- name: openSpots | type: integer | description: Number of open spots for this slot.
- name: waitingList | type: WaitingList | description: An object describing the slot's waitlist and its occupancy.
- name: totalSpots | type: integer | description: Total number of spots and open spots for this waitlist. For example, a Yoga class with 10 waitlist spots and 3 registered on the waitlist has 10 `total_spots` and 7 `open_spots`.
- name: openSpots | type: integer | description: Number of open spots for this waitlist.
- name: bookingPolicyViolations | type: BookingPolicyViolations | description: Booking policy violations for the slot.
- name: tooEarlyToBook | type: boolean | description: Bookings policy violation. Too early to book this slot.
- name: tooLateToBook | type: boolean | description: Bookings policy violation. Too late to book this slot.
- name: bookOnlineDisabled | type: boolean | description: Bookings policy violation. Online booking is disabled for this slot.
- name: validSubmissionRequired | type: boolean | description: Bookings policy violation. Intake Form submission is required for this slot.
- name: locked | type: boolean | description: Indicates whether the slot is locked because a waitlist exists. When a slot frees up, the slot is offered to the next customer on the waitlist. Read-only.
- name: ecomCheckout | type: RedirectSessionEcomCheckoutParams | description: Information required for generating a custom URL for a Wix eCommerce checkout.
- name: checkoutId | type: string | description: Required. GUID of the checkout to process. To retrieve this GUID, create a checkout and the relevant GUID is returned in the response. Create a checkout using one of the following: - SDK: [Create Checkout](https://dev.wix.com/docs/sdk/backend-modules/ecom/checkout/create-checkout.md) or [Create Checkout From Current Cart](https://dev.wix.com/docs/sdk/backend-modules/ecom/current-cart/create-checkout-from-current-cart.md). - REST: [Create Checkout From Cart](https://dev.wix.com/docs/rest/business-solutions/e-commerce/cart/create-checkout-from-cart.md).
- name: eventsCheckout | type: RedirectSessionEventsCheckoutParams | description: Information required for generating a custom URL for a Wix Events checkout.
- name: reservationId | type: string | description: Required. GUID of the temporary event reservation. Call Create Reservation ([SDK](https://dev.wix.com/docs/sdk/backend-modules/events/orders/create-reservation.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/events/orders/create-reservation.md)) to reserve a ticket temporarily and obtain a reservation GUID.
- name: eventSlug | type: string | description: Required. URL-friendly event slug, generated from the event title of the event. For example, `my-event-4`. To obtain an event slug, call Get Event ([SDK](https://dev.wix.com/docs/sdk/backend-modules/calendar/events/get-event.md) | [REST](https://dev.wix.com/docs/rest/business-management/calendar/events-v3/get-event.md)).
- name: paidPlansCheckout | type: RedirectSessionPaidPlansCheckoutParams | description: Information required for generating a custom URL for a Wix Paid Plans checkout.
- name: planId | type: string | description: Required. GUID of the paid plan selected. To get a plan GUID, call Query Public Plans ([SDK](https://dev.wix.com/docs/sdk/backend-modules/pricing-plans/plans/query-public-plans.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/pricing-plans/pricing-plans/plans/query-public-plans.md)).
- name: checkoutData | type: string | description: For use when pricing plan selection is part of a checkout flow, only if the paid plan selection page is implemented on an external Wix Headless client site. In this case, a string is received by the external pricing plans page as a `checkoutData` query parameter. Pass this string back here when redirecting back to Wix for checkout.
- name: logout | type: RedirectSessionLogoutParams | description: Information required for generating a custom URL to log out from a Wix account. This process invalidates the visitor or member token and clears cookies associated with the Wix domain from their browser.
- name: clientId | type: string | description: Required. GUID of the OAuth app authorizing the client. To get this GUID, go to your [Headless settings](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2F{{oauth-apps-settings/manage}}) and copy the Client GUID of your OAuth app.
- name: auth | type: RedirectSessionAuthParams | description: Information required for generating a custom URL for Wix authentication.
- name: authRequest | type: AuthorizeRequest | description: Required. Details of the authorization request.
- name: clientId | type: string | description: GUID of the Wix OAuth app requesting authorization.
- name: responseType | type: string | description: Desired authorization [grant type](https://auth0.com/docs/authenticate/protocols/oauth#grant-types). Supported values: + `code`: The endpoint returns an authorization code that can be used to obtain an access token.
- name: redirectUri | type: string | description: URI to redirect the browser to after authentication and authorization. The browser is redirected to this URI whether the authentication and authorization process is successful or not.
- name: scope | type: string | description: Desired scope of access. If this field is left empty, only an access token is granted. To received a refresh token, pass `offline_access` as the value of this field.
- name: state | type: string | description: A value used to confirm the state of an application before and after it makes an authorization request. If a value for this field is set in the request, it's added to the `redirectUri` when the browser is redirected there. Learn more about [using the state parameter](https://auth0.com/docs/secure/attack-protection/state-parameters).
- name: responseMode | type: string | description: esired response format. Supported values: + `query`: The response parameters are encoded as query string parameters and added to the `redirectUri` when redirecting. + `fragment`: The response parameters are encoded as URI fragment parameters and added to the `redirectUri` when redirecting. + `web_message`: The response parameters are encoded as a JSON object and added to the body of a [web message response](https://datatracker.ietf.org/doc/html/draft-sakimura-oauth-wmrm-00). Default value: `query`
- name: codeChallenge | type: string | description: Code challenge to use for PKCE verification. This field is only used if `responseType` is set to `code`.
- name: codeChallengeMethod | type: string | description: Code challenge method to use for PKCE verification. This field is only used if `responseType` is set to `code`. Supported values: + `S256`: The code challenge is transformed using SHA-256 encyption. + `S512`: The code challenge is transformed using SHA-512 encyption.
- name: sessionToken | type: string | description: Session token of the site visitor to authorize.
- name: signInUrl | type: string | description: URL to redirect user to sign in
- name: userConsented | type: boolean | description: Indicates whether the user has consented to the requested scopes
- name: optionalLogin | type: boolean | description: Indicates whether login is optional. If true, will not redirect to the sign_in_url if user is not logged in.
- name: metaSiteId | type: string | description: The site id the authorization is requested for.
- name: prompt | type: Prompt | description: The type of prompt to use during the authorization process.
- enum:
- login: Display the login page to the member, prompting them to enter their credentials.
- none: Bypass the Wix login page and redirect the member directly to your site. This option checks if the member has an active session from a previous login and, if so, immediately redirects to the specified URL while retrieving tokens.
- name: storesProduct | type: RedirectSessionStoresProductParams | description: Information required for generating a custom URL for a Wix stores product page.
- name: productSlug | type: string | description: Required. Unique slug of the product to redirect to. To obtain a product slug, call Query Products [SDK](https://dev.wix.com/docs/sdk/backend-modules/stores/catalog-v3/products-v3/get-product-by-slug.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/stores/catalog-v3/products-v3/query-products.md)).
- name: bookingsBook | type: RedirectSessionBookingsBookParams | description: Information required for generating a custom URL for Wix bookings book page.
- name: resourceId | type: string | description: For use when filtering the bookings page by a specific resource.
- name: callbacks | type: CallbackParams | description: Details of pages to redirect the visitor back to on the Wix Headless client site. When redirecting to any callback URL, Wix specifies the boolean `wixMemberLoggedIn` parameter. If `true`, a member logged in during the preceding Wix-managed process. **Note**: For an authentication redirect, don't specify a post-flow URL here. Instead, specify one in `auth.authRequest.redirectUri`.
- name: thankYouPageUrl | type: string | description: The URL for a custom thank you page implemented on a site outside of Wix. The visitor is directed to this page after the Wix-managed process is completed. When redirecting to this URL, Wix passes different query parameters depending on the preceding transaction: After a pricing plans checkout: + `planOrderId`: GUID of a pricing plan order. After an eCommerce checkout: + `orderId`: GUID of an eCommerce order. After an Events checkout: + `orderNumber`: Unique order number for the transaction. + `eventId`: GUID of the event. If the process is abandoned or interrupted, the visitor is redirected to the URL specified in `postFlowUrl` instead. Default: If you don't specify a URL, the visitor is redirected to a Wix thank you page, and from there to the URL specified in `postFlowUrl`.
- name: postFlowUrl | type: string | description: The URL Wix should redirect the visitor to when the Wix-managed process is completed, abandoned, or interrupted. **Note**: For an authentication redirect, don't specify a URL here. Instead, specify one in `auth.authRequest.redirectUri`.
- name: loginUrl | type: string | description: The URL for a custom login page implemented outside of Wix. Default: If you don't specify a URL, a Wix login page is used.
- name: bookingsServiceListUrl | type: string | description: The URL for a custom bookings services page implemented outside of Wix. Default: If you don't specify a URL, a Wix bookings services page is used.
- name: cartPageUrl | type: string | description: The URL for a custom eCommerce cart page implemented outside of Wix. Default: If you don't specify a URL, a Wix cart page is used.
- name: planListUrl | type: string | description: The URL for a custom pricing plans page implemented outside of Wix. When redirecting to this URL, Wix specifies the following query parameters: + `planIds`: GUIDs of the pricing plans on the custom page. + `checkoutData`: Pass this string back in `paidPlansCheckout.checkoutData` when redirecting back to Wix for checkout. Default: If you don't specify a URL, a Wix pricing plans page is used.
- name: preferences | type: RedirectSessionPreferences | description: Optional preferences for customizing redirection to Wix pages.
- name: useGenericWixPages | type: boolean | description: Whether to use a standard Wix template for Wix-managed pages the visitor is redirected to. Set to `false` only if your client site connects with a Wix site that has custom pages. Default: `true`
- name: maintainIdentity | type: boolean | description: Whether to maintain the identity used in the redirect to Wix (not relevant for `logout` and `auth` intents), or to use a new visitor identity. Default: `true`
- name: additionalQueryParameters | type: object | description: Map of global query parameters to append to the Wix URL. Common parameters include: - [UTM parameters](https://en.wikipedia.org/wiki/UTM_parameters): Use to track the source of site traffic. - `lang`: Use to control the displayed language of the Wix-managed page. For supported values, see [ISO 639 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).
- name: checkIfPublish | type: boolean | description: Check if Wix page for the requested intent is published and return it if possible. Otherwise, return a standard Wix template for it. Default: `false`
- name: origin | type: string | description: The origin of the request
Return type: PROMISE
- name: redirectSession | type: RedirectSession | description: Details for redirecting the visitor to a Wix page.
- name: _id | type: string | description: GUID of the redirect session created.
- name: fullUrl | type: string | description: The full URL of the Wix page to redirect the visitor to. This URL includes query parameters informing Wix where to redirect the visitor back to on the Wix Headless client site.
- name: urlDetails | type: URLDetails | description: Details about the URL of the redirect session.
- name: endpoint | type: string | description: Endpoint of the url. This includes the base URL and the path to the endpoint, without query parameters. For example: `https://mysite.com/_api/oauth2/authorize`.
- name: searchParams | type: object | description: URL query parameters.
- name: sessionToken | type: string | description: The session token to pass to the Wix page to maintain the visitor's identity.
- name: shortUrl | type: string | description: The short URL of the Wix page to redirect the visitor to. This URL includes query parameters informing Wix where to redirect the visitor back to on the Wix Headless client site.
```
### Examples
### createRedirectSession
```javascript
import { redirects } from '@wix/redirects';
async function createRedirectSession(options) {
const response = await redirects.createRedirectSession(options);
};
```
### createRedirectSession (with elevated permissions)
```javascript
import { redirects } from '@wix/redirects';
import { auth } from '@wix/essentials';
async function myCreateRedirectSessionMethod(options) {
const elevatedCreateRedirectSession = auth.elevate(redirects.createRedirectSession);
const response = await elevatedCreateRedirectSession(options);
}
```
### createRedirectSession (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).
```javascript
import { createClient } from '@wix/sdk';
import { redirects } from '@wix/redirects';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed
const myWixClient = createClient ({
modules: { redirects },
// Include the auth strategy and host as relevant
});
async function createRedirectSession(options) {
const response = await myWixClient.redirects.createRedirectSession(options);
};
```
---