Developers/Scorecards JS

Browser capture SDK · v1

Install and integrate scorecards-js.

Open a CADDIE.100-owned scorecard capture experience from a client website. The SDK privately validates and stages photos, collects round details, submits a durable asynchronous job, and returns its ID to the host application.

Framework-agnosticPublishable keysCamera and file inputDurable job callbacks

Installation

Add one client-owned capture entry point.

Install the package in the website that will open Smart Scorecards. The package includes TypeScript contracts, the browser client, and the complete full-screen, modal, and inline widget UI.

npm install --save-exact @caddie100/scorecards-js@1.0.0
Package deliveryInstall the versioned public npm package under the included CADDIE.100 customer license. A publishable API key with capture permission is required separately. Pin the version in production builds; sibling file dependencies are for local development.

Browser credentials

Use a publishable key for an allowed origin.

Scorecards JS accepts only a c100_pk_live_… or c100_pk_test_… key carrying the separately licensed scorecards:capture scope. CADDIE.100 verifies the requesting browser origin on every configuration and capture request.

Never place a private c100_live_… or c100_test_… credential in browser code, browser storage, a public repository, an analytics event, or a client-visible log. Publishable keys cannot call the private normalization or processing endpoints.

import { createScorecardsClient } from "@caddie100/scorecards-js";

const scorecards = createScorecardsClient({
  apiKey: "c100_pk_live_…",
  // Defaults to https://www.caddie100.com.
});

For local development, set baseUrl: "http://localhost:3100" and serve the client from its registered local origin. baseUrl must be an HTTP or HTTPS origin without a path, query, fragment, or embedded credentials.

Quick start

Mount one button. Let the SDK own the upload flow.

mountJobButton() adds an SDK-owned launcher to the supplied container. It does not request camera access, open a picker, create a job, or upload anything until the user acts inside the modal.

const widget = scorecards.mountJobButton({
  container: document.querySelector<HTMLElement>("#scorecard-upload")!,
  buttonLabel: "Add scorecard",
  maxPhotos: 24,
  externalReference: "client-round-123",
  initialRound: {
    courseId: "COURSE_ID",
    teeBox: "Blue",
    holesPlayed: 18,
    startingHole: 1,
    playedOn: "2026-09-18",
  },
  onSuccess(response) {
    // Associate this durable job with the signed-in host user.
    hostScorecards.saveJob(response);
  },
  onError(response) {
    hostScorecards.showError(response.message);
  },
  onCancel(response) {
    hostScorecards.handleCanceledUpload(response);
  },
});

// When the host experience unmounts:
await widget.destroy();
  1. Create one client.Initialize it with the site's publishable key and, when needed, a non-production API origin.
  2. Mount one job widget.Pass its container, optional 1–24 photo limit, round defaults, and callbacks.
  3. Let the golfer add photos.Each selected photo is privacy-re-encoded, uploaded separately, and validated immediately.
  4. Store the successful job ID.Use externalReference or the callback selection strings to associate it with the host's user and workflow.
  5. Destroy on unmount.Abort work and release previews, object URLs, event listeners, staged resources, scroll locks, and SDK-owned DOM.

Configuration

Choose how much the host supplies.

buttonLabelUpload scorecard by default
theme / labelsOptional partner colors, radii, and button copy
maxPhotos24 by default · 1–24 supported by the built-in widget
locationOptional WGS 84 latitude and longitude for nearby course choices
initialRoundCourse, tee, holes, starting hole, date, and optional tee time
externalReferenceOpaque client identifier returned unchanged
styleNonceOptional CSP nonce for the Shadow DOM stylesheet
callbacksVersioned success, error, and cancel handoffs

Use initialRound when the host already knows part or all of the round. The golfer can confirm or change those values before submission.

The course picker opens immediately and requests nearby choices instead of downloading the course directory. Pass location when the host already knows WGS 84 coordinates; otherwise CADDIE.100 attempts a coarse IP-derived location from Vercel request headers. Coordinates are used only to rank Typesense results and are not returned. After two typed characters, the same authenticated endpoint returns at most ten browser-safe course/location matches. Tee choices include published color, gender applicability, total yardage, and men's/women's rating and slope when available. The built-in job widget requires a published tee selection and does not accept a typed replacement.

const widget = scorecards.mountJobButton({
  container: document.querySelector<HTMLElement>("#scorecard-upload")!,
  maxPhotos: 1,
  initialRound: { holesPlayed: 9, startingHole: 10 },
});

// The SDK owns the launcher and modal. Hosts may also open it from their UI.
await widget.open();

Partner branding and copy

Customize colors and button labels.

Pass theme and labels to mountJobButton(). Omitted values keep CADDIE.100 defaults. These options apply to the durable job widget and its field editors, preview, and photo controls. Configure them when mounting; destroy and mount again to change them. The older capture widget does not accept these options.

const widget = scorecards.mountJobButton({
  container: document.querySelector<HTMLElement>("#scorecard-upload")!,
  buttonLabel: "Scan your scorecard",
  theme: {
    launcherBackground: "#075985", launcherText: "#ffffff",
    primaryBackground: "#075985", primaryText: "#ffffff",
    primaryHoverBackground: "#0c4a6e",
    secondaryBackground: "#ffffff", secondaryText: "#075985",
    secondaryBorder: "#075985", link: "#0369a1", linkHover: "#075985",
    focus: "#075985", controlRadius: 12, modalRadius: 20,
  },
  labels: {
    continueToPhotos: "Add photos", browseFiles: "Choose photos",
    takePhoto: "Open camera", back: "Previous",
    createJob: "Submit Scorecard", closePreview: "Return to photos",
    confirmRemove: "Yes, delete", cancelRemove: "Keep photo",
  },
});

Colors must be opaque six-digit hex strings such as #075985. controlRadius and modalRadius accept numbers from 0–32 pixels; mobile dialogs remain full screen. Pair background and text colors with sufficient contrast, and check hover and focus states. Launcher colors inherit the primary colors unless overridden.

Supported color keys: launcherBackground, launcherText, primaryBackground, primaryText, primaryHoverBackground, secondaryBackground, secondaryText, secondaryBorder, link, linkHover, focus, background, surface, text, mutedText, border, danger, dangerText, required, requiredHover, selectedBackground, closeBackground, closeText, closeBorder, closeHoverBackground. Defaults retain rose required indicators and danger actions; partners can override those tokens explicitly. The dark photo preview canvas remains optimized for viewing images.

Labels accept 1–80 characters of plain text and merge with defaults. Unknown keys, markup, control characters, and invalid colors are rejected before the widget mounts. Labels persist through upload progress, retries, and editor transitions. Icon-only controls use the configured text as their accessible name, with the photo filename added where relevant. buttonLabel controls the launcher separately.

continueToPhotos
Continue to photos
browseFiles
Browse files
takePhoto
Take a photo
back
Back
backToDetails
Back to round details
createJob
Submit Scorecard
creatingJob
Creating scorecard job…
startingProcessing
Starting processing…
uploadingPhotos
Uploading...
fixUpload
Fix upload to continue
retryJob
Retry scorecard job
close
Close scorecard photos
closeEditor
Close round detail
closePreview
Close preview
previewPhoto
Enlarge preview
removePhoto
Remove photo
confirmRemove
Delete photo
cancelRemove
Keep photo
retryUpload
Try upload again
chooseAnotherDate
Choose another date
saveDate
Save date
noTeeTime
No tee time

Changing a label changes its visible copy and accessible name. For example, createJob defaults to Submit Scorecard and still submits an asynchronous processing job. The callback fields, status codes, validation messages, course names, and date/time values keep their API meaning. This is button-copy customization, not complete localization.

Keep mobile titles and actions inside the safe area.

The modal, field editors, preview, and delete confirmation use safe-area padding. Headers reserve the top inset; footers reserve the bottom inset, with 58px minimum buttons on phones and 56px on desktop. Date values and tee-time cells use 18px text. Full-screen dialogs use dynamic viewport height so browser controls can expand and collapse.

The host page should set <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">. The SDK consumes the browser-provided safe-area insets and does not alter the host viewport tag. In Next.js, export viewport = { width: "device-width", initialScale: 1, viewportFit: "cover" } from the host layout.

Durable processing jobs

Upload, keep the job ID, and leave the page safely.

The built-in job widget privacy-re-encodes and privately stages each photo as soon as it is chosen. Final submission atomically creates a 24-hour CADDIE.100 job from those opaque capture IDs, starts processing, closes the modal, and returns the jobId. Store that ID in the host's own submission record.

const accepted = await hostScorecards.loadAcceptedJob();
let current = await scorecards.getProcessingJob(accepted.jobId);
while (!["COMPLETE", "COMPLETE_WITH_REVIEW", "PARTIAL", "FAILED"].includes(current.status)) {
  await new Promise((resolve) => setTimeout(resolve, current.requirements.pollAfterSeconds * 1_000));
  current = await scorecards.getProcessingJob(accepted.jobId);
}

await hostScorecards.saveExtractionResult(current);

getProcessingJob() returns the current state and, at a terminal state, every photo's public Process response and review decisions. A host server with an authorized same-organization credential may poll the same HTTP endpoint instead of keeping the browser open.

Each terminal capture exposes a typed ScorecardProcessingResult. Its roundDrafts[].record values are typed ScorecardRoundRecord objects that the host can copy into its own durable record and correction workflow.

for (const capture of current.result?.captures ?? []) {
  for (const draft of capture.processing?.roundDrafts ?? []) {
    // Store this canonical record in ParTC. The user may correct or replace it.
    await hostScorecards.saveCanonicalRound(draft.record);
  }
}

// Later Scoring and Reports requests belong on the ParTC backend, using the
// accepted or corrected canonical record. Scorecards JS never holds a private key.
Copy the terminal resultCADDIE.100 deletes each privacy-safe source photo after that capture reaches a terminal processing state. The structured job and extraction result expire after 24 hours. The host remains responsible for its permanent user record, correction and approval UI, notifications, and any later Scoring call.

Capture flow

Choose the round, then add validated photos.

File or camera roll

Choose photos

Accepts JPEG, PNG, and WebP sources up to 25 MB, validates image headers and dimensions before decoding, prevents duplicates, and shows revocable local previews before processing.

Live camera

Take one photo

Requests the rear camera only after an explicit user action. A denied, unavailable, or unsupported camera leaves file selection available.

Immediate validation

Bound upload concurrency

Each photo uploads as its own bounded request, with no more than three active at once. Its row shows waiting, preparation, progress, server validation, failure, or ready dimensions and size.

Review

Preview, retry, or remove

The golfer can enlarge a local preview, retry only a failed row, or remove an unclaimed staged photo. Submission stays blocked until every selected photo is ready. Back returns to the selected round details.

Embedded metadata is removed before uploadWhen processing begins, the SDK applies the photo's encoded orientation, draws only its pixels into a browser canvas, and uploads a newly encoded image under a generic filename. It automatically recompresses oversized phone photos under the 4 MB upload boundary and reduces dimensions only when compression alone is insufficient. The original bytes, filename, and embedded EXIF, GPS coordinates, comments, thumbnails, and similar metadata are not submitted. This protection also applies when an integration calls processCapture() directly.

Results and events

Connect the SDK to the host application.

onSuccess, onError, and onCancel receive small versioned objects. getState() returns the current bounded widget state without exposing files, image URLs, staged IDs, or processing results.

const widget = scorecards.mountJobButton({
  container: document.querySelector<HTMLElement>("#scorecard-upload")!,
  onSuccess(response) {
    // Includes jobId, accepted job status, and safe round display strings.
    hostScorecards.saveJob(response);
  },
  onError(response) {
    reportSafeClientError(response.code, response.message);
  },
  onCancel(response) {
    hostScorecards.handleCanceledUpload(response);
  },
});

const currentState = widget.getState();

Success means CADDIE.100 accepted and submitted the asynchronous job; it does not mean handwriting processing has finished. The success object includes the job ID, accepted status, course ID/name, tee, date/time, holes, starting hole, and photo count.

Scorecards JS ends at this extraction handoff. It has no Scoring or Reports method and does not receive corrections. A partner backend can send any valid canonical round record—whether extracted, corrected, manually entered, or imported—to the private CADDIE.100 Scoring API, then send that same current record to Reports when it needs a printable PNG.

Choose the lifecycle deliberatelyPersist the returned jobId. Poll GET /api/v1/scorecard-jobs/{jobId} from the host backend or use the matching SDK primitive when browser polling is appropriate.
Deliberately excludedBrowser callbacks do not receive normalization transforms, semantic region maps, temporary artifact URLs, provider provenance, usage data, or processing cost data.
const widget = scorecards.mountJobButton({
  container: document.querySelector<HTMLElement>("#scorecard-upload")!,
  onError(response) {
    if (response.retryable) showRetryGuidance(response.message);
    else showCaptureError(response.message);
  },
});

Lifecycle

Close, reopen, and clean up predictably.

open()Open the modal from a host-owned action
close()Cancel the unfinished operation and return focus
getState()Read the bounded immutable job-widget state
destroy()Abort work, release resources, and remove the launcher

A successful submission closes automatically. The mounted launcher can start the next submission. Call destroy() when a component, route, or client-owned experience unmounts.

Browser and host requirements

Preserve camera, preview, and policy boundaries.

  • Serve the host over HTTPS before enabling live camera capture. Localhost is accepted for development.
  • Allow the configured CADDIE.100 origin in connect-src.
  • Allow blob: in img-src for local, revocable photo previews.
  • Pass the request nonce as styleNonce when the host uses a nonce-based style-src policy. The SDK applies it to its Shadow DOM stylesheet.
  • When embedded, grant camera access through Permissions Policy and the iframe's allow="camera" attribute.

Test the exact production Content Security Policy. Do not weaken a global policy merely to accommodate the widget.

Current product boundary

Manual photo selection with automatic upload.

The v1 job widget supports desktop drag/drop, browser files, mobile camera capture through the file input, one to 24 photos, automatic private staging, and durable asynchronous processing jobs. The earlier synchronous capture-session widget remains source-compatible but is not required by the v1 job flow.

Automatic shutter behavior, live marker coaching, video/page streaming, HEIC conversion, correction UI, partner storage, Scoring or Reports calls, and season analytics are not part of the SDK. Those exclusions are product boundaries, not feature gates.

For the private server normalization and processing contracts—including request limits, response versions, capture guidance, retention, and stable problem codes—use the Smart Scorecards HTTP API documentation.