Skip to main content
The Go SDK exposes Commerce V1 under client.Commerce.
ctx := context.Background()
client := grantex.NewClient("gx_live_...")

profile, err := client.Commerce.GetProfile(ctx, "mch_shopify_mgx0n6_22")
if err != nil {
    return err
}
fmt.Println(profile.Merchant["merchant_id"])

products, err := client.Commerce.SearchCatalog(ctx, grantex.CommerceRecord{
    "merchant_id": "mch_shopify_mgx0n6_22",
    "query":       "lamp",
    "limit":       3,
})
if err != nil {
    return err
}
fmt.Println(products.Items)

Idempotent Writes

Commerce write operations that can create payment-affecting resources take an idempotency key argument. The SDK sends it as the Idempotency-Key header, not in the JSON body.
cart, err := client.Commerce.CreateCart(ctx, grantex.CommerceRecord{
    "merchant_id": "mch_shopify_mgx0n6_22",
    "currency":    "INR",
    "line_items": []grantex.CommerceRecord{
        {"variant_id": "var_123", "quantity": 1},
    },
}, "cart-2026-06-14-001")

MCP Tool Calls

result, err := client.Commerce.MCP(ctx, grantex.CommerceRecord{
    "jsonrpc": "2.0",
    "id":      "catalog-search-1",
    "method":  "tools/call",
    "params": grantex.CommerceRecord{
        "name": "catalog.search",
        "arguments": grantex.CommerceRecord{
            "merchant_id": "mch_shopify_mgx0n6_22",
            "query":       "lamp",
            "limit":       1,
        },
    },
})

Ops And Webhooks

health, err := client.Commerce.GetOpsHealth(ctx, map[string]string{
    "merchant_id": "mch_shopify_mgx0n6_22",
    "environment": "live",
})

_, err = client.Commerce.HandleProviderWebhook(ctx, "plural", grantex.CommerceRecord{}, nil)
if err != nil {
    // Missing or invalid provider signatures fail closed.
}

Common Methods

MethodPurpose
GetProfileFetch the public Commerce V1 merchant profile
SearchCatalog / ListCatalogProductsGround agent shopping flows in merchant catalog data
CreateCart / GetCartCreate and read Commerce carts
CreateConsentRequest / ExchangeConsentForPassportRequest buyer consent and mint Commerce Passports
VerifyPassport / RevokePassportVerify or revoke Commerce Passports
CreatePaymentIntent / GetPaymentIntentCreate and inspect provider-neutral payment intents
CreateCheckoutLinkCreate hosted checkout handoff links
CreateProviderCredential / ValidateProviderCredentialManage provider credential metadata and validation
GetOpsHealth / ListProviderWebhookEventsRun operator health and webhook queue checks