Preloader

      How to Connect an Existing Customer with a Cart Created with Sales Channel API in Shopware 6

      Introduction

      Shopware 6 is a powerful and flexible eCommerce platform that enables developers to build seamless shopping experiences. One of its key strengths is the comprehensive API system, especially the Sales Channel API, which allows you to programmatically manage customer sessions, carts, and checkouts.

      Whether you’re building a headless storefront, a custom integration, or just need more control over your checkout process, being able to connect an existing customer to a cart is essential. This guide walks you through the step-by-step process of creating a cart and linking it to an existing customer using Shopware 6’s Sales Channel API.

      Let’s dive into the technical steps to ensure your cart and customer connection runs smoothly.

      Step 1: Set Up Your Environment

      • API credentials (Sales Channel ID and API Key)
      • API client (like Postman or any HTTP client)

      Step 2: Create a New Cart

      First, create a new cart using the Sales Channel API.

      Request

      				
      					POST /sales-channel-api/v3/checkout/cart
      Authorization: Bearer <your_access_token>
      				
      			

      Response:

      				
      					{
        "token": "cart-token"
      }
      				
      			

      This will return a cart-token which will be used to identify the cart in subsequent requests.

      Step 3: Get the Customer's ID

      Retrieve the existing customer’s ID. If you don’t have it, you can search for the customer using their email or other identifying information.

      Request

      				
      					GET /api/v3/search/customer
      Authorization: Bearer <your_admin_access_token>
      Content-Type: application/json
      {
        "filter": [
          {
            "type": "equals",
            "field": "email",
            "value": "customer@example.com"
          }
        ]
      }
      				
      			

      Response

      				
      					{
        "data": [
          {
            "id": "customer-id",
            "attributes": {
              "firstName": "John",
              "lastName": "Doe",
              "email": "customer@example.com"
            }
          }
        ]
      }
      				
      			

      Step 4: Connect the Customer to the Cart

      Now, assign the customer to the cart using the customer-login endpoint.

      Request

      				
      					POST /sales-channel-api/v3/checkout/cart/customer-login
      Authorization: Bearer <your_access_token>
      Content-Type: application/json
      
      {
        "username": "customer@example.com",
        "password": "customer-password",
        "cartId": "cart-token"
      }
      				
      			

      Ensure that the username and password are correct for the customer. The cartId should be the cart-token received when the cart was created.

      Response

      				
      					{
        "contextToken": "new-context-token"
      }
      				
      			

      This response provides a new contextToken which you will use for further operations on this cart.

      Step 5: Verify the Connection

      To verify that the customer is connected to the cart, you can retrieve the cart details and check if the customer information is present.

      Request

      				
      					GET /sales-channel-api/v3/checkout/cart
      Authorization: Bearer <new-context-token>
      				
      			

      Response

      				
      					{
        "data": {
          "name": "Test",
          "email": "customer@example.com",
          ...
        }
      }
      				
      			

      Conclusion

      You have successfully connected an existing customer to a cart created using the Sales Channel API in Shopware 6. You can now proceed with adding items to the cart, and updating customer details. For more advanced implementations or custom integrations, leveraging professional Shopware development services can help ensure a smooth and scalable solution tailored to your business needs.

      Our Services

      Related Blogs

      Top 5 Best Hyvä Theme Development Companies & Agencies in the Netherlands 2026

      Top 5 Best Hyvä Theme Development Companies & Agencies in the Netherlands 2026

      TL ; DR Quick Summary: Looking for the best Hyvä theme development […]

      Top 5 Best Roofer Marketing Companies USA & Roofing Digital Marketing Agencies in USA For 2026

      Top 5 Best Roofer Marketing Companies USA & Roofing Digital Marketing Agencies in USA For 2026

      These days, most homeowners open Google before they ever pick up the […]

      Top 5 Trusted Shopware Agencies in India (2026)for B2B & B2C Brands

      Top 5 Trusted Shopware Agencies in India (2026)for B2B & B2C Brands

      In 2026, Shopware continues to strengthen its position in the global Shopware […]