API Reference

API usage
API authentication using user tokens

Whenever a user successfully logs in to your VTEX store, VTEX ID generates a JWT user token and sets it as the VtexIdclientAutCookie cookie.

For a period of 24 hours after its creation, the user token can be used to authenticate requests to VTEX APIs. To do this, send it as a header named VtexIdclientAutCookie.

User tokens allow for actions limited to their scope, which is defined according to the user who logged in:

  • Shopper: Shoppers' tokens have permission to perform actions related to the shopping experience, such as viewing active products' information, placing orders, and viewing information of orders made under that same shopper profile. This token scope does not allow users to access the VTEX Admin panel or change logistics settings, for example.
  • Admin: Administrative users' tokens allow for actions based on License Manager roles attributed to them. This may include access to different Admin panel pages or the ability to edit different configurations, for example.

As described above, user tokens and associated permissions are tied to the user who logged in. However, they are not store-exclusive. This means, for example, that administrative users with access to different accounts can perform actions in all of those stores with the same token.

Generating user tokens

Developers working with VTEX can generate authentication tokens without having to simulate a shopper’s login. This can be useful to run tests or even to generate tokens programmatically if your integration depends on an API that can not be authenticated with application keys. There are two methods you can use:

Generating a user token with the VTEX IO CLI

  1. Install the VTEX IO CLI.

  2. Log in to VTEX by running the following command on your terminal. Remember to replace the {accountName} value with your VTEX account name.

    vtex login {accountName}

  3. Once you are logged in to your VTEX account, run this command to generate a user token:

    vtex local token

    With this, the CLI will generate a valid user token associated with your profile, print it to your terminal and also copy it to your clipboard.

Generating an authentication token with the VTEX ID API

To do this, use the Generate authentication token endpoint.

Note that the token generated by this API endpoint is not tied to a user profile but to an application key, which means this token's permissions are the same as defined to the credential pair, instead of having the same permissions as the logged in user. Still, you can use this token to authenticate API requests in the same way as a regular user token, informing its value in the VtexIdclientAutCookie header.

Photo of the contributor
+ 1 contributors
Was this helpful?
Suggest edits (Github)
Photo of the contributor
+ 1 contributors
On this page