# Audit

About audit log functionality you can find more info from [Audit Log documentation](https://prompteasy.eu/docs/administration/audit-log). About Vault Receipts, see [Vault Receipts documentation](https://prompteasy.eu/docs/administration/vault-receipts).

## Get the audit log for the tenant

`GET /v1/audit`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Responses:

- 200: A list of audit log entries

Content type: application/json

Type: array

Items:
  Reference: [AuditLog](https://api.prompteasy.eu/docs/api/models/auditlog/index.md); Type: object

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Export audit logs as unencrypted JSONL

`GET /v1/audit/export`

Export audit logs as a JSONL file with optional timeframe filtering. Recording of the export action is logged prior to streaming the export.

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `start_time` (query, string, date-time, optional) - Optional start time filter (ISO 8601 string)
  Type: string, date-time

- `end_time` (query, string, date-time, optional) - Optional end time filter (ISO 8601 string)
  Type: string, date-time

Responses:

- 200: A raw JSONL file containing tenant header and audit log entries.

Content type: application/x-jsonlines

Type: string, binary

- 401: Unauthorized

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/export' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/export', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/export',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Get the audit log for a specific user

`GET /v1/audit/users/{user}`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `user` (path, integer, required)
  Type: integer

Responses:

- 200: A list of audit log entries

Content type: application/json

Type: array

Items:
  Reference: [AuditLog](https://api.prompteasy.eu/docs/api/models/auditlog/index.md); Type: object

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/users/0' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/users/0', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/users/0',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Get the audit log for a specific target

`GET /v1/audit/target/{targetTable}/{id}`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `targetTable` (path, string, required)
  Type: string

- `id` (path, integer, required)
  Type: integer

Responses:

- 200: A list of audit log entries

Content type: application/json

Type: array

Items:
  Reference: [AuditLog](https://api.prompteasy.eu/docs/api/models/auditlog/index.md); Type: object

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/target/string/0' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/target/string/0', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/target/string/0',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Get the audit log for a specific date range

`GET /v1/audit/start/{startTime}/end/{endTime}`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `startTime` (path, string, date-time, required)
  Type: string, date-time

- `endTime` (path, string, date-time, required)
  Type: string, date-time

Responses:

- 200: A list of audit log entries

Content type: application/json

Type: array

Items:
  Reference: [AuditLog](https://api.prompteasy.eu/docs/api/models/auditlog/index.md); Type: object

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/start/2024-01-15T09%3A30%3A00Z/end/2024-01-15T09%3A30%3A00Z' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/start/2024-01-15T09%3A30%3A00Z/end/2024-01-15T09%3A30%3A00Z', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/start/2024-01-15T09%3A30%3A00Z/end/2024-01-15T09%3A30%3A00Z',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Get the audit log starting from a specific time

`GET /v1/audit/start/{startTime}`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `startTime` (path, string, date-time, required)
  Type: string, date-time

Responses:

- 200: A list of audit log entries

Content type: application/json

Type: array

Items:
  Reference: [AuditLog](https://api.prompteasy.eu/docs/api/models/auditlog/index.md); Type: object

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/start/2024-01-15T09%3A30%3A00Z' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/start/2024-01-15T09%3A30%3A00Z', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/start/2024-01-15T09%3A30%3A00Z',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Get the cryptographic vault receipts for the tenant

`GET /v1/audit/receipts`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Responses:

- 200: A paginated list of cryptographic vault receipts

Content type: application/json

Type: object

Schema: [PaginatedVaultReceipts](https://api.prompteasy.eu/docs/api/models/paginatedvaultreceipts/index.md)

- `current_page` (optional)
  Type: integer

- `data` (optional)
  Type: array
  
  Items:
    Reference: [VaultReceiptListItem](https://api.prompteasy.eu/docs/api/models/vaultreceiptlistitem/index.md); Type: object

- `first_page_url` (optional)
  Type: string, uri

- `from` (optional)
  Type: integer

- `last_page` (optional)
  Type: integer

- `last_page_url` (optional)
  Type: string, uri

- `links` (optional)
  Type: array
  
  Items:
    Reference: [PaginationLink](https://api.prompteasy.eu/docs/api/models/paginationlink/index.md); Type: object

- `next_page_url` (optional)
  Type: string, uri; nullable

- `path` (optional)
  Type: string, uri

- `per_page` (optional)
  Type: integer

- `prev_page_url` (optional)
  Type: string, uri; nullable

- `to` (optional)
  Type: integer

- `total` (optional)
  Type: integer

- 403: Forbidden

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/receipts' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/receipts', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/receipts',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Get detailed cryptographic vault receipt details

`GET /v1/audit/receipts/{receipt}`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `receipt` (path, string, uuid, required)
  Type: string, uuid

Responses:

- 200: Detailed vault receipt representation

Content type: application/json

Type: object

Schema: [VaultReceipt](https://api.prompteasy.eu/docs/api/models/vaultreceipt/index.md)

- `id` (optional)
  Type: string, uuid

- `datetime` (optional)
  Type: string, date-time

- `user` (optional)
  Type: object
  
  - `id` (optional)
    Type: integer; nullable
  
  - `name` (optional)
    Type: string
  
  - `initials` (optional)
    Type: string

- `prompt_id` (optional)
  Type: string, uuid; nullable

- `prompt_history_id` (optional)
  Type: string, uuid; nullable

- `action` (optional)
  Type: string
  
  enum: ["modified","versioned","executed"]

- `hash` (optional)
  Type: string

- `signature` (optional)
  Type: string

- `prompt` (optional)
  Type: string; nullable

- `llm_system_message` (optional)
  Type: string; nullable

- `prompt_version` (optional)
  Type: integer

- `metadata` (optional)
  Type: object

- 403: Forbidden

- 404: Receipt not found

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/receipts/550e8400-e29b-41d4-a716-446655440000' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/receipts/550e8400-e29b-41d4-a716-446655440000', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/receipts/550e8400-e29b-41d4-a716-446655440000',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```


## Verify the cryptographic vault receipt integrity

`GET /v1/audit/receipts/{receipt}/verify`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKeyAuth": [],
    "BearerAuth": []
  }
]
```

- ApiKeyAuth: apiKey, header X-Api-Key
- BearerAuth: http (bearer)

Parameters:

- `receipt` (path, string, uuid, required)
  Type: string, uuid

Responses:

- 200: Verification result of a cryptographic vault receipt

Content type: application/json

Type: object

Schema: [VaultReceiptVerification](https://api.prompteasy.eu/docs/api/models/vaultreceiptverification/index.md)

- `valid` (optional)
  Type: boolean

- `receipt` (optional)
  Reference: [VaultReceipt](https://api.prompteasy.eu/docs/api/models/vaultreceipt/index.md); Type: object

- 403: Forbidden

- 404: Receipt not found

## Examples

### cURL

```bash
curl -X GET 'https://api.prompteasy.eu/v1/audit/receipts/550e8400-e29b-41d4-a716-446655440000/verify' \
  -H 'X-Api-Key: YOUR_TOKEN' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.prompteasy.eu/v1/audit/receipts/550e8400-e29b-41d4-a716-446655440000/verify', {
  method: 'GET',
  headers: {
    'X-Api-Key': 'YOUR_TOKEN',
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.prompteasy.eu/v1/audit/receipts/550e8400-e29b-41d4-a716-446655440000/verify',
    headers={
        'X-Api-Key': 'YOUR_TOKEN',
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```
