Add an Entry to the Audit Log API

On this page

This API allows you to insert an Audit Log. Generally, Audit Logs are created automatically whenever an admin does something from the FusionAuth UI. However, you can use this API to insert Audit Logs directly if you need.

Request#

Send the message and user responsible for the action in the request body, along with any optional details.

API Key Authentication
Create an Audit Log
POST/api/system/audit-log
OpenAPI Spec

Request Body#

auditLog.data
  • Type: Object
  • Optional

An object that can hold additional details of an audit log.

auditLog.newValue
  • Type: String
  • Optional

Intended to be utilized during a change to record the new value.

auditLog.oldValue
  • Type: String
  • Optional

Intended to be utilized during a change to record the old value prior to the change.

auditLog.reason
  • Type: String
  • Optional

Intended to be utilized during a change to indicate the reason for the modification.

auditLog.tenantId
  • Type: UUID
  • Optional
  • Available since 1.65.0

The Id of the Tenant associated with this Audit Log. This field will be overridden if the request contains an X-FusionAuth-TenantId header, or if the supplied API key is scoped to a specific Tenant.

auditLog.insertUser
  • Type: String
  • Required

The user that took the action that is being written to the Audit Logs. We suggest you use email addresses for this field.

auditLog.message
  • Type: String
  • Required

The message of the Audit Log.

eventInfo
  • Type: Object
  • Optional

Information about the request. FusionAuth adds the information to the events the request triggers, as event.info. For more information, see Pass Context From API Requests to Webhooks.

eventInfo.data
  • Type: Object
  • Optional

An object that holds any JSON you choose, such as a trace Id. FusionAuth copies the object to event.info.data without changes.

eventInfo.deviceDescription
  • Type: String
  • Optional

A description of the end user's device.

eventInfo.deviceName
  • Type: String
  • Optional

The name of the end user's device.

eventInfo.deviceType
  • Type: String
  • Optional

The type of the end user's device.

eventInfo.ipAddress
  • Type: String
  • Optional

The IP address of the end user. When your server calls FusionAuth for the end user, set this value to the end user's IP address. When this value is omitted, FusionAuth uses the IP address of the client that sent the request.

eventInfo.os
  • Type: String
  • Optional

The operating system of the end user's device.

eventInfo.userAgent
  • Type: String
  • Optional

The user agent of the end user's browser.

Example Request JSON
{
  "auditLog": {
    "data": {
      "externalId": "_applicationA"
    },
    "newValue:": "{\"name\": \"bar\"}",
    "oldValue": "{\"name\": \"foo\"}",
    "reason": "Because I like to change things.",
    "insertUser": "user@fusionauth.io",
    "message": "Example audit log"
  }
}

Response#

The response for this API does not contain a body. It only contains a status code.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present.
401FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes.
503The search index is unavailable or returned an error, so FusionAuth can't complete the request. The response contains a JSON body.