Skip to main content

Authentication

SDK Authentication

All Silent Witness SDKs use API key authentication. You configure your API key once when initializing your SDK client, and the SDK handles all authentication automatically.

🔑

API Key Authentication

Configure your API key when creating your SDK client

🛡️

Automatic Header Management

SDKs automatically include authentication in all requests

Configuring Authentication

Configure your API key when initializing your SDK client:

import "github.com/silentwitness/go-sdk"

// Option 1: Package-level configuration
silentwitness.Key = "sk-your-api-key-here"

// Option 2: Client instance configuration
client := silentwitness.NewClient(silentwitness.Config{
APIKey: "sk-your-api-key-here",
})
defer client.Close()
info

API keys start with sk- and are 64 characters long. Keep your API key secure and never expose it in client-side code.

Environment Variables

For production applications, store your API key in environment variables:

import (
"os"
"github.com/silentwitness/go-sdk"
)

client := silentwitness.NewClient(silentwitness.Config{
APIKey: os.Getenv("SILENT_WITNESS_API_KEY"),
})

Getting an API Key

Access Console Dashboard

Log into your Silent Witness Console dashboard

Generate API Key

Navigate to API keys section and create a new key

Secure Your Key

Store your API key securely in environment variables

Test Your Key

Upload a test file to verify your key works

API Key Management

Account Association

API keys are associated with your account and all usage is billed to your account:

  • Cases created via API keys are associated with your account
  • Invoices are generated automatically for case creation and usage
  • All usage counts toward your subscription plan limits
  • Case history shows both user-created and API key-created cases

Scopes

API keys can be restricted to specific scopes:

  • read - Read-only access to SDK methods
  • write - Full read/write access to all methods
  • admin - Administrative operations

Rate Limits

Each API key has rate limiting applied:

  • Default: 1000 requests per hour
  • SDK Handling: SDKs automatically handle rate limit errors with retry logic
  • Custom: Contact support for higher limits

Security Best Practices

warning

Keep your API key secure

  • Never commit API keys to version control
  • Use environment variables in production
  • Rotate keys regularly
  • Monitor key usage

Authentication Errors

If authentication fails, SDKs will return language-specific errors:

response, err := client.Files.Upload(ctx, &silentwitness.UploadFileRequest{
Content: []byte("test"),
Filename: silentwitness.String("test.txt"),
})
if err != nil {
// Check for authentication error
if strings.Contains(err.Error(), "UNAUTHENTICATED") {
log.Fatal("Invalid API key")
}
}

Testing Authentication

Use the file upload method to test your authentication:

package main

import (
"context"
"log"
"github.com/silentwitness/go-sdk"
)

func main() {
client := silentwitness.NewClient(silentwitness.Config{
APIKey: "sk-your-api-key-here",
})
defer client.Close()

fileBytes := []byte("test file content")
response, err := client.Files.Upload(context.Background(),
&silentwitness.UploadFileRequest{
Content: fileBytes,
Filename: silentwitness.String("test.txt"),
Purpose: silentwitness.String("crash_analysis"),
})
if err != nil {
log.Fatalf("Authentication failed: %v", err)
}

log.Printf("Success: File uploaded with ID %s", response.FileId)
}