Docs
BlogHomeStart building

Visual Edits

Edit the preview directly, no prompt needed.


The preview marks every element with its source location (data-tlm-loc="src/app/page.tsx:12:5"). A visual editor sends a batch of changes to those elements; Totalum patches the code, checks that it still builds, and saves the batch as one version deployed to the preview. All or nothing: a change that cannot be applied leaves the code untouched. Visual edits need a paid plan.

#Apply Visual Edit

POST/api/v1/vcaas/projects/:projectId/visual-edit/applyapi-key0.6 credits

Apply a batch. Answers 202; follow it with Get Visual Edit. Sending the same batchId again returns the same result without a second charge.

Path parameters

ParameterTypeDescription
projectIdstringThe project id

Body parameters

FieldTypeRequiredDescription
batchIdstringYesA UUID you generate (the idempotency key)
baseVersionIdstringYesThe version the preview showed
changesobject[]Yes1–200 changes
changes[].locstringYesThe element's data-tlm-loc (path:line:column)
changes[].kindstringYes"text", "style", "image", "link", "visibility" or "delete"
changes[].beforestring | objectNoThe current value (text, classes, src or href)
changes[].afterstring | object | nullYestext: the new text · style: { add?, remove?, replace? } of Tailwind classes · image: { src, alt? } · link: { href, target? } · visibility: { hidden } · delete: null
changes[].idstringNoYour id for the change

Response fields

FieldTypeDescription
data.batchIdstringThe batch
data.versionIdstringThe version being saved
data.operationobject{ kind: "visualEdit", id, status: "building" }
data.creditsChargednumber0.6 the first time, 0 on a repeat

Example request

curl -X POST \
  -H "api-key: tlm_sk_your_key" \
  -H "Content-Type: application/json" \
  -d '{"batchId":"5f0c2e1a-8d3b-4c6e-9a7f-1b2c3d4e5f60","baseVersionId":"ver_01k6xd2m8q","changes":[{"loc":"src/app/page.tsx:14:7","kind":"text","before":"Book now","after":"Book your cut"}]}' \
  https://builder-api.totalum.app/api/v1/vcaas/projects/barber-bookings/visual-edit/apply
Success · 202 Accepted
json
{ "errors": null, "data": { "batchId": "5f0c2e1a-8d3b-4c6e-9a7f-1b2c3d4e5f60", "versionId": "ver_01k6y6", "operation": { "kind": "visualEdit", "id": "op_01k6y7", "status": "building" }, "creditsCharged": 0.6 } }

Error codes

CodeHTTPMeaning
VALIDATION_ERROR400batchId is not a UUID, or a change is invalid
FREE_PLAN_NO_SOURCE_EDITING403Editing code needs a paid plan
BATCH_ID_IN_USE409The batchId belongs to another project
AGENT_RUNNING409A prompt is running
INSUFFICIENT_CREDITS402Not enough credits
End of Apply Visual EditNext endpointGETGet Visual Edit

#Get Visual Edit

GET/api/v1/vcaas/projects/:projectId/visual-edit/:batchIdapi-keyFree

Whether a batch was saved. A batch that failed before it was saved is refunded.

Path parameters

ParameterTypeDescription
projectIdstringThe project id
batchIdstringThe batch

Response fields

FieldTypeDescription
data.batchIdstringThe batch
data.versionIdstring | nullIts version
data.statestring"saving", "saved" or "failed"
data.errorCodestring | undefinedOn failure, e.g. VISUAL_EDIT_NOT_PATCHABLE, VISUAL_EDIT_TYPECHECK_FAILED, VISUAL_EDIT_BASE_MISMATCH (the file changed since baseVersionId)
data.errorMessagestring | undefinedOn failure
data.refundedbooleanThe credits were given back

Example request

curl -H "api-key: tlm_sk_your_key" \
  https://builder-api.totalum.app/api/v1/vcaas/projects/barber-bookings/visual-edit/5f0c2e1a-8d3b-4c6e-9a7f-1b2c3d4e5f60
Success · 200 OK
json
{ "errors": null, "data": { "batchId": "5f0c2e1a-8d3b-4c6e-9a7f-1b2c3d4e5f60", "versionId": "ver_01k6y6", "state": "saved", "refunded": false } }

Error codes

CodeHTTPMeaning
VISUAL_EDIT_NOT_FOUND404No such batch on this project
End of Get Visual Edit Back to top