client.KeyLogs()

Logs (CSV)

Returns a CSV of the charged lookups made on a key, one row per request.

Requires the account Management Key. The maximum interval is 90 days. Without a start or end date the interval is the last 21 days.

The response is text/csv and downloads as an attachment. A non-200 response reverts to JSON, with the error code and message in the body.

CSV format​

The CSV has no header row. Columns, in order:

  1. Timestamp (ISO 8601)
  2. IP address the request was received from
  3. Search term
  4. URL the request originated from
  5. Lookup type
  6. Tags
  7. Lookups consumed
  8. Licensee name (sublicensing keys only)
  9. Source IP address

The source IP column carries the address forwarded in the AZ-Source-IP header. We record it only for keys with IP address forwarding enabled, and only when the header holds a valid IP address. It is empty otherwise.

Data redaction​

We redact personally identifiable information (PII) in your usage log weekly, covering the IP, source IP, search term and URL columns.

The default retention is 28 days. Change the period from your dashboard. Set it to 0 days to stop collecting PII altogether.

Endpoint​

GET /keys/{key}/lookups

See the API reference for this endpoint.

This operation needs a Management Key. Pass it with addresszen.WithManagementKey(...) when you create the client, which sends it in the Authorization header. See setup.

Signature​

func (c *Client) KeyLogs(ctx context.Context, key string, params *KeyLogsParams) (string, error)

Arguments​

NameTypeRequiredDescription
ctxcontext.ContextyesCancels the request and sets its deadline.
keystringyesAPI Key
params*KeyLogsParamsnoOptional query parameters, or nil. Fields under Query Parameters.

Query Parameters​

A required parameter is a method argument. Set the rest as fields of params, named in Studly case (post_town is PostTown); a field left at its zero value is not sent.

NameTypeRequiredDescription
starttime.TimenoStart Timestamp
endtime.TimenoEnd Timestamp
licenseestringnoLicensee Key

Response​

The CSV text, as a string.

Errors​

An HTTP error returns *addresszen.APIError with the HTTP status, the API error code and the body; match it with errors.AsType. A transport failure returns the net/http error, wrapped. See error handling.

Example​

key-logs/main.gogo
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	addresszen "go.addresszen.com/sdk"
)

func main() {
	client := addresszen.NewClient("ak_test", addresszen.WithManagementKey("uk_test"))
	now := time.Now()
	logs, err := client.KeyLogs(context.Background(), "ak_test", &addresszen.KeyLogsParams{
		Start: now.AddDate(0, 0, -7),
		End:   now,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Print(logs)
}