November 23, 2017


Cancel Global Ip Address

This example shows how to cancel a Global IP Address.
See below for more details.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
package main

import (

func main() {
	// SoftLayer API username and key
	username := "set me"
	apikey   := "set me"

	// The id  of Global IP Address you wish to cancel.
	globalIpId := 61823

	// Create SoftLayer API session
	sess := session.New(username, apikey)

	// Get SoftLayer_Network_Subnet_IpAddress_Global and SoftLayer_Billing_Item services
	globalIpService  := services.GetNetworkSubnetIpAddressGlobalService(sess)
	billingService  := services.GetBillingItemService(sess)

	// Declare mask used to get the id of billing item
	mask := "id;billingItem[id]"

	// Call to getObject() method in order to get global ip data according to mask
	globalIp, err := globalIpService.Id(globalIpId).Mask(mask).GetObject()
	if err != nil {
		fmt.Printf("\n Unable to get the Global Ip Address\n - %s\n", err)

	// Call to Billing_Item::cancelService method to cancel the Global Ip Address
	result, err := billingService.Id(*globalIp.BillingItem.Id).CancelService()
	if err != nil {
		fmt.Printf("\n Unable to cancel Global Ip Address\n - %s\n", err)

	// Print final result
	if result {
		fmt.Printf("\n Global Ip Address '%d' was successfuly cancelled\n", globalIpId)
	} else {
		fmt.Printf("\n Global Ip Address '%d' could not be cancelled\n", globalIpId)


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue