# Excluding and Preventing Indexing of Content

> Learn how to exclude parts of a document from a scan and how to prevent documents from being added to the Copyleaks Internal Database.

You have granular control over what content is scanned and what data is stored when you submit a document to Copyleaks. This guide covers two distinct types of exclusion:

1. **Excluding Parts of a Document from Scan Analysis**: This allows you to refine the plagiarism scan by ignoring specific elements like quotes or code blocks.
2. **Preventing a Document from Being Indexed**: This allows you to control whether the entire document is added to the Copyleaks Internal Database for future comparisons.

## Exclude Options

The `exclude` object can contain the following boolean properties:

- `quotes`: If set to `true`, all text within quotation marks will be ignored.
- `citations`: If set to `true`, citations and references will be ignored.
- `references`: If set to `true`, the bibliography or reference list will be ignored.
- `tableOfContents`: If set to `true`, the table of contents will be ignored.
- `titles`: If set to `true`, titles and headings will be ignored.
- `code`: An object controlling code exclusion. Set its `comments` field to `true` to ignore comments within code blocks (for example, `"code": { "comments": true }`).
- `documentTemplateIds`: An array of unique identifiers for predefined templates stored in your Private Cloud Hub or the Shared Data Hub. These templates' content is then excluded from the document and won't count towards plagiarism or AI analysis.

<Note>
  Use these options to customize your scans and focus on the most relevant content.
</Note>

## Using the Exclude

The `exclude` property is a powerful feature with two primary uses:

1. **Active Scans**: When submitting a document for scanning, you can include the `exclude` object in the request payload to specify which parts of the document should be ignored during analysis, e.g., you can exclude quotes, citations, or code blocks to focus on the most relevant content.

2. **Exclude Template**: The `exclude` template allows you to refine the analysis of documents by excluding specific sections based on a predefined template. The template document could be located in either your Private Cloud Hub or the Shared Data Hub, e.g., excluding exam questions from a student's filled out exam.

<Tip>
  Use `documentTemplateIds` to streamline your workflow when dealing with repetitive document structures. This ensures consistency and saves time during the scanning process.
</Tip>

## Get Started

