API Request Logs

An ApiRequestLog is an audit log for monitoring and troubleshooting requests made via API to your site.

Logs available through this endpoint are retained for 6 months, after which they are automatically discarded. For longer retention, use Files.com SIEM integrations to stream logs in real time to your preferred SIEM, or configure SIEM streaming to a file.

List API Request Logs

SDK Method

apirequestlog.List()

Return Object

[]*ApiRequestLog

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    api_request_log "github.com/Files-com/files-sdk-go/v3/apirequestlog"
)

apiRequestLogIterator, err := api_request_log.List(files_sdk.ApiRequestLogListParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for apiRequestLogIterator.Next() {
    apiRequestLog := apiRequestLogIterator.apiRequestLog()
}
err = apiRequestLogIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

The ApiRequestLog Object

Some of the methods above return a ApiRequestLog object. The attributes of this object are listed below.

AttributeDescription
Timestamp
date-time
Start Time of Action. Deprecrated: Use created_at.
ApiKeyId
int64
API Key ID, if applicable
ApiKeyPrefix
string
API Key Prefix, if applicable
UserId
int64
User ID
Username
string
Username
UserIsFromParentSite
boolean
true if this change was performed by a user on a parent site.
Interface
string
API Interface
RequestMethod
string
HTTP Method
RequestPath
string
Request path
RequestIp
string
IP of requesting client
RequestHost
string
Hostname the request was sent to
RequestId
string
Unique Id of the Request
ApiName
string
Name of API Endpoint
UserAgent
string
User-Agent
ErrorType
string
Error type, if applicable
ErrorMessage
string
Error message, if applicable
ResponseCode
int64
HTTP Response Code
Success
boolean
false if HTTP Response Code is 4xx or 5xx
DurationMs
int64
Duration (in milliseconds)
ImpersonatorUserId
int64
User ID of Site Admin user impersonating this user via a Read-Only session.
CreatedAt
date-time
Start Time of Action