# AuditLogs

The audit log provides audit trail information for user activity, changes to business objects and other important information. For more information, see [Audit log](https://run-ai-docs.nvidia.com/self-hosted/2.24/infrastructure-setup/procedures/event-history).

## Get audit logs

> Get audit logs based on query params filter

```json
{"openapi":"3.0.3","info":{"title":"NVIDIA Run:ai","version":"2.24"},"tags":[{"name":"AuditLogs","description":"The audit log provides audit trail information for user activity, changes to business objects and other important information. For more information, see [Audit log](https://run-ai-docs.nvidia.com/self-hosted/2.24/infrastructure-setup/procedures/event-history)."}],"servers":[{"url":"https://app.run.ai"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer authentication"}},"parameters":{"StartRequired":{"name":"start","in":"query","description":"Start date of time range to fetch data in ISO 8601 timestamp format.","required":true,"schema":{"type":"string","format":"date-time"}},"EndRequired":{"name":"end","in":"query","description":"End date of time range to fetch data in ISO 8601 timestamp format.","required":true,"schema":{"type":"string","format":"date-time"}},"Offset":{"name":"offset","in":"query","required":false,"description":"The offset of the first item returned in the collection.","schema":{"type":"integer","format":"int32"}},"NumberOfSamples":{"name":"numberOfSamples","in":"query","description":"The number of samples to take in the specified time range.","required":false,"schema":{"type":"integer","maximum":1000,"minimum":0,"default":20}},"SortOrder":{"name":"sortOrder","in":"query","required":false,"description":"Sort results in descending or ascending order.","schema":{"type":"string","enum":["asc","desc"],"default":"asc"}},"AuditLogSort":{"name":"sortBy","in":"query","required":false,"description":"Sort results by a parameters.","schema":{"type":"string","enum":["timestamp","subject","subject_type","source_ip","action","http_method","result","url","entity_type","entity_name","entity_id"]}},"AuditLogFilter":{"name":"filterBy","in":"query","required":false,"explode":false,"description":"Filter results by a parameter. Use the format field-name operator value. Operators are == Equals, != Not equals, <= Less than or equal, >= Greater than or equal, =@ contains, !@ Does not contains, =^ Starts with and =$ Ends with. Dates are in ISO 8601 timestamp format and available for operators ==, !=, <= and >=.","schema":{"type":"array","items":{"type":"string","pattern":"^(timestamp|subject|subject_type|source_ip|action|result|url|entity_type|entity_name|cluster_name)(==|!=|<=|>=|=@|!@|=\\^|=\\$).+$"}}}},"schemas":{"AuditLogs":{"type":"array","items":{"$ref":"#/components/schemas/AuditLog"}},"AuditLog":{"type":"object","required":["tenant_id","subject","subject_type","action","result"],"properties":{"id":{"type":"string","format":"uuid","maxLength":40},"timestamp":{"type":"string","format":"date-time"},"tenant_id":{"type":"string","description":"the ID of the tenant"},"subject":{"type":"string","maxLength":500,"minLength":1,"description":"the user/app which triggered this API"},"subject_type":{"type":"string","enum":["User","App"],"default":"User"},"source_ip":{"type":"string","format":"ipv4","maxLength":250},"action":{"type":"string","enum":["create","update","delete","sign-in","sign-out","reset-password"]},"http_method":{"type":"string","enum":["GET","POST","PUT","PATCH","DELETE","CREATE"]},"url":{"type":"string","format":"uri","maxLength":2000},"entity_type":{"type":"string","maxLength":500},"entity_name":{"type":"string"},"entity_id":{"type":"string"},"result":{"type":"string","enum":["Succeeded","Failed"]},"http_status_code":{"type":"integer","maximum":599},"cluster_name":{"type":"string","maxLength":500},"cluster_id":{"type":"string","format":"uuid","maxLength":40},"request_id":{"type":"string","format":"uuid","maxLength":40},"metadata":{"type":"object","maxProperties":10,"additionalProperties":{"type":"string"}}}},"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","minimum":100,"maximum":599},"message":{"type":"string"},"details":{"type":"string"}}}},"responses":{"401Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403Forbidden":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500InternalServerError":{"description":"unexpected error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503ServiceUnavailable":{"description":"unexpected error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/v1/audit/log":{"get":{"description":"Get audit logs based on query params filter","summary":"Get audit logs","operationId":"getAuditLogs","tags":["AuditLogs"],"parameters":[{"$ref":"#/components/parameters/StartRequired"},{"$ref":"#/components/parameters/EndRequired"},{"$ref":"#/components/parameters/Offset"},{"$ref":"#/components/parameters/NumberOfSamples"},{"$ref":"#/components/parameters/SortOrder"},{"$ref":"#/components/parameters/AuditLogSort"},{"$ref":"#/components/parameters/AuditLogFilter"}],"responses":{"200":{"description":"Executed successfully","content":{"application/json":{"schema":{"type":"object","required":["logs"],"properties":{"total":{"type":"integer"},"next":{"type":"integer"},"audit_logs":{"$ref":"#/components/schemas/AuditLogs"}}}}}},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"},"500":{"$ref":"#/components/responses/500InternalServerError"},"503":{"$ref":"#/components/responses/503ServiceUnavailable"}}}}}}
```

## Download audit logs

> Download audit logs as a file, based on query params filter

```json
{"openapi":"3.0.3","info":{"title":"NVIDIA Run:ai","version":"2.24"},"tags":[{"name":"AuditLogs","description":"The audit log provides audit trail information for user activity, changes to business objects and other important information. For more information, see [Audit log](https://run-ai-docs.nvidia.com/self-hosted/2.24/infrastructure-setup/procedures/event-history)."}],"servers":[{"url":"https://app.run.ai"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Bearer authentication"}},"parameters":{"StartRequired":{"name":"start","in":"query","description":"Start date of time range to fetch data in ISO 8601 timestamp format.","required":true,"schema":{"type":"string","format":"date-time"}},"EndRequired":{"name":"end","in":"query","description":"End date of time range to fetch data in ISO 8601 timestamp format.","required":true,"schema":{"type":"string","format":"date-time"}},"NumberOfSamples":{"name":"numberOfSamples","in":"query","description":"The number of samples to take in the specified time range.","required":false,"schema":{"type":"integer","maximum":1000,"minimum":0,"default":20}},"AuditLogFilter":{"name":"filterBy","in":"query","required":false,"explode":false,"description":"Filter results by a parameter. Use the format field-name operator value. Operators are == Equals, != Not equals, <= Less than or equal, >= Greater than or equal, =@ contains, !@ Does not contains, =^ Starts with and =$ Ends with. Dates are in ISO 8601 timestamp format and available for operators ==, !=, <= and >=.","schema":{"type":"array","items":{"type":"string","pattern":"^(timestamp|subject|subject_type|source_ip|action|result|url|entity_type|entity_name|cluster_name)(==|!=|<=|>=|=@|!@|=\\^|=\\$).+$"}}}},"responses":{"401Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403Forbidden":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500InternalServerError":{"description":"unexpected error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503ServiceUnavailable":{"description":"unexpected error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"required":["code","message"],"properties":{"code":{"type":"integer","minimum":100,"maximum":599},"message":{"type":"string"},"details":{"type":"string"}}}}},"paths":{"/api/v1/audit/log/file":{"get":{"description":"Download audit logs as a file, based on query params filter","summary":"Download audit logs","operationId":"downloadAuditLogs","tags":["AuditLogs"],"parameters":[{"in":"query","name":"file_type","schema":{"type":"string","enum":["CSV","JSON"],"default":"CSV"},"required":false},{"$ref":"#/components/parameters/StartRequired"},{"$ref":"#/components/parameters/EndRequired"},{"$ref":"#/components/parameters/NumberOfSamples"},{"$ref":"#/components/parameters/AuditLogFilter"}],"responses":{"200":{"description":"File downloaded","content":{"application/octet-stream":{}}},"401":{"$ref":"#/components/responses/401Unauthorized"},"403":{"$ref":"#/components/responses/403Forbidden"},"500":{"$ref":"#/components/responses/500InternalServerError"},"503":{"$ref":"#/components/responses/503ServiceUnavailable"}}}}}}
```