<Steps>
  <Step title="Before you begin">
    Before you start, ensure you have the following:
    - An active Copyleaks account. If you don't have one, **[sign up for free](https://api.copyleaks.com/signup)**.
    - You can find your API key on the **[API Dashboard](https://api.copyleaks.com/dashboard)**.
  </Step>

  <Step title="Installation">
    <InstallSDKs />
  </Step>

  <Step title="Login">
    To perform a scan, we first need to generate an access token. For that, we will use the [**login**](/reference/actions/account/login) endpoint.
    The API key can be found on the [**Copyleaks API Dashboard**](https://api.copyleaks.com/dashboard).

    Upon successful authentication, you will receive a token that must be attached to subsequent API calls via the `Authorization: Bearer <TOKEN>` header.
    This token remains valid for 48 hours.

    <CodeGroup>
        ```http title="HTTP" icon="globe"
        POST https://id.copyleaks.com/v3/account/login/api

        Headers
        Content-Type: application/json

        Body
        {
            "email": "your@email.address",
            "key": "00000000-0000-0000-0000-000000000000"
        }
        ```
        ```bash title="cURL" icon="terminal"
        export COPYLEAKS_EMAIL="your@email.address"
        export COPYLEAKS_API_KEY="your-api-key-here"

        curl --request POST \
          --url https://id.copyleaks.com/v3/account/login/api \
          --header 'Accept: application/json' \
          --header 'Content-Type: application/json' \
          --data "{
            \"email\": \"${COPYLEAKS_EMAIL}\",
            \"key\": \"${COPYLEAKS_API_KEY}\"
          }"
        ```
        ```python title="Python" icon="python"
        from copyleaks.copyleaks import Copyleaks

        EMAIL_ADDRESS = "your@email.address"
        API_KEY = "your-api-key-here"

        # Login to Copyleaks
        auth_token = Copyleaks.login(EMAIL_ADDRESS, API_KEY)
        print("Logged successfully!\nToken:", auth_token)
        ```
        ```javascript title="JavaScript" icon="square-js"
        const { Copyleaks } = require("plagiarism-checker");

        const EMAIL_ADDRESS = "your@email.address";
        const API_KEY = "your-api-key-here";
        const copyleaks = new Copyleaks();

        // Login function
        function loginToCopyleaks() {
          return copyleaks.loginAsync(EMAIL_ADDRESS, API_KEY).then(
            (loginResult) => {
              console.log("Login successful!");
              console.log("Access Token:", loginResult.access_token);
              return loginResult;
            },
            (err) => {
              console.error('Login failed:', err);
              throw err;
            }
          );
        }

        loginToCopyleaks();
        ```
        ```java title="Java" icon="java"
        import com.copyleaks.sdk.api.Copyleaks;

        String EMAIL_ADDRESS = "your@email.address";
        String API_KEY = "00000000-0000-0000-0000-000000000000";

        // Login to Copyleaks
        try {
            String authToken = Copyleaks.login(EMAIL_ADDRESS, API_KEY);
            System.out.println("Logged successfully!\nToken: " + authToken);
        } catch (CommandException e) {
            System.out.println("Failed to login: " + e.getMessage());
            System.exit(1);
        }
        ```
    </CodeGroup>

    **Response**
    ```json
    {
        "access_token": "<ACCESS_TOKEN>",
        ".issued": "2025-07-31T10:19:40.0690015Z",
        ".expires": "2025-08-02T10:19:40.0690016Z"
    }
    ```

    <Note>
    Save this token! It's valid for 48 hours and can be reused for subsequent API calls.
    </Note>
  </Step>

  <Step title="Indexed Scan">
    Use the following example to index a document as a template in your Private Cloud Hub.

  <CodeGroup>
        ```http title="HTTP" icon="globe"
        PUT https://api.copyleaks.com/v3/scans/submit/file/my-template-index
        Content-Type: application/json
        Authorization: Bearer YOUR_LOGIN_TOKEN

        {
          "base64": "VGhpcyBpcyBhIHRlc3QgZG9jdW1lbnQu",
          "filename": "student_solved_exam",
          "properties": {
            "action": 2,
            "indexing": {
              "repositories": ["my_private_cloud_exam_template"]
            },
            "sandbox": true
          }
        }
        ```
        ```bash title="cURL" icon="terminal"
        curl --request PUT \
          --url https://api.copyleaks.com/v3/scans/submit/file/my-template-index \
          --header 'Authorization: Bearer YOUR_LOGIN_TOKEN' \
          --header 'Content-Type: application/json' \
          --data '{
            "base64": "VGhpcyBpcyBhIHRlc3QgZG9jdW1lbnQu",
            "filename": "student_solved_exam",
            "properties": {
              "action": 2,
              "indexing": {
                "repositories": ["my_private_cloud_exam_template"]
              },
              "sandbox": true
            }
          }'
        ```
        ```python title="Python" icon="python"
        import requests
        import base64

        # Document content
        document_content = "This is a test document."
        base64_content = base64.b64encode(document_content.encode()).decode('utf-8')

        url = "https://api.copyleaks.com/v3/scans/submit/file/my-template-index"
        payload = {
            "base64": base64_content,
            "filename": "student_solved_exam",
            "properties": {
                "action": 2,
                "indexing": {
                    "repositories": ["my_private_cloud_exam_template"]
                },
                "sandbox": True
            }
        }
        headers = {
            "Authorization": "Bearer YOUR_LOGIN_TOKEN",
            "Content-Type": "application/json"
        }

        response = requests.put(url, json=payload, headers=headers)
        print(response.json())
        ```
        ```javascript title="JavaScript" icon="square-js"
        const { Copyleaks } = require('plagiarism-checker');

        const EMAIL_ADDRESS = "your@email.address";
        const API_KEY = "your-api-key-here";

        async function indexTemplate() {
            const copyleaks = new Copyleaks();
            const authToken = await copyleaks.loginAsync(EMAIL_ADDRESS, API_KEY);

            const documentContent = "This is a test document.";
            const base64Content = Buffer.from(documentContent).toString('base64');

            const scanId = "my-template-index";
            const fileSubmission = {
                base64: base64Content,
                filename: "student_solved_exam",
                properties: {
                    action: 2,
                    indexing: {
                        repositories: ["my_private_cloud_exam_template"]
                    },
                    sandbox: true
                }
            };

            try {
                const result = await copyleaks.submitFileAsync(authToken, scanId, fileSubmission);
                console.log('Template indexed successfully!', result);
            } catch (error) {
                console.error('Failed to index template:', error);
            }
        }

        indexTemplate();
        ```
        ```java title="Java" icon="java"
        import classes.Copyleaks;
        import models.response.CopyleaksAuthToken;
        import models.submissions.CopyleaksFileSubmissionModel;
        import models.submissions.properties.*;
        import java.util.Base64;
        import java.nio.charset.StandardCharsets;

        public class IndexTemplateExample {
            private static final String EMAIL_ADDRESS = "your@email.address";
            private static final String API_KEY = "00000000-0000-0000-0000-000000000000";

            public static void main(String[] args) {
                try {
                    CopyleaksAuthToken authToken = Copyleaks.login(EMAIL_ADDRESS, API_KEY);

                    String documentContent = "This is a test document.";
                    String base64Content = Base64.getEncoder().encodeToString(
                        documentContent.getBytes(StandardCharsets.UTF_8)
                    );

                    SubmissionWebhooks webhooks = new SubmissionWebhooks("https://your-server.com/webhook/{STATUS}");
                    SubmissionProperties properties = new SubmissionProperties(webhooks);
                    properties.setSandbox(true);
                    properties.setAction(SubmissionActions.IndexOnly); // Action 2 = IndexOnly

                    SubmissionIndexingRepository repo = new SubmissionIndexingRepository();
                    repo.setId("my_private_cloud_exam_template");

                    SubmissionIndexing indexing = new SubmissionIndexing();
                    // Requires copyleaks-java-sdk SubmissionIndexing.setRepositories (coming soon)
                    indexing.setRepositories(new SubmissionIndexingRepository[]{ repo });
                    properties.setIndexing(indexing);

                    CopyleaksFileSubmissionModel fileSubmission = new CopyleaksFileSubmissionModel(
                        base64Content,
                        "student_solved_exam",
                        properties
                    );

                    Copyleaks.submitFile(authToken, "my-template-index", fileSubmission);
                    System.out.println("Template indexed successfully!");
                } catch (Exception e) {
                    System.out.println("Failed: " + e.getMessage());
                    e.printStackTrace();
                }
            }
        }
        ```
    </CodeGroup>
  </Step>

  <Step title="Submit for Scanning">
    Include the `exclude` object in the request payload to specify which parts of the document should be ignored during analysis.

    <CodeGroup>
        ```http title="HTTP" icon="globe"
        PUT https://api.copyleaks.com/v3/scans/submit/file/my-scan-with-template
        Content-Type: application/json
        Authorization: Bearer YOUR_LOGIN_TOKEN

        {
          "base64": "VGhpcyBpcyBhIHRlc3QgZG9jdW1lbnQu",
          "filename": "document-to-scan.txt",
          "properties": {
            "exclude": {
              "documentTemplateIds": ["my-template-index"],
              "quotes": true,
              "citations": true,
              "references": true,
              "tableOfContents": true,
              "titles": true,
              "htmlTemplate": true,
              "code": {
                "comments": true
              }
            },
            "sandbox": true
          }
        }
        ```
        ```bash title="cURL" icon="terminal"
        curl --request PUT \
          --url https://api.copyleaks.com/v3/scans/submit/file/my-scan-with-template \
          --header 'Authorization: Bearer YOUR_LOGIN_TOKEN' \
          --header 'Content-Type: application/json' \
          --data '{
            "base64": "VGhpcyBpcyBhIHRlc3QgZG9jdW1lbnQu",
            "filename": "document-to-scan.txt",
            "properties": {
              "exclude": {
                "documentTemplateIds": ["my-template-index"],
                "quotes": true,
                "citations": true,
                "references": true,
                "tableOfContents": true,
                "titles": true,
                "htmlTemplate": true,
                "code": {
                  "comments": true
                }
              },
              "sandbox": true
            }
          }'
        ```
        ```python title="Python" icon="python"
        import requests
        import base64

        # Document content
        document_content = "This is a test document."
        base64_content = base64.b64encode(document_content.encode()).decode('utf-8')

        url = "https://api.copyleaks.com/v3/scans/submit/file/my-scan-with-template"
        payload = {
            "base64": base64_content,
            "filename": "document-to-scan.txt",
            "properties": {
                "exclude": {
                    "documentTemplateIds": ["my-template-index"],
                    "quotes": true,
                    "citations": true,
                    "references": true,
                    "tableOfContents": true,
                    "titles": true,
                    "htmlTemplate": true,
                    "code": {
                      "comments": true
                    }
                },
                "sandbox": True
            }
        }
        headers = {
            "Authorization": "Bearer YOUR_LOGIN_TOKEN",
            "Content-Type": "application/json"
        }

        response = requests.put(url, json=payload, headers=headers)
        print(response.json())
        ```
        ```javascript title="JavaScript" icon="square-js"
        const { Copyleaks } = require('plagiarism-checker');

        const EMAIL_ADDRESS = "your@email.address";
        const API_KEY = "your-api-key-here";

        async function submitScanWithTemplate() {
            const copyleaks = new Copyleaks();
            const authToken = await copyleaks.loginAsync(EMAIL_ADDRESS, API_KEY);

            const documentContent = "This is a test document.";
            const base64Content = Buffer.from(documentContent).toString('base64');

            const scanId = "my-scan-with-template";
            const fileSubmission = {
                base64: base64Content,
                filename: "document-to-scan.txt",
                properties: {
                    exclude: {
                        documentTemplateIds: ["my-template-index"],
                        quotes: true,
                        citations: true,
                        references: true,
                        tableOfContents: true,
                        titles: true,
                        htmlTemplate: true,
                        code: {
                          comments: true
                        }
                    },
                    sandbox: true
                }
            };

            try {
                const result = await copyleaks.submitFileAsync(authToken, scanId, fileSubmission);
                console.log('Scan submitted successfully!', result);
            } catch (error) {
                console.error('Failed to submit scan:', error);
            }
        }

        submitScanWithTemplate();
        ```
        ```java title="Java" icon="java"
        import classes.Copyleaks;
        import models.response.CopyleaksAuthToken;
        import models.submissions.CopyleaksFileSubmissionModel;
        import models.submissions.properties.*;
        import java.util.Base64;
        import java.nio.charset.StandardCharsets;

        public class SubmitScanWithTemplate {
            private static final String EMAIL_ADDRESS = "your@email.address";
            private static final String API_KEY = "00000000-0000-0000-0000-000000000000";

            public static void main(String[] args) {
                try {
                    CopyleaksAuthToken authToken = Copyleaks.login(EMAIL_ADDRESS, API_KEY);

                    String documentContent = "This is a test document.";
                    String base64Content = Base64.getEncoder().encodeToString(
                        documentContent.getBytes(StandardCharsets.UTF_8)
                    );

                    SubmissionWebhooks webhooks = new SubmissionWebhooks("https://your-server.com/webhook/{STATUS}");
                    SubmissionProperties properties = new SubmissionProperties(webhooks);
                    properties.setSandbox(true);
                    SubmissionExclude exclude = new SubmissionExclude();
                    exclude.setDocumentTemplateIds(new String[]{"my-template-index"});
                    properties.setExclude(exclude);

                    CopyleaksFileSubmissionModel fileSubmission = new CopyleaksFileSubmissionModel(
                        base64Content,
                        "document-to-scan.txt",
                        properties
                    );

                    Copyleaks.submitFile(authToken, "my-scan-with-template", fileSubmission);
                    System.out.println("Scan submitted successfully!");
                } catch (Exception e) {
                    System.out.println("Failed: " + e.getMessage());
                    e.printStackTrace();
                }
            }
        }
        ```
    </CodeGroup>
  </Step>
</Steps>

## Response Example

When the scan is processed, the `scannedDocument` object in the response will reflect the number of words that were excluded.

<Tabs>
  <Tab title="201">
    <Check>**201 Created** - The scan was successfully created and is now processing. The excluded word count is reflected in the response.</Check>

    ```json
    {
      "scannedDocument": {
        "scanId": "my-scan-exclude-example",
        "totalWords": 8,
        "totalExcluded": 4,
        "credits": 0,
        "expectedCredits": 1,
        "creationTime": "2025-08-10T10:00:00.000000Z",
        "metadata": {
          "filename": "document-with-exclusions.txt"
        },
        "enabled": {
          "plagiarismDetection": true,
          "aiDetection": false,
          "explainableAi": false,
          "writingFeedback": false,
          "pdfReport": true,
          "cheatDetection": false,
          "aiSourceMatch": false,
          "internalAiSourceMatch": false
        },
        "detectedLanguage": "en"
      },
      "results": {
        "score": {
          "identicalWords": 0,
          "minorChangedWords": 0,
          "relatedMeaningWords": 0,
          "aggregatedScore": 0.0
        },
        "internet": [],
        "database": [],
        "batch": [],
        "repositories": []
      },
      "notifications": {},
      "writingFeedback": {},
      "status": 0,
      "developerPayload": ""
    }
    ```
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={2}>
    <Card title="Webhooks Overview" icon="plug" href="/reference/data-types/authenticity/webhooks/overview/">Learn how to securely receive and process notifications from Copyleaks.</Card>
    <Card title="Viewing Scan Results" icon="browser" href="/concepts/features/how-to-display/">Understand the scan result format and how to display it to your users.</Card>
</CardGroup>
