docs

Documentation

Three job endpoints, one auth header, one polling loop. Everything on this page documents the deployed v1 surface — the machine-readable version is openapi.json, and the coding-agent version is agents.md.

API REFERENCE AGENTS.MD

Quickstart

Upload a file, point a voice at it, poll until it is done, download the result. Five curl calls, under five minutes. The base URL and key come from your environment — never hardcode a domain.

Base URL: $VOICESWAP_API_BASE # the api.* origin of your Voiceswap deployment API key: $VOICESWAP_API_KEY # vsk_… — created in the studio, shown exactly once
# 1 · Register an upload → presigned PUT URL (valid 1 h) curl -s "$VOICESWAP_API_BASE/v1/uploads" -X POST \ -H "authorization: Bearer $VOICESWAP_API_KEY" \ -H "content-type: application/json" \ -H "idempotency-key: $(uuidgen)" \ -d '{"content_length": 4718592, "rights_attestation": true}' # → 201 { "upload_id": "upl_…", "r2_key": "…", "put_url": "https://…", "expires_at": "…" } # 2 · Put the audio bytes straight to storage curl -s -X PUT "<put_url>" --data-binary @song.wav # (files ≤ 50 MB can use PUT /v1/uploads/direct instead; send # x-voiceswap-rights-attestation: true with that raw-body call) # 3 · Create the job — always 202 + a job id curl -s "$VOICESWAP_API_BASE/v1/swap" -X POST \ -H "authorization: Bearer $VOICESWAP_API_KEY" \ -H "content-type: application/json" \ -H "idempotency-key: $(uuidgen)" \ -d '{"input": {"upload_id": "<upload_id>"}, "voice": "<id from GET /v1/voices>"}' # → 202 + Location + Retry-After; { "id": "job_…", "status": "queued", "status_url": "/v1/jobs/job_…", … } # 4 · Poll Location when Retry-After permits; cache ETag and send If-None-Match curl -i "$VOICESWAP_API_BASE/v1/jobs/<job_id>" \ -H "authorization: Bearer $VOICESWAP_API_KEY" \ -H 'if-none-match: "<previous etag>"' # → 304 if unchanged, or { "status": "queued" | "processing" | "succeeded" | "failed" | "cancelled", … } # 5 · Fetch the signed result URL (valid 15 min — call again for a fresh one) curl -s "$VOICESWAP_API_BASE/v1/jobs/<job_id>/result" \ -H "authorization: Bearer $VOICESWAP_API_KEY" # → { "url": "https://…", "expires_at": "…", "format": "wav" } curl -s -o swapped.wav "<url>"
Every job POST returns 202. Follow Location, obey the server's Retry-After, and use ETag/If-None-Match for cheap 304 polling. Never re-send a mutation without its original Idempotency-Key.
Payment environments. The deployed dev environment uses Stripe sandbox mode, so only Stripe test cards are charged. The in-process test provider is confined to local wrangler dev and automated tests. Staging and production refuse billable work until their real Stripe configuration is complete — billing fails closed, never open.
Speech input is beta. Singing is the validated path; the speech evaluation (plan item P2.16) has not recorded its verdict yet. Speech routes through a separation-bypass path and works, but quality is not yet gated.

Authentication

Every request carries a bearer token. Keys start with vsk_ (256-bit, random), are stored only as a SHA-256 hash, and the plaintext is shown exactly once — at creation or rotation.

authorization: Bearer vsk_…

Keys are scoped: each key carries an endpoint allowlist and a voice allowlist (or all). Missing, invalid, or revoked credentials return 401 with a Bearer challenge; a valid key outside its scope returns 403 forbidden before any billing artifact exists.

Rotation keeps the key's id, scopes, limits and usage history but swaps the secret; the old token stops resolving immediately. Revocation propagates to the enforcement cache in ≤ 60 seconds, with an immediate push in the normal path. There is no grace window.

To verify a key and see what it can reach:

GET/v1/ping
200 → { "ok": true, "workspace": { "id": "ws_…", "plan" }, "actor": { "type": "api_key", "id": "key_…" }, "scopes": { "endpoints", "voices": "all" | ["voice_…"] } }

Uploads

Audio bytes never travel in a job request — jobs reference an upload. Three ways to get the bytes in, all landing in workspace-scoped storage keys that only your keys can reference:

Rights declaration required. Every conversion-source upload must explicitly confirm rights_attestation: true. The direct-body route uses x-voiceswap-rights-attestation: true. Clone/training datasets require a separate declaration when that currently-disabled capability is enabled. The server records the current voice-rights policy version, document hash, signer, subject, context and time in append-only evidence. A missing or false declaration returns 400 input_invalid before an upload row or job can be created.

Presigned single PUT PRIMARY

POST/v1/uploads

Returns a presigned URL you PUT the file to, valid 1 h. Mandatory for files over 50 MB; recommended for everything.

FIELDMEANING
content_lengthoptionalSize in bytes — lets the server floor the credit hold honestly.
rights_attestationrequiredMust be literal true; confirms ownership or all permissions needed for this upload and use.
201 → { "upload_id": "upl_…", "r2_key": "input/<ws>/<uuid>", "put_url": "https://…", "expires_at": "…" }

Direct upload (≤ 50 MB)

PUT/v1/uploads/direct

Raw request body streamed to storage — the API never buffers the file. Content-Length and x-voiceswap-rights-attestation: true are required; when sending Idempotency-Key, send Content-Digest so retries can compare the bytes. Anything over 50 MB is refused with 400 input_invalid.

201 → { "upload_id": "upl_…", "r2_key": "…" }

Resumable multipart

POST/v1/uploads/multipart

Initiate a multipart session, then sign parts, upload each part to its URL, and complete with the ETags. Re-request part URLs any time to resume.

STEPCALLNOTES
initiatePOST /v1/uploads/multipartbody { "rights_attestation": true } → 201 { upload_id, r2_key }
sign partsPOST /v1/uploads/multipart/{id}/partsbody { "part_numbers": [1, 2, …] } — 1–100 numbers per call, part numbers 1–10000 → { parts: [{ part_number, put_url }] }
completePOST /v1/uploads/multipart/{id}/completebody { "parts": [{ "part_number", "etag" }] } (ETags from each part PUT) → { r2_key }
abortPOST /v1/uploads/multipart/{id}/abort→ { "aborted": true }
Upload lifecycle, precisely: only incomplete sessions are swept — a presigned slot that never received its PUT, or a multipart session never completed, is aborted and cleaned up after 24 h. A completed upload (direct, presigned-and-PUT, or completed multipart) stays stored until a job consumes it; when that job succeeds, the input is deleted per the retention policy (immediately by default — zero retention unless you opt in to history). There is currently no automatic sweep for completed uploads you never reference and no upload-delete endpoint (only an open multipart session can be aborted) — so upload only what you intend to convert.
Caps at launch: 100 MB / 30 minutes per job. Job POSTs take JSON only — multipart/form-data file bodies are not accepted on /v1/swap · /v1/vocals · /v1/instrumental; upload first, then reference input.upload_id.

Trust & safety intake

Public, unauthenticated reports are rate-limited by the same anonymous edge limiter used for signup recovery. Intake is durable in the admin review queue. Until an email vendor is configured, acknowledgement and action notices are recorded with delivery status stubbed; the API does not claim an email was sent.

POST/reports/abuse

Required: requester_email, target_type, a target_id or target_url, category, and description.

POST/takedown

The same target fields plus literal good_faith: true, accurate: true, and signature: true. Read the versioned takedown policy before submitting.

201 → { "id": "<report uuid>", "status": "open", "acknowledgement": "recorded_stub", "policy_url": "/takedown-policy/2026-08-23" }
POST/v1/swap

Replace the singer (or speaker — see the speech-beta note) in a recording. The model aims to retain performance features, but separation and conversion can alter them; review each result.

BODY (application/json)
FIELDMEANING
inputrequired{ "upload_id": "…" } or { "r2_key": "…" } — an upload owned by your workspace. The object must exist before the POST. If both fields are sent, upload_id takes precedence.
voicerequiredA voice id from GET /v1/voices with "status": "ready". A voice outside the key's scope is 403; an unknown one is 404 voice_not_found; a not-ready one is 409 conflict.
params.pitchoptionalSemitone shift applied at conversion. Integer, −24 to 24, default 0. Validated on the processing engine, not at the POST — an out-of-range value is accepted with 202, then the job fails with input_invalid (never billed).
params.preserve_timingoptionalBoolean, default true. Currently no effect — conversion is always frame-exact (timing is always preserved); the flag is accepted for forward compatibility only.
params.denoiseoptionalBoolean, default false. Applies only when the input is classified as speech (the separation-bypass path); a music mix goes through separation instead and denoise is ignored.
formatoptionalwav, mp3 or flac. Default wav.
duration_hint_secondsoptionalSizes the temporary credit hold — any number greater than 0, at most 1800 (fractions allowed; the hold rounds up to whole seconds). It can only enlarge the hold and is floored by the upload's byte size; billing always uses the measured duration, never this hint. When a workspace spend cap (including the first-week ceiling) or a key minute/spend cap applies, the hint is ignored and the hold is the 1800-second job maximum, so queued jobs can never settle above the cap.
RESPONSE — 202 Accepted
{ "id": "job_0d5a…", "status": "queued", "endpoint": "swap", "voice_id": "voice_…", "format": "wav", "input_duration_seconds": null, "billed_duration_seconds": null, "failure": null, "created_at": "2026-08-16T12:00:00.000Z", "updated_at": "2026-08-16T12:00:00.000Z", "finished_at": null, "output_available": false, "status_url": "/v1/jobs/job_0d5a…", "links": { "self": "/v1/jobs/job_0d5a…", "result": null } }

Send Idempotency-Key: <uuid> on every mutation. The same key and parameters replay the stored success or executed failure for 24 h; different parameters return 409. Validation failures release the key, and abandoned executions become retryable after a short lease.

POST/v1/vocals

Return only the vocal from a mixed recording — the first stage of what /v1/swap does internally. Same request shape as swap, minus the voice.

BODY (application/json)
FIELDMEANING
inputrequired{ "upload_id" } or { "r2_key" } — upload_id wins if both are sent.
params.denoiseoptionalBoolean, default false. Speech-bypass only: applied when the input is classified as speech; a music mix is separated instead and denoise is ignored.
formatoptionalwav | mp3 | flac, default wav.
duration_hint_secondsoptionalAs on /v1/swap.

Responds 202 with the same job object ("endpoint": "vocals", "voice_id": null); poll and fetch the result the same way.

POST/v1/instrumental

Return the backing track with the vocal removed. Same separator as /v1/vocals, opposite half; both halves bill from the same meter — the length of the input.

BODY (application/json)
FIELDMEANING
inputrequired{ "upload_id" } or { "r2_key" } — upload_id wins if both are sent.
formatoptionalwav | mp3 | flac, default wav.
duration_hint_secondsoptionalAs on /v1/swap.

Responds 202 with the job object ("endpoint": "instrumental").

Jobs

GET/v1/jobs/{id}

The lifecycle is queued → processing → succeeded | failed, with queued | processing → cancelled. Queued/processing responses include Retry-After; every representation has an ETag and honors If-None-Match → 304. Durations are integer seconds. Failures use failure: {code, detail, retryable}.

DELETE/v1/jobs/{id}

Cancel a queued or processing job. The credit hold is released and the GPU task is terminated; a cancelled job is never billed, even if the GPU finishes late — the late result is discarded and reconciled. Cancelling an already-cancelled job returns 200 again (idempotent); a job that already succeeded or failed is 409 conflict.

GET/v1/jobs/{id}/result

A signed download URL for the output of a succeeded job.

200 → { "url": "https://…", "expires_at": "…", "format": "wav" }
  • The URL is valid 15 minutes and carries a Content-Disposition download filename; call the endpoint again any time for a fresh one.
  • Still queued/processing → 409 conflict ("poll GET /v1/jobs/:id"). Failed or cancelled → 409, no result exists.
  • After retention deletion → 404 not_found with an explicit message. The default retention is zero plus a 1 h download grace window — download promptly.

Voices

GET/v1/voices

Every voice the calling key can reach: published library voices plus your workspace's own, filtered by the key's voice scope. Only a voice with "status": "ready" can be used in /v1/swap.

200 → { "data": [ { "id": "voice_…", "name": "Atlas", "status": "ready", "kind": "professional", "best_for": ["pop", "soul"], "library": true, "created_at": "…" } ], "has_more": false, "next_cursor": null }

All list endpoints use ?limit=25&cursor=…; limit defaults to 25 and is bounded to 1–100. Cursors are opaque.

Training your own voice via the API is not live yet — voice training ships with the clone-training control plane. Platform owners can import a trained model into their workspace.

Import a trained voice

Use an admin key with the explicit voices:import action. Imported voices start private. When imports are disabled, these endpoints return HTTP 503 with code import_unavailable and retryable: false.

POST/v1/voices/imports
{ "name": "Studio alto", "rights_attestation": true, "rights_basis": "I trained this model on my own voice.", "sample": true, "model_size_bytes": 10485760, "sample_size_bytes": 131072 }

PUT the ZIP (only model.pth and an optional model.index, up to 500 MiB) to model_put_url. If requested, PUT a WAV, MP3 or FLAC preview up to 20 MiB to sample_put_url. Rename Applio files to those exact names at the ZIP root. Declare the exact ZIP byte count in model_size_bytes. Include sample_size_bytes only when sample is true. Each PUT must send the matching Content-Length. Use a protocol-2 torch.save checkpoint with data.pkl up to 2 MiB and a FAISS index if supplied. Each entry may expand to 1 GiB. For DEFLATE entries over 1 MiB expanded, the ratio limit is 20:1. Send If-None-Match: * with both PUTs and omit x-amz-copy-source. Set Content-Type to application/zip for the model and application/octet-stream for the preview. The URLs expire after 15 minutes.

POST/v1/voices/imports/{voice_id}/complete

After uploading, complete the import with an empty body. A ready voice can be used immediately in a swap. Invalid uploads return 400.

GET/v1/voices/imports/{voice_id}

Returns the voice ID and status. A failed import includes its reason.

Webhooks

Register an HTTPS endpoint and Voiceswap POSTs you events instead of making you poll. Delivery is at-least-once and asynchronous; the event insert is transactional with the state change that caused it, so an event you receive is always true — but you may receive it twice. Deduplicate on vs-event-id.

POST/v1/webhooks
FIELDMEANING
urlrequiredYour HTTPS endpoint.
event_typesoptionalSubset of the event types below. Default includes succeeded, failed, and cancelled jobs.
201 → { "id": "…", "url": "…", "secret": "whsec_…" } // secret shown ONCE — store it
GET/v1/webhooks

Cursor page → { "data": [{ id, url, event_types, active, created_at }], "has_more", "next_cursor" }.

DELETE/v1/webhooks/{id}

Deactivate an endpoint → { "deleted": true }.

GET/v1/webhooks/{id}/deliveries

Cursor page of delivery attempts; unknown or foreign endpoints return 404.

POST/v1/webhooks/deliveries/{id}/replay

Put any delivery — including a dead-lettered one — back in the queue now → { "replayed": true }.

Event types

Every delivery uses one envelope: { id: "evt_…", type, created_at, data }. Job lifecycle events are a discriminated union on type; all three carry the same full data.job resource. job.succeeded additionally carries data.billing: { amount, currency }. Failed-job details use the same public taxonomy text as polling and never expose provider diagnostics.

TYPEWHEN
job.succeededA job finished and was billed. LIVE
job.failedA job ended in a failure class — nothing billed. LIVE
job.cancelledCancellation committed; billing is irreversibly released while provider cleanup may continue. LIVE
workspace.spend_alertA measured settle pushed the workspace over its spend cap. LIVE
workspace.payment_failedAn overage charge permanently declined — new billable work refuses until resolved. LIVE
workspace.payment_method_saved · workspace.topup_succeeded · workspace.clone_paid · workspace.refund_issued · workspace.dispute_createdImplemented billing lifecycle events. LIVE
voice.ready · voice.failedReserved for voice training — emitted once the training control plane ships. RESERVED

Signature verification

Every delivery is signed with your endpoint's secret. Headers:

vs-signature: t=<unix_ts>,v1=<hex hmac_sha256(secret, "<t>.<raw_body>")> vs-event-type: job.succeeded vs-event-id: <event uuid> // deduplicate on this vs-delivery-id: <delivery uuid>
// Node — verify before trusting the body import { createHmac, timingSafeEqual } from "node:crypto"; function verify(secret, header, rawBody, toleranceSeconds = 300) { const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? ""); if (!m) return false; const [, t, sig] = m; if (Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false; // replay guard const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex"); return timingSafeEqual(Buffer.from(sig), Buffer.from(expected)); }

Verify against the unmodified raw body, reject timestamps older than five minutes, use constant-time comparison, and ignore unknown future event types. Webhook deliveries do not follow redirects. A 3xx response counts as a failed attempt. Failed deliveries retry after 1 m → 5 m → 30 m → 2 h → 8 h, then dead-letter; replay revives them.

Errors

Every non-2xx JSON response is application/problem+json with RFC 9457 fields plus stable code, request_id, and retryable. The nested error member is a deprecated v1 compatibility extension. Every type URI resolves to the public error registry, which lists meaning and remediation.

{ "type": "https://voiceswap.dev/docs/errors#voice_not_found", "title": "Voice not found", "status": 404, "detail": "…", "instance": "/v1/swap", "code": "voice_not_found", "request_id": "…", "retryable": false }
HTTPCODEBILLEDMEANING
400input_invalidneverA parameter, body, or the input audio is missing or malformed; this includes a missing/false upload rights_attestation (or direct-upload attestation header).
401unauthorizedneverKey missing, unknown, or revoked; includes a Bearer challenge.
402payment_requiredneverNo payment method on the workspace (card-first, no free minutes), or a previous charge failed and must be resolved.
403insufficient_scopeneverValid key lacks endpoint or voice scope.
403forbiddenneverThe authenticated actor lacks permission for the action.
404not_foundneverNo such route or object — including outputs already deleted by retention.
404voice_not_foundneverThe referenced voice does not exist for this workspace.
409conflictneverIdempotency-Key reused with a different body, job in the wrong state, voice not ready, upload session not open.
429rate_limitedneverrpm limit, per-key monthly minute cap, or workspace spend cap. Carries Retry-After.
429queue_fullneverOnly when an operator-configured per-workspace concurrent-job cap is reached (none by default — extra jobs are accepted and queue). Carries Retry-After.
500separation_failedneverThe separation stage failed on this input.
500quality_rejectneverThe engine rejected its own output.
400webhook_destination_blockedneverThe webhook destination is private, local, reserved, or otherwise prohibited.
502provider_rejectedneverThe GPU provider rejected the control request.
502provider_auth_failedneverThe GPU provider rejected the configured credential.
503provider_rate_limitedneverThe GPU provider requested a deferred retry.
503provider_degradedneverThe GPU circuit breaker is open after repeated provider failures.
500internalneverSomething failed on our side. Retry once with backoff.
501not_implementedneverThe surface exists but this action ships in a later release — do not retry.
503oom_retryneverTransient GPU memory pressure — safe to retry with backoff.
504timeoutneverThe job exceeded its processing deadline.

The BILLED column is the taxonomy's per-class billable flag: today it is never for every class — a failed or refused call does not bill, period. Job failures appear as the structured failure object on the job.

Rate limits & caps

Every response authenticated to an API-key quota bucket carries RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and RateLimit-Policy. An unauthenticated 401 omits them; authenticate and retry. A 429 also carries Retry-After.

CEILINGSCOPEDEFAULTON HIT
Requests / minuteper keyplan rpm — 30 payg · 60 starter · 300 producer · 1000 scale (settable per key)429 rate_limited, short Retry-After
Monthly minutesper keynone (set per key, with on_cap: block | overage)block: 429 rate_limited, Retry-After = seconds to month end · overage: keeps converting and bills at the plan rate
Concurrent jobsper workspaceno cap — extra jobs are accepted (queued) and become processing once handed to the GPU provider, including while they wait there for a free GPU worker; rpm, minute and spend caps still applynever refused for concurrency by default · only an operator-configured cap returns 429 queue_full, short Retry-After
Monthly spendper workspace$50 (raiseable in settings; new workspaces carry a first-week ceiling)429 rate_limited, Retry-After = seconds to month end
HTTP/1.1 429 Too Many Requests retry-after: 12 ratelimit-limit: 30 ratelimit-remaining: 0 ratelimit-reset: 12 ratelimit-policy: 30;w=60 { "status": 429, "code": "rate_limited", "retryable": true, … }

Failure posture (deliberate, documented): the rpm limiter fails open — if the limiter is unreachable, non-metered requests still work. Caps fail closed — a job-creating POST whose cap state cannot be verified is refused. Spend safety beats availability.

Billing

  • Per processed input minute, rounded up to the second. The billed figure is the input duration measured on the server during processing — never a client-supplied number. Money is ceil(seconds × rate / 60).
  • Failed, refused and cancelled calls are free. An out-of-scope 403 never creates a billing artifact.
  • Card-first, no free minutes. A workspace needs a payment method before its first job — otherwise 402 payment_required.
  • Funds order when a job settles: included plan minutes → rollover → prepaid credit → card overage, atomically, in that order (and released in exactly the reverse order when a hold is freed).
  • Exactly-once: a credit hold is reserved with the job row, the measured amount settles once at finalization, and duplicate charges are structurally rejected. Card overage is charged only after a job succeeds.
RATES — from the versioned price catalog (v1, USD)
PLANPER MINUTEMONTHLYANNUAL (per mo)INCLUDED MINRPM
Pay as you go$0.10$0$0030
Starter$0.08$14$815060
Producer$0.06$28$16450300
Scale$0.04$79$4918001000
VOICE CLONE PRICES (per clone; cloning ships with the training control plane)
PLANPRIVATE CLONINGAVAILABILITY
Pay as you go$9$19
Starter$7$9
Producer$5$9
Scale$3$9
Private cloning: waitlist-only during private beta. Dataset requirements, training time and quality guidance will be published only after the training flow ships and has measured evidence.
Rollout state, honestly: subscription checkout, included-minute allocation and prepaid top-ups arrive with the payments/billing completion work. Until they land, every conversion settles as card overage at your plan's per-minute rate — the funds ladder above is live code, its earlier rungs simply hold zero. Annual prices are the per-month figure when billed annually.

Output spec PENDING P1 BENCH

What is fixed today: outputs come back in the format you asked for — wav, mp3 or flac — at the same length and timing as the input, loudness-matched to the source with a gate and limiter in the render path.

What is not final yet: the numeric loudness target (LUFS), output sample-rate/bit-depth guarantees, and per-format encode settings are pinned by the GPU performance bench (plan item P1.11), which has not run on built images yet. This section will carry the exact numbers when the bench lands; until then, do not build to an assumed LUFS value.