Licensees
A licensee is one of your customers using AddressZen through your key. Sub-licensing lets a platform serve many customers from one account and one bill while tracking each customer's usage separately. The licensee methods create, list, update and cancel them.
Your key must be enabled for sub-licensing; contact us to switch one over. Every licensee method needs a Management Key. The sub-licensing guide covers billing.
Add a licensee
Call CreateLicensee() with the customer's name and address. The result carries the licensee's own key, beginning sl_, in Key, and its ID.
package main
import (
"context"
"fmt"
"log"
"os"
addresszen "go.addresszen.com/sdk"
)
func main() {
client := addresszen.NewClient("ak_test",
addresszen.WithManagementKey(os.Getenv("AZN_MANAGEMENT_KEY")))
res, err := client.CreateLicensee(context.Background(), "ak_test", addresszen.CreateLicenseeBody{
Name: new("Example Inc"),
Address: new("1010 Cauthen Ln, Alamogordo, NM"),
Postcode: new("88310"),
Whitelist: new([]string{"https://www.example.com"}),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Result.ID, res.Result.Key)
}
Postcode takes the customer's ZIP or postal code, whatever their country. Whitelist lists the URLs the licensee's key may be used from.
List licensees
ListLicensees() returns 10 per call by default and up to 100 with Limit, oldest first. Canceled licensees are left out. Query filters by name. HasMore says whether another page exists: to fetch it, set StartingAfter to the ID of the last licensee on this one.
package main
import (
"context"
"fmt"
"log"
"os"
addresszen "go.addresszen.com/sdk"
)
func main() {
client := addresszen.NewClient("ak_test",
addresszen.WithManagementKey(os.Getenv("AZN_MANAGEMENT_KEY")))
params := &addresszen.ListLicenseesParams{Limit: 100}
for {
res, err := client.ListLicensees(context.Background(), "ak_test", params)
if err != nil {
log.Fatal(err)
}
licensees := res.Result.Licensees
for _, licensee := range licensees {
fmt.Printf("%s: %d lookups today\n", licensee.Name, licensee.Daily.Count)
}
if !res.Result.HasMore || len(licensees) == 0 {
break
}
params.StartingAfter = licensees[len(licensees)-1].ID
}
}
Update or delete a licensee
Pass your key and the licensee's key:
UpdateLicensee()changes theAddress,Postcode, allowed URLs (Whitelist) orDailylimit. The name cannot change after creationRegenerateLicenseeKey()issues a newsl_key and stops the old one immediatelyDeleteLicensee()cancels the licensee and stops its key. Contact us to undo it
RetrieveLicensee() returns one licensee.
Licensee usage
Set Licensee on KeyUsageParams or KeyLogsParams. See API keys.
To send requests on a licensee's behalf, create a client with its sl_ key in place of your API key.
See CreateLicensee() and ListLicensees() for the body and parameters.