Go SDK for commercetools
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Travis Build Status codecov Go Report Card GoDoc

The Commercetools Go SDK was created for enabling the creation of the Terraform Provider for Commercetools. That provider enables you to use infrastructure-as-code principles with Commercetools.

This means that the SDK is not feature complete at the moment. The SDK is currently not meant for building e-commerce front-ends with it, but aimed at maintaining the configuration of such a site. A front-end can be built using one of the existing SDK's, provided and maintained by commercetools.

Using the SDK

package main

import (


func main() {

    oauth2Config := &clientcredentials.Config{
        ClientID:     "<client-id>",
        ClientSecret: "<client-secret>",
        Scopes:       []string{"manage_project:<scopes>"},
        TokenURL:     "https://auth.sphere.io/oauth/token",
    httpClient := oauth2Config.Client(context.TODO())

    // Create the new client. When an empty value is passed it will use the CTP_*
    // environment variables to get the value. The HTTPClient arg is optional,
    // and when empty will automatically be created using the env values.
    client := commercetools.New(&commercetools.Config{
        ProjectKey: "<project-key>",
        URL:        "https://api.sphere.io",
        HTTPClient: httpClient,

    svc := products.New(client)
    product, err := svc.ProductCreate(&products.ProductDraft{
        Key: "test-product",
        Name: commercetools.LocalizedString{
            "nl": "Een test product",
            "en": "A test product",
        ProductType: commercetools.Reference{
            TypeID: "product-type",
            ID:     "8750e1fd-f431-481f-9296-967b1e56bf49",
        Slug: commercetools.LocalizedString{
            "nl": "een-test-product",
            "en": "a-test-product",
    if err != nil {


Service implementation

At the moment the SDK has service coverage for primarily Terraform configuration use-cases, for example declaring API Extensions, Subscriptions and Project Settings. Broader coverage will be implemented if our use-cases require it or via contributions of course!

Product Catalog

  • Categories
  • Products
  • Product Projections
  • Product Projections Search
  • Product Suggestions
  • Inventory
  • Reviews

Pricing & Discounts

  • Tax Categories
  • Product Discounts
  • Cart Discounts
  • Discount Codes

Carts, Orders & Shopping Lists

  • Shopping Lists beta
  • My Shopping Lists beta
  • Carts
  • My Carts beta
  • Shipping Methods
  • Shipping Zones
  • Payments
  • My Payments beta
  • Orders
  • My Orders beta
  • Order Import


  • Customers
  • My Customer Profile beta
  • Customer Groups


  • Project Settings
  • Channels
  • State Machines

Customize Data

  • Product Types
  • Types
  • Custom Fields
  • Custom Objects

Customize Behavior

  • API Extensions beta
  • Subscriptions beta
  • Messages Query