# Audit Logs API

## Overview

{% hint style="info" %}

* This feature is available with the [**Paradime Security pack**](https://www.paradime.io/security).&#x20;
* Your API keys ***must*** have the [Audit Logs viewer capability](https://docs.paradime.io/app-help/developers/generate-api-keys).
  {% endhint %}

The Audit Log API enables you to access and retrieve audit logs associated with your Paradime account.

## Fetch Audit Logs

This endpoint enables fetching Audit logs metadata for all event types and workspaces in your account.

**Example Request**

{% tabs %}
{% tab title="GraphQL" %}

```python
import requests
import os

# API credentials
api_endpoint = "<YOUR_API_ENDPOINT>"
api_key = "<YOUR_API_KEY>"
api_secret = "<YOUR_API_SECRET>"

graphql_query = """
query GetAuditLogs {
    getAuditLogs {
        auditLogs {
            id
            createdDttm
            updatedDttm
            workspaceId
            workspaceName
            actorType
            actorUserId
            actorEmail
            eventSourceId
            eventSource
            eventId
            eventType
            metadataJson
        }
    }
}
  """
  
response = requests.post(api_endpoint, json={"query": graphql_query}, headers={
      "Content-Type": "application/json",
      "X-API-KEY": api_key,
      "X-API-SECRET": api_secret,
  })

print(response.json())
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location --request POST '<YOUR_API_ENDPOINT>' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR_API_KEY>' \
--header 'X-API-SECRET: <YOUR_API_SECRET>' \
--data-raw '{
  "query": "query GetAuditLogs { getAuditLogs { auditLogs { id createdDttm updatedDttm workspaceId workspaceName actorType actorUserId actorEmail eventSourceId eventSource eventId eventType metadataJson } } }"
}'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Example Response</summary>

```json
{
  "auditLogs": [
    {
      "id": 1,
      "createdDttm": "2024-02-13 16:09:29.718805",
      "updatedDttm": "2024-02-13 16:09:29.718809",
      "workspaceId": 2,
      "workspaceName": "data_platform",
      "actorType": "user",
      "actorUserId": 4,
      "actorEmail": "john@acme.io",
      "eventSourceId": 0,
      "eventSource": "bolt",
      "eventId": 12,
      "eventType": "schedule_manual_run",
      "metadataJson": {
        "schedule_name_uuid": "e3a1e416-f778-3fa5-aac9-10288466cfb5",
        "schedule": {
          "name": "daily run"
        }
      }
    },
    ...
    }
  ]
}
```

</details>
