.txt file, you can scan a .py file. The only difference is the file extension you send.
Teams use code scans to:
- Confirm that proprietary code has not appeared in public repositories, forums, or documentation sites.
- Check that contributed or outsourced code was not copied from other sources, to stay on the right side of licensing agreements.
- Review programming assignments for academic integrity.
Get started
1
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.
- You can find your API key on the API Dashboard.
2
Installation
Choose your preferred method for making API calls.
3
Login
To perform a scan, we first need to generate an access token. For that, we will use the login endpoint.
The API key can be found on the Copyleaks API 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.Response
4
Submit the code file for scanning
Use the Submit File Endpoint to send the file for analysis. The request is identical to a text submission: the file content goes in
base64, the file name goes in filename, and the scan settings go in properties. We suggest you provide a unique scanId for each submission, for example one derived from the file path.5
Wait for the completed webhook
The scan can take some time. Once it’s complete, Copyleaks sends a completed webhook to the status URL you provided. It contains a summary of the scan: an overall score, and one entry per source where the code was found, each with a An empty
result ID you will use in the next step.Matches are grouped by where they came from:results.internet- public web pages, including code hosting sites, forums, and documentation.results.database- documents in the Copyleaks Shared Data Hub.results.repositories- your own Private Cloud Hubs, if you scanned against any.
Completed webhook (trimmed)
results section with an aggregatedScore of 0 means none of the code was found in the sources you scanned against.6
Export detailed results
After the
completed webhook arrives, use the export endpoint to retrieve the detailed plagiarism results using the result IDs you received in the completed webhook. Each result contains the character positions of every matched range in your file and in the source, which you can map back to line numbers or feed into the Copyleaks report.We will also export the Crawled Version. The crawledVersion webhook contains the text version of the submitted file as Copyleaks processed it. This can later be used in order to display the report.In addition, you should also specify a completionWebhook to receive notifications when the export is ready.7
Summary
You have successfully submitted a source code file for plagiarism detection and exported the results. You can now handle the results in your application, highlight the matched lines for your users, or take further actions based on the findings.
Tune the scan for source code
The defaults work for most code scans. These settings are the ones teams most often adjust:- Where to look.
scanning.internet(on by default) covers public web sources. Addscanning.repositoriesto also compare against your own codebase in a Private Cloud Hub, which is how you check new code against everything your organization already indexed. - Keep proprietary code private. Don’t turn on
scanning.copyleaksDbfor proprietary code. Whenindexing.copyleaksDbis omitted, it follows thescanning.copyleaksDbflags, so scanning against the Shared Data Hub also adds your file to it, where other Copyleaks users’ scans can match it. To compare proprietary code against your own codebase, use a Private Cloud Hub withscanning.repositoriesinstead. - Cut down on noise. Source files share a lot of boilerplate, such as import blocks, license headers, and common idioms. Use
filters.minCopiedWordsto hide results below a minimum match size, andsensitivityLevel(1 is fastest, 5 is most thorough) to control how deep the scan goes. See Detection Levels for how identical, minor-change, and paraphrase matching can be toggled individually. - Ignore sources you own. If your own public sites show up as matches, exclude them with
filters.domainstogether withfilters.domainsModeset to1.
Frequently asked questions
Next steps
Webhooks Overview
Learn how to securely receive and process notifications from Copyleaks.
Viewing Scan Results
Understand the scan result format and how to display it to your users.
Data Hubs
Compare code against your own Private Cloud Hub or the Shared Data Hub.
Submit File Reference
Every property you can set on a scan, with request and response examples.

