Skip to content

new(guide): punchout login integration #2047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions docs/localization/punchout-login-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: "Punchout login integration"
slug: "punchout-login-integration"
excerpt: "Learn how to securely integrate external procurement systems with VTEX stores using Punchout login flows and one-time tokens."
hidden: false
createdAt: "2025-07-02T00:00:00.000Z"
updatedAt: "2025-07-02T00:00:00.000Z"
---

The Punchout login integration enables external procurement systems to authenticate users into a VTEX store without requiring manual credential input. This guide explains how to implement the [Punchout](https://developers.vtex.com/docs/guides/punchout) login flow using one-time tokens (OTT) for secure, session-based authentication.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[link-check] reported by reviewdog 🐶
🚨 Found a broken link in a Markdown Link (Error 404):
https://developers.vtex.com/docs/guides/punchout

👉 Please review this link before merging your Pull Request.


The flow supports two integration types:

* **[VTEX user flow](#vtex-user-flow):** For procurement users who exist on the VTEX platform. In this flow, the username and password are sent as part of the request body, and VTEX authorizes them.

* **[Pre-authenticated user flow](#pre-authenticated-user-flow):** For procurement users who don't exist on VTEX. In these cases, VTEX trusts the integrator to authorize these users and receive their username for login.

## How it works

The authentication flow starts with a request to a Punchout endpoint and ends with the user's browser being redirected to a store page in a logged-in state.

The authentication process creates a one-time token (OTT) and returns a URL to be accessed by the procurement system. This URL starts a user session in the VTEX store.

Example flow:

1. Request (VTEX user flow):

`https://host.com/api/authenticator/punchout/start?returnURL=/checkout`

1. Final redirect (logged-in session):

`https://host.com/checkout`

Each flow returns a URL with a short-lived token that must be accessed within 5 minutes and can only be used once.

## VTEX user flow

This flow validates the credentials of an existing VTEX user. It requires the user’s email and password. If the validation is positive, the response provides a URL that can be accessed directly via web browsers, initiating a session in the selected host.

>ℹ️ Find more details about each field in `POST` in [Start VTEX user punchout flow](https://developers.vtex.com/docs/api-reference/api-reference/punchout-api#post-/api/authenticator/punchout/start).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[link-check] reported by reviewdog 🐶
🚨 Found a broken link in a Markdown Link (Error 404):
https://developers.vtex.com/docs/api-reference/api-reference/punchout-api#post-/api/authenticator/punchout/start

👉 Please review this link before merging your Pull Request.


### Request example

```json
curl -X POST "https://store.myvtex.com/api/authenticator/punchout/start?returnURL=/checkout" \
-H "Content-Type: application/json" \
-d '{
"username": "[email protected]",
"password": "vtex_user_password"
}'
```

### Response body example

```json
{
"url": "https://apiexamples.com/punchout/redirect/OTT123"
}
```

## Pre-authenticated user flow

This flow is used when the procurement user doesn’t exist on VTEX. In this case, a password isn't required. An authenticated integration, using a valid API key/API token pair associated with a role that has the `CanPunchout` permission, generates an OTT on behalf of the user. Other authentication methods (such as `VtexIdClientAutCookie`) don't work for this endpoint.

If the validation is positive, the response provides a URL that can be accessed directly via web browsers, initiating a session created with the username provided in the request body.

>ℹ️ Find more details about each field in `POST` in [Start pre-authenticated user punchout flow](https://developers.vtex.com/docs/api-reference/punchout-api#post-/api/authenticator/punchout/authenticated/start).

### Request example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD024/no-duplicate-heading Multiple headings with the same content [Context: "### Request example"]


```json
curl -X POST "https://store.myvtex.com/api/authenticator/punchout/authenticated/start?returnURL=/checkout" \
-H "Content-Type: application/json" \
-H "X-VTEX-API-AppKey: your-app-key" \
-H "X-VTEX-API-AppToken: your-app-token" \
-d '{
"username": "[email protected]"
}'
```

### Response body example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD024/no-duplicate-heading Multiple headings with the same content [Context: "### Response body example"]


```json
{
"url": "https://apiexamples.com/punchout/redirect/OTT123"
}
```

## Security mechanisms

Punchout login flows use the following security mechanisms to protect credentials and redirect behavior:

* **One-Time Tokens (OTT)**: Tokens expire after 5 minutes and can be used only once.

* **Secure credential handling**: Credentials are validated directly against the VTEX user database (VTEX user flow) or the request is made with secure API credentials (pre-authenticated flow).

* **Redirect protection**: The `returnURL` is validated against authorized hosts to avoid open redirects.
Loading