Skip to content
Official SDKs

C# SDK Quickstart

This guide will walk you through installing the official C# SDK and running your first scan. In just a few minutes, you’ll be able to check content for plagiarism, AI-generated text, and more directly from your .NET application.

🔑 Before you begin

In order to start integrating Copyleaks API, you'll need an account and an API key:

  1. Installation

    First, install the official Copyleaks package from NuGet into your project using the Package Manager Console.

    Terminal window
    Install-Package Copyleaks
  2. Quick Example: Scan Text

    Program.cs
    using System;
    using System.Text;
    using System.Threading.Tasks;
    using Copyleaks.SDK.V3.API;
    using Copyleaks.SDK.V3.API.Models.Requests;
    using Copyleaks.SDK.V3.API.Models.Requests.Properties;
    public class Program
    {
    // --- Your Credentials ---
    private const string USER_EMAIL = "YOUR_EMAIL_ADDRESS";
    private const string USER_KEY = "YOUR_API_KEY";
    private const string WEBHOOK_URL = "https://your-server.com/webhook/{STATUS}";
    // --------------------
    public static async Task Main(string[] args)
    {
    try
    {
    // Log in to the Copyleaks API
    Console.WriteLine("Authenticating...");
    var identityClient = new CopyleaksIdentityApi();
    var loginResponse = await identityClient.LoginAsync(USER_EMAIL, USER_KEY);
    Console.WriteLine("✅ Logged in successfully!");
    // Prepare your content for scanning
    Console.WriteLine("Submitting text for scanning...");
    var apiClient = new CopyleaksScansApi();
    var scanId = Guid.NewGuid().ToString();
    var textToScan = "Hello world, this is a test.";
    var base64Content = Convert.ToBase64String(Encoding.UTF8.GetBytes(textToScan));
    // Configure the scan
    var scanProperties = new ClientScanProperties();
    scanProperties.Sandbox = true; // Turn on sandbox mode for testing
    scanProperties.Webhooks = new Webhooks { Status = new Uri($"{WEBHOOK_URL}") };
    var fileDocument = new FileDocument
    {
    Base64 = base64Content,
    Filename = "test.txt",
    PropertiesSection = scanProperties
    };
    // Submit the scan to Copyleaks
    await apiClient.SubmitFileAsync(scanId, fileDocument, loginResponse.Token);
    Console.WriteLine($"🚀 Scan submitted successfully! Scan ID: {scanId}");
    Console.WriteLine("You will be notified via your webhook when the scan is complete.");
    }
    catch (Exception ex)
    {
    Console.WriteLine($"🛑 An error occurred: {ex.Message}");
    }
    }
    }
  3. Understanding the Code

    The example code performs four main actions to submit a scan:

    1. Login: It authenticates with your email and API key to get a secure login token. This token is required for all subsequent requests.
    2. Prepare Content: It takes a simple string of text and converts it into a Base64 string.
    3. Configure Scan: It creates a ClientScanProperties object to define the scan’s behavior. We enable sandbox mode for safe testing and provide a webhook URL for completion notifications.
    4. Submit for Scanning: It creates a FileDocument with the content and properties, then sends it to the Copyleaks API. The process is asynchronous; Copyleaks will notify your webhook URL once the scan is complete.

Now that you’ve submitted your first scan, here are some recommended steps: