# Go SDK Quickstart

> Install the Copyleaks Go SDK, authenticate, and submit your first scan in under 5 minutes with this step-by-step guide.

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

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)**.
- Go 1.22 or later. The SDK has no dependencies outside the standard library.

## Get Started

<Steps>
  <Step title="Installation">
    Add the official `copyleaks-go` module to your project.

    ```bash
    go get github.com/Copyleaks/copyleaks-go@v1.1.0
    ```
  </Step>

  <Step title="Quick Example: Scan Text">
    <Warning>
    Remember to replace the placeholder credentials and webhook URL with your actual values.
    </Warning>

    ```go title="main.go"
    package main

    import (
        "context"
        "fmt"
        "log"

        "github.com/Copyleaks/copyleaks-go"
    )

    func main() {
        ctx := context.Background()
        client, err := copyleaks.NewClient()
        if err != nil {
            log.Fatal(err)
        }

        // Log in to the Copyleaks API. The token is valid for 48 hours; reuse it.
        token, err := client.Login(ctx, "YOUR_EMAIL_ADDRESS", "YOUR_API_KEY")
        if err != nil {
            log.Fatal(err)
        }

        // Submit a simple string of text for scanning
        scanID := "my-first-scan"
        err = client.SubmitFile(ctx, token, scanID, &copyleaks.FileSubmission{
            Content:  []byte("Hello world, this is a test."), // the SDK base64-encodes it
            Filename: "test.txt",
            Properties: copyleaks.ScanProperties{
                // {STATUS} becomes completed, error, creditschecked or indexed.
                Webhooks: copyleaks.SubmitWebhooks{Status: "https://your-server.com/webhook/{STATUS}"},
                Sandbox:  true, // Turn on sandbox mode for testing
            },
        })
        if err != nil {
            log.Fatal(err)
        }
        fmt.Println("Scan submitted successfully! Scan ID:", scanID)
        fmt.Println("You will be notified via your webhook when the scan is complete.")
    }
    ```
  </Step>

  <Step title="Understanding the Code">
    The example code performs four main actions to submit a scan:

    1.  **Create a client:** `copyleaks.NewClient()` creates the client that sends every request. Every method takes a `context.Context` first.
    2.  **Login:** It authenticates with your email and API key to get a login token, which is required for all subsequent requests.
    3.  **Configure Scan:** It fills a `FileSubmission` with the content, a filename and `ScanProperties`. We enable `Sandbox` mode for safe testing and provide the webhook URL. The SDK encodes `Content` to Base64 for you.
    4.  **Submit for Scanning:** `SubmitFile` sends the submission to the Copyleaks API. The process is asynchronous; Copyleaks will notify your webhook URL once the scan is complete.
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/Copyleaks/copyleaks-go">Check the official Copyleaks Go SDK repository on GitHub for more examples and details.</Card>
  <Card title="Go Package Reference" icon="golang" href="https://pkg.go.dev/github.com/Copyleaks/copyleaks-go">Browse every type and method of the SDK on pkg.go.dev.</Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="Check for Plagiarism" icon="magnifying-glass" href="/guides/authenticity/detect-plagiarism-text">
    Detect plagiarism in text documents using the Copyleaks API. Search billions of sources to find unoriginal content.
  </Card>
  <Card title="Detect AI-Generated Content" icon="robot" href="/guides/ai-detector/ai-text-detection">
    Detect AI-generated text via sync or async API calls. This guide covers sync detection, see the Authenticity API Guide for async.
  </Card>
  <Card title="Assess Grammar and Writing Quality" icon="spell-check" href="/guides/writing/check-grammar">
    Get writing and grammar suggestions via API. Authenticate, submit text, and access full details in the docs.
  </Card>
  <Card title="Moderate Text" icon="shield-halved" href="/guides/moderation/moderate-text">
    Scan and moderate text content for unsafe or policy-relevant material across 10+ categories.
  </Card>
</CardGroup>
