Inventory Audit API (v1)

https://github.com/folio-org/mod-audit

Table of contents

mod-audit API

API for retrieving events for inventory changes

/audit-data/inventory

GET /audit-data/inventory/instance/{entityId}

Get list of instance events

GET /audit-data/inventory/instance/{entityId}
URI Parameters
  • entityId: required (string)
Query Parameters
  • eventTs: (string)

    Get records earlier than specified timestamp, not including

    Example:

    1617225600000

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Inventory audit item",
  "type": "object",
  "properties": {
    "inventoryAuditItems": {
      "description": "List of inventory audit items",
      "type": "array",
      "id": "inventoryAuditItems",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "Inventory audit item",
        "properties": {
          "eventId": {
            "description": "UUID of the event",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "entityId": {
            "description": "UUID of the entity",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "eventTs": {
            "description": "Event timestamp",
            "type": "string",
            "format": "utc-millisec"
          },
          "eventDate": {
            "description": "Date time when event triggered",
            "format": "date-time",
            "type": "string"
          },
          "action": {
            "description": "Action for event (CREATE, UPDATE or DELETE)",
            "type": "string"
          },
          "userId": {
            "description": "UUID of the user who performed the action",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "diff": {
            "description": "Difference for entity cause by an action",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "object",
            "properties": {
              "fieldChanges": {
                "description": "Changes in fields",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "changeType": {
                      "type": "string",
                      "description": "Type of change",
                      "enum": [
                        "MODIFIED",
                        "REMOVED",
                        "ADDED",
                        "NOTHING"
                      ]
                    },
                    "fieldName": {
                      "description": "Name of the field",
                      "type": "string"
                    },
                    "fullPath": {
                      "description": "Full path of the field",
                      "type": "string"
                    },
                    "oldValue": {
                      "description": "Old value of the field",
                      "type": "object",
                      "javaType": "java.lang.Object"
                    },
                    "newValue": {
                      "description": "New value of the field",
                      "type": "object",
                      "javaType": "java.lang.Object"
                    }
                  },
                  "required": [
                    "changeType",
                    "fieldName",
                    "fullPath"
                  ]
                }
              },
              "collectionChanges": {
                "description": "Changes in collections",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "collectionName": {
                      "description": "Name of the collection",
                      "type": "string"
                    },
                    "itemChanges": {
                      "description": "Changes of the collection",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "changeType": {
                            "description": "Type of change",
                            "type": "string",
                            "enum": [
                              "MODIFIED",
                              "REMOVED",
                              "ADDED",
                              "NOTHING"
                            ]
                          },
                          "oldValue": {
                            "description": "Old value of the item",
                            "type": "object",
                            "javaType": "java.lang.Object"
                          },
                          "newValue": {
                            "description": "New value of the item",
                            "type": "object",
                            "javaType": "java.lang.Object"
                          }
                        },
                        "required": [
                          "changeType"
                        ]
                      }
                    }
                  },
                  "required": [
                    "collectionName",
                    "itemChanges"
                  ]
                }
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    },
    "totalRecords": {
      "description": "Total number of records",
      "type": "integer"
    }
  },
  "required": [
    "inventoryAuditItems"
  ],
  "additionalProperties": false
}

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

GET /audit-data/inventory/holdings/{entityId}

Get list of holdings events

GET /audit-data/inventory/holdings/{entityId}
URI Parameters
  • entityId: required (string)
Query Parameters
  • eventTs: (string)

    Get records earlier than specified timestamp, not including

    Example:

    1617225600000

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Inventory audit item",
  "type": "object",
  "properties": {
    "inventoryAuditItems": {
      "description": "List of inventory audit items",
      "type": "array",
      "id": "inventoryAuditItems",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "Inventory audit item",
        "properties": {
          "eventId": {
            "description": "UUID of the event",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "entityId": {
            "description": "UUID of the entity",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "eventTs": {
            "description": "Event timestamp",
            "type": "string",
            "format": "utc-millisec"
          },
          "eventDate": {
            "description": "Date time when event triggered",
            "format": "date-time",
            "type": "string"
          },
          "action": {
            "description": "Action for event (CREATE, UPDATE or DELETE)",
            "type": "string"
          },
          "userId": {
            "description": "UUID of the user who performed the action",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "diff": {
            "description": "Difference for entity cause by an action",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "object",
            "properties": {
              "fieldChanges": {
                "description": "Changes in fields",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "changeType": {
                      "type": "string",
                      "description": "Type of change",
                      "enum": [
                        "MODIFIED",
                        "REMOVED",
                        "ADDED",
                        "NOTHING"
                      ]
                    },
                    "fieldName": {
                      "description": "Name of the field",
                      "type": "string"
                    },
                    "fullPath": {
                      "description": "Full path of the field",
                      "type": "string"
                    },
                    "oldValue": {
                      "description": "Old value of the field",
                      "type": "object",
                      "javaType": "java.lang.Object"
                    },
                    "newValue": {
                      "description": "New value of the field",
                      "type": "object",
                      "javaType": "java.lang.Object"
                    }
                  },
                  "required": [
                    "changeType",
                    "fieldName",
                    "fullPath"
                  ]
                }
              },
              "collectionChanges": {
                "description": "Changes in collections",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "collectionName": {
                      "description": "Name of the collection",
                      "type": "string"
                    },
                    "itemChanges": {
                      "description": "Changes of the collection",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "changeType": {
                            "description": "Type of change",
                            "type": "string",
                            "enum": [
                              "MODIFIED",
                              "REMOVED",
                              "ADDED",
                              "NOTHING"
                            ]
                          },
                          "oldValue": {
                            "description": "Old value of the item",
                            "type": "object",
                            "javaType": "java.lang.Object"
                          },
                          "newValue": {
                            "description": "New value of the item",
                            "type": "object",
                            "javaType": "java.lang.Object"
                          }
                        },
                        "required": [
                          "changeType"
                        ]
                      }
                    }
                  },
                  "required": [
                    "collectionName",
                    "itemChanges"
                  ]
                }
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    },
    "totalRecords": {
      "description": "Total number of records",
      "type": "integer"
    }
  },
  "required": [
    "inventoryAuditItems"
  ],
  "additionalProperties": false
}

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

GET /audit-data/inventory/item/{entityId}

Get list of item events

GET /audit-data/inventory/item/{entityId}
URI Parameters
  • entityId: required (string)
Query Parameters
  • eventTs: (string)

    Get records earlier than specified timestamp, not including

    Example:

    1617225600000

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Inventory audit item",
  "type": "object",
  "properties": {
    "inventoryAuditItems": {
      "description": "List of inventory audit items",
      "type": "array",
      "id": "inventoryAuditItems",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "Inventory audit item",
        "properties": {
          "eventId": {
            "description": "UUID of the event",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "entityId": {
            "description": "UUID of the entity",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "eventTs": {
            "description": "Event timestamp",
            "type": "string",
            "format": "utc-millisec"
          },
          "eventDate": {
            "description": "Date time when event triggered",
            "format": "date-time",
            "type": "string"
          },
          "action": {
            "description": "Action for event (CREATE, UPDATE or DELETE)",
            "type": "string"
          },
          "userId": {
            "description": "UUID of the user who performed the action",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "diff": {
            "description": "Difference for entity cause by an action",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "object",
            "properties": {
              "fieldChanges": {
                "description": "Changes in fields",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "changeType": {
                      "type": "string",
                      "description": "Type of change",
                      "enum": [
                        "MODIFIED",
                        "REMOVED",
                        "ADDED",
                        "NOTHING"
                      ]
                    },
                    "fieldName": {
                      "description": "Name of the field",
                      "type": "string"
                    },
                    "fullPath": {
                      "description": "Full path of the field",
                      "type": "string"
                    },
                    "oldValue": {
                      "description": "Old value of the field",
                      "type": "object",
                      "javaType": "java.lang.Object"
                    },
                    "newValue": {
                      "description": "New value of the field",
                      "type": "object",
                      "javaType": "java.lang.Object"
                    }
                  },
                  "required": [
                    "changeType",
                    "fieldName",
                    "fullPath"
                  ]
                }
              },
              "collectionChanges": {
                "description": "Changes in collections",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "collectionName": {
                      "description": "Name of the collection",
                      "type": "string"
                    },
                    "itemChanges": {
                      "description": "Changes of the collection",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "changeType": {
                            "description": "Type of change",
                            "type": "string",
                            "enum": [
                              "MODIFIED",
                              "REMOVED",
                              "ADDED",
                              "NOTHING"
                            ]
                          },
                          "oldValue": {
                            "description": "Old value of the item",
                            "type": "object",
                            "javaType": "java.lang.Object"
                          },
                          "newValue": {
                            "description": "New value of the item",
                            "type": "object",
                            "javaType": "java.lang.Object"
                          }
                        },
                        "required": [
                          "changeType"
                        ]
                      }
                    }
                  },
                  "required": [
                    "collectionName",
                    "itemChanges"
                  ]
                }
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    },
    "totalRecords": {
      "description": "Total number of records",
      "type": "integer"
    }
  },
  "required": [
    "inventoryAuditItems"
  ],
  "additionalProperties": false
}

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "type": "object",
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}