November 23, 2017


Retrieve information of invoices in the account.

This script makes a single call to the getInvoices() method in the SoftLayer_Account API service
and uses a object masks to get the specific information of each invoice.

Important manual pages

Author: SoftLayer Technologies, Inc. <>
package main

import (

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

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

	// Get SoftLayer_Account service
	service := services.GetAccountService(sess)

	// Declare object mask used to get information about invoices
	mask := "id;payment;amount;invoiceTotalOneTimeAmount;invoiceTotalRecurringAmount;" +

	// Call method getInvoices() in order to retrieve SoftLayer_Billing_Invoice objects.
	invoices, err := service.Mask(mask).GetInvoices()
	if err != nil {
		fmt.Printf("\n Unable to retrieve invoices:\n - %s\n", err)

	// Following helps to print the result en JSON format.
	for _, invoice := range invoices {
		jsonFormat, jsonErr := json.MarshalIndent(invoice, "", "     ")
		if jsonErr != nil {
		fmt.Printf("\n%s", string(jsonFormat))
		// Single separator
		fmt.Printf("\n%s", strings.Repeat("-", 120))


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