Skip to Content

API Reference

All types are exported from the root module (RoControl.<Type>).

RoControl.init(config)RoControlClient

Creates a client. Raises a clear Config error on invalid input. Server-only: calling from the client errors.

FieldTypeDefaultNotes
apiKeystringRequired. Per-universe key from the dashboard.
baseUrlstring?https://api.rocontrol.appMust be http(s).
loggerLogger?built-inCustom structured sink.
logLevelLogLevel?"info"silent | error | warn | info | debug.
metricsMetricsSink?noneOptional metrics hook.
httpTimeoutSecondsnumber?101–60.
maxRetriesnumber?30–10.
retryBaseDelaySecondsnumber?0.50–30.
retryMaxDelaySecondsnumber?100–120, >= base.
circuitBreakerFailureThresholdnumber?51–100.
circuitBreakerCooldownSecondsnumber?601–3600.
enableMemoryStoreLeaseboolean?trueCross-server single-flight for reportEvent.
studioModeboolean?falseFriendlier logs in Studio.

RoControlClient methods

MethodReturnsDescription
registerSchedule(descriptor)OperationResultDeclarative schedule registration. Validates, normalizes, content-hashes, and coalesces identical schedules.
reportEvent(input)OperationResultImperative event report (cross-server single-flight).
buildScheduleFromRegistry(config)RoControlScheduleBuild a descriptor by scanning a Folder of event instances.
onFailedOperation(cb)RBXScriptConnectionFires on dispatch/network failure.
retryFailedOperation(failed)OperationResultRe-dispatch a failed operation.
getHealth()HealthStatusCircuit state, pending count, last success/failure.
flush()()Bounded wait until pending work drains (use in BindToClose).
destroy()()Stop accepting work, flush, release resources.

OperationResult.status is one of sent \| queued \| skipped \| duplicate \| disabled \| failed \| circuit_open. reportEvent/registerSchedule return immediately with queued; the network result arrives via metrics, logs, and onFailedOperation.

Schedule descriptor

type RoControlSchedule = { key: string, timezone: "UTC", cycleSeconds: number, -- length of one cycle eventDurationSeconds: number, -- how long each event is "live" startsAtUnix: number?, -- optional anchor (defaults to epoch-aligned) rotation: { kind: "sequential" } | { kind: "weighted", algorithm: "mulberry32-fnv1a32" }, events: { { key: string, iconAssetId: string?, -- 123, "123", or "rbxassetid://123" durationSeconds: number?, priority: number?, -- lower wins; advanced weight: number?, -- weighted rotation only } }, }

Rotation defaults to sequential. Use weighted only if you need it — it uses the portable mulberry32-fnv1a32 algorithm the backend reproduces exactly; never rely on Roblox Random.new for the icon to match in-game. See Icon Automation Events.

Report input

type ReportEventInput = { key: string, label: string?, iconAssetId: string?, startedAt: number?, -- unix seconds; defaults to now durationSeconds: number?, priority: number?, occurrenceId: string?, -- defaults to "<normalizedKey>:<startedAt>" metadata: { [string]: any }?, }

Errors — RoControlError

{ kind: ErrorKind, message: string, retryable: boolean, statusCode: number?, requestId: string?, cause: any? }

ErrorKind = Auth | RateLimit | Validation | Transport | Server | Timeout | Config | MemoryStore | CircuitOpen | Unknown.

Retry policy: Auth/Validation/Config never retry; RateLimit (honors Retry-After), Server, Timeout, and Transport retry idempotent operations with exponential backoff + jitter, guarded by a circuit breaker.

Metrics

If you pass a MetricsSink, the SDK emits rocontrol.sdk.* counters/timings: init, schedule.register.{attempt,success,failure}, event.report.{attempt,success,failure}, http.retry, lease.{win,loss,error}, circuit.{open,close}, queue.{enqueued,dropped}, and moderation.{pending,approved,rejected,failed} when the backend returns moderation state.

The full source lives at github.com/Badacord/rocontrol-sdk .