> ## Documentation Index
> Fetch the complete documentation index at: https://gr-docs.aporia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rag Access Control

> ensures that users can only access documents they are authorized to, based on their role.

## Overview:

RAG Access Control ensures that users can only **access documents they are authorized to**, based on their role. The system ensures that only document IDs matching the user's access level are returned.

## Integration Setup:

1. **Select a Knowledge Base:** Choose the knowledge base (e.g., Google Drive) that you want to integrate. **Only the admin of the selected knowledge base should complete the integration process.**
2. **Credentials:** After selecting the knowledge base, authorize access through Google OAuth to finalize the integration.
3. **Integration Location:** The integration can be found under RAG Access Control in the Project Settings page. The organization admin is responsible for completing the integration setup for the organization.

## Post-Integration Flow:

Once the integration is complete, follow these steps to verify RAG access:

1. **Query the Endpoint:** You will need to query the following endpoint to check document access

```json theme={null}
https://gr-prd.aporia.com/<PROJECT_ID>/verify-rag-access
```

2. **Request Body:**
   The request body should contain the following information:

```json theme={null}
{
  "type": "google-kb",
  "doc_ids": ["doc_id_1"],
  "user_email": "sandy@aporia.com"
}
```

3. **API Key:**
   Ensure the API key for Aporia is included in the request header for authentication.

4. **Response:**
   The system will return a response indicating the accessibility of documents. The response will look like this:

```json theme={null}
{
  "accessible_doc_ids": ["doc_id_1", "doc_id_2"],
  "unaccessible_doc_ids": ["doc_id_3"],
  "errored_doc_ids": [{"doc_id_4": "error_message"}]
}
```
