Documentation
Feedback
Guides
API Reference

Guides
Guides
B2B
B2B Buyer Portal

B2B session data

Learn how to retrieve and interpret B2B session data enriched by the Shopper Session app, including payment methods, catalog access, and addresses.

This feature is only available to stores using B2B Buyer Portal, which is currently available for selected accounts.

The vtex_session cookie stores a snapshot of the buyer's session state. For B2B stores, this session is enriched with organization and contract data by the Shopper Session app, covering payment methods, catalog access, and available addresses. This enrichment is available under the public.facets and shopper namespaces.

This guide explains how to retrieve and interpret that data.

Retrieving session data

To retrieve the current B2B session data for a logged-in buyer, send a GET Get Session request including the public.facets and shopper namespaces:


_10
GET /api/sessions?items=public.facets,shopper.scopes,shopper.defaults,shopper.firstName,shopper.lastName
_10
Cookie: vtex_session=<current-session-token>

Response example:


_51
{
_51
"namespaces": {
_51
"public": {
_51
"facets": {
_51
"value": "productClusterIds=138;productClusterIds=139;productClusterIds=141;productClusterIds=not:140"
_51
}
_51
},
_51
"shopper": {
_51
"scopes": {
_51
"value": {
_51
"vtex.checkout": {
_51
"creditCards": "visa,mastercard"
_51
},
_51
"vtex.payments": {
_51
"paymentSystemIds": "1,2,3"
_51
},
_51
"vtex.catalog": {
_51
"collectionIds": "138,139,141",
_51
"excludeCollectionIds": "140"
_51
},
_51
"vtex.master-data": {
_51
"AD": [
_51
{
_51
"ids": ["addr-1", "addr-2"]
_51
}
_51
],
_51
"customFieldValues": [
_51
{
_51
"field": "name",
_51
"value": "customField1",
_51
"ids": ["field-1", "field-2"]
_51
}
_51
]
_51
}
_51
}
_51
},
_51
"defaults": {
_51
"value": {
_51
"shippingAddress": "default-address-id",
_51
"paymentMethod": "default-payment-method"
_51
}
_51
},
_51
"firstName": {
_51
"value": "John"
_51
},
_51
"lastName": {
_51
"value": "Doe"
_51
}
_51
}
_51
}
_51
}

shopper.scopes sub-namespaces

The shopper.scopes value is divided into sub-namespaces, each representing a different area of the buyer's organization scope.

Sub-namespaceDescription
vtex.checkoutCredit card types (creditCards) allowed for the buyer's organization.
vtex.paymentsPayment system IDs (paymentSystemIds) available to the buyer based on their contract.
vtex.catalogCollection IDs the buyer has access to (collectionIds), and excluded collection IDs (excludeCollectionIds), restricting the product catalog to what is permitted by their contract.
vtex.master-dataAddress IDs associated with the buyer's organization unit (AD), and custom organization fields (customFieldValues).

public.facets

The public.facets value embeds the buyer's catalog access as a query string in the productClusterIds format, prefixing excluded collections with not:. For example, productClusterIds=138;productClusterIds=not:140 grants access to collection 138 and excludes collection 140.

shopper.defaults, firstName, and lastName

  • shopper.defaults holds the buyer's default values, such as shippingAddress and paymentMethod.
  • shopper.firstName and shopper.lastName hold the buyer's name.

Session data expiration and refresh

This session data is a snapshot taken at session creation time. If the buyer's contract changes after the session is created (for example, a new address is added or a credit limit is updated), the session data will not reflect those changes until a new session is created or the session is explicitly refreshed.

By default, the vtex_session cookie has a fixed 5-day expiration.

Learn more

Contributors
2
Photo of the contributor julia-rabello
Photo of the contributor kaio-donadelli
+ 2 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor julia-rabello
Photo of the contributor kaio-donadelli
+ 2 contributors
Was this helpful?
Suggest edits (GitHub)
On this page