SyncsnapServer
SyncsnapServer is the server-side client used to create jobs, get job status, and get presigned upload/download URLs. Use it only in Node (e.g. Next.js route handlers, API routes, or other backend code). It reads process.env.SYNCSNAP_TOKEN for authentication.
Construction
SYNCSNAP_TOKEN is set (get it from the dashboard).
Methods
createJob()
Creates a new transfer job. Returns the job object (id, projectId, status, createdAt, updatedAt). The frontend uses theid to build the QR URL and poll status.
getJob(jobId: string)
Fetches the current job (status, fileName, etc.). Used by your polling endpoint.getUploadUrl(jobId, options)
Gets a presigned upload URL for the given job. Used when the phone needs to upload a file; the SyncSnap upload page typically calls your backend or the API. Options:fileName (required), optional expirationMinutes.
getDownloadUrl(jobId, options?)
Gets a presigned download URL for a completed job. Your backend calls this and returns the URL to the frontend. Options: optionalexpirationMinutes.
waitForJobCompletion(jobId, options?)
Polls the job until status iscompleted or failed, or until timeout/abort. Optional: intervalMs, timeoutMs, onPoll(job), signal (AbortSignal).
Errors
If the SyncSnap API returns an error or a non-2xx status, the SDK throws anError with a message (e.g. from the API body or a generic “Syncsnap request failed (status)”). Handle these in your route and return an appropriate HTTP response.