Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
Functional AppsSession Client
Session Client GraphQL API
vtex.session-client
Version: 1.0.5
Latest version: 1.0.5

This API manages the vtex_session cookie, which holds session-related data for users. Developers can either interact with the API endpoints directly or declare this app as a dependency to leverage its React functions.

Schema overview

Query

classDiagram
  direction LR

  class Query {
    String version
    session(items [String]) Session
  }

  class SessionError {
    String type
    String message
  }

  class SessionSuccess {
    String! id
    SessionNamespaces namespaces
  }

  %% Links between classes
  Query --> Session : session
  Session --> SessionError : possibleType
  Session --> SessionSuccess : possibleType

  %% Click events
  click Query href "#query"
  click Session href "#session"
  click SessionError href "#sessionerror"
  click SessionSuccess href "#sessionsuccess"
Field(argument)TypeDescription
sessionSessionRetrieves the vtex_session cookie content if successful. The Get session endpoint from the Session Manager API is an equivalent implementation in REST. The Session union has two possible types: SessionError and SessionSuccess.
items[String]Specifies the items from the vtex_session cookie that will be returned in the response. Each string defines the namespace and value of the items, with the "{namespace}.{value}" format. If this argument isn't declared, the response will have all the items in the namespace field. Example: ["store.channel", "store.countryCode", "impersonate.canImpersonate"].

Mutation

classDiagram
    direction LR

    class Mutation {
        updateSession(fields SessionFieldsJSONInput!, items [String]) Session
    }

    class SessionError {
        String type
        String message
    }

    class SessionSuccess {
        String! id
        SessionNamespaces namespaces
    }

    %% Links between classes
    Mutation --> Session : updateSession
    Session --> SessionError : possibleType
    Session --> SessionSuccess : possibleType

    %% Click events
    click Mutation href "#mutation"
    click Session href "#session"
    click SessionError href "#sessionerror"
    click SessionSuccess href "#sessionsuccess"
Field(argument)TypeDescription
updateSessionSessionUpdates fields in the public namespace of the vtex_session cookie and returns the updated content. The Edit session endpoint from the Session Manager API is an equivalent implementation in REST. The Session union has two possible types: SessionError and SessionSuccess.
fieldsSessionFieldsJSONInput!A JSON object with the public fields to be updated. Since this is equivalent to a PATCH request, the request will have the following behavior with this field:
  • Fields that exist in the cookie and aren't declared in this field will not be changed.
  • Fields that exist in the cookie and are declared in this field will have their values updated.
  • Fields that don't exist in the cookie and are declared in this field will be created.
Example: { "foo": 123, "baz": "abc" }.
items[String]Specifies the items from the vtex_session cookie that will be returned in the response. Each string defines the namespace and value of the items. If this argument isn't declared, the response will have all the items in the namespace field. Example: ["store.channel", "store.countryCode", "impersonate.canImpersonate"].

Tip: To only show the updated fields in the response, use the public namespace along with the field name. Example: ["public.supportedLocales"].

Schema description

Arguments must be provided by the user. Required fields are marked with an exclamation mark (!).

SessionError

Field(argument)TypeDescription
typeStringSession error type.
messageStringSession error message.
Session 🔽

SessionSuccess

Field(argument)TypeDescription
idString!Session ID.
namespacesSessionNamespacesNamespaces object with the content of the vtex_session cookie. Each namespace has fields with specific information about the session. Check all the possible namespaces in the Sessions System documentation.
Session 🔽

Session

TypeDescription
SessionErrorReturned when a session error occurs. It provides the error type and message.
SessionSuccessReturned when the operation succeeds. It includes the content of the session cookie.
Query 🔼
Mutation 🔼
See also
Vtex.session Client
VTEX IO Apps
VTEX App Store
VTEX IO Apps