livewire·rust

The update endpoint

The browser posts one signed batch and reads back new markup. This page states the contract exactly: what the request must carry, what the server checks and in what order, and what each failure answers.

update request
{
  "_token": "the session token",
  "components": [
    {
      "snapshot": "{\"data\":{...},\"memo\":{...},\"checksum\":\"...\"}",
      "updates": { "count": 1 },
      "calls": [
        { "method": "increment", "params": [], "metadata": {} }
      ]
    }
  ]
}
Live exampleopen ↗

The JSON on the left is the batch shape this page documents; the frame is a component that speaks it.

Where it lives

Every endpoint sits under a prefix derived from the application key: the first eight hexadecimal characters of SHA-256 over the key string followed by livewire-endpoint.

/livewire-{hash}/update
/livewire-{hash}/upload-file
/livewire-{hash}/preview-file/{filename}
/livewire-{hash}/js/{file}
/livewire-{hash}/css/{file}

The update endpoint accepts POST and is registered in the web group, so the session and the framework's CSRF check run before the handler. The handler itself owns every other check.

The page publishes the address it used as data-update-uri on the script tag and as uri in window.livewireScriptConfig. Setting update_uri in configuration changes that published address; the package still registers the default path only, so an application that changes it must serve the new URI itself.

What the request must carry

RequirementFailure
An X-Livewire header, any value404, empty body
A content type starting with application/json404, empty body
A valid session CSRF token: _token in the JSON body, or a token header419 from the framework's CSRF middleware
A JSON body no larger than payload.max_size500, with the configured limit named
At least one component, each with a string snapshot, an object updates, and an array calls404, empty body

The body is read before it is parsed, so a chunked request without a content length still meets the size guard. The request is then rebuilt around a cheap clone of the bytes, so the session, the signed-in user, and an action's services still work.

{
  "_token": "the session token",
  "components": [
    {
      "snapshot": "{\"data\":{...},\"memo\":{...},\"checksum\":\"...\"}",
      "updates": { "count": 1 },
      "calls": [
        { "method": "increment", "params": [], "metadata": {} }
      ]
    }
  ]
}

snapshot is one minified JSON string per component. A call's params is a list or an object; any other JSON type is malformed. Every component envelope is checked before any count limit applies, so a malformed batch is a 404 rather than a limit violation.

The per-component pipeline

Components run in the order the request listed them. One request holds the whole batch's state: the render stack, the children, the response assets, and the computed values.

  1. Parse the snapshot into data, memo, and checksum. A structure the protocol does not define is a 404.
  2. Verify the checksum. The client's failure allowance is checked once for the batch, before the first snapshot, and each failure is counted.
  3. Decide whether the component can skip its render: no updates, only $commit calls, declared reactive props, no bindings, and props identical to what the parent passed. A skip answers {"skip":true,"id":...}.
  4. Run the registered persistent guards. The first guard that answers a response ends the whole batch with it.
  5. Check the release token. A mismatch is a 419.
  6. Check the origin the snapshot recorded against the update's Origin header, or the host it was addressed to. A mismatch is a 404.
  7. Restore the children the memo recorded, then hydrate the fields from data. A field the component does not publish, or one it locked, cannot be updated.
  8. Run boot, initialize, and hydrate; then fetch unresolved model references.
  9. Apply a parent's reactive props, then each update in order: updating for the root field, the dotted-path assignment, and one updated per touched root after all assignments.
  10. Run the calls in order: an event is resolved to a listener, an upload call is handled by the runtime, a policy may refuse, and a JSON action records its return metadata.
  11. Fetch model references an action wrote, then render unless the response skips it: JSON-only calls, an explicit skipRender, or a redirect without render_on_redirect.
  12. Run dehydrate, build and sign the new snapshot, inject wire:id, wire:name, wire:snapshot, and wire:effects into the first root tag, and add the result as effects.html. An island action answers with its fragment instead.

The answer carries one entry per component, in request order, plus the response-level assets:

{ "components": [ { "snapshot": "...", "effects": { "html": "..." } } ], "assets": [] }

A streamed action sends its frames before that payload. The response is then text/event-stream with cache-control: no-cache and x-livewire-stream: true; each frame is {"stream":true,"body":{...},"endStream":true}, and the ordinary JSON payload follows the last frame. Assets are not injected into a streamed answer.

The snapshot envelope

Three keys, always in this order, serialized minified so the same snapshot always encodes to the same bytes:

KeyHolds
dataThe wire-public fields, in declaration order, plus __meta__ for synthesized fields
memoid, name, children, release, then the feature entries: json, async, isolate, props, errors, scripts, assets, slots, and the page's path, method, origin
checksumHMAC-SHA256, lowercase hex

memo.children is always an object, and an empty child list is {}, never null or an omission.

The checksum signs {"data":...,"memo":...} with memo.children removed, under the application's encryption key. The child list is the one part the browser may rewrite while it morphs the DOM, so it is outside the signature; every other entry is covered. Verification removes the same parts and compares in constant time, so a tampered data.count is a 419 while a rewritten child list is accepted.

The release token is a-{release_token}-{component release token}, with both defaults a, so an unchanged installation sends a-a-a. A redeployment that changes the configured token invalidates every browser session still holding an old snapshot. The check runs after the checksum.

The failure allowance

A client that keeps sending corrupt snapshots is stopped by the framework's rate limiter:

Limits

All four live under payload in the configuration. None disables one. Each configured limit answers 500 with the message below, which names the setting.

SettingDefaultCounts
max_size1048576 bytesThe request body, compared after it is read
max_nesting_depth10One dotted update path, such as a.b.c
max_calls50Every call in the batch, summed
max_components200Every component in the batch

The error table

StatusCauseMessage
404Missing header or JSON content type, empty or invalid body, malformed envelope, foreign originEmpty body
404A model reference names no rowUnable to find the [post] model for the reference [12].
404Snapshot structureInvalid Livewire snapshot structure: expected [data], [memo], [checksum], [memo.id], and [memo.name].
419ChecksumLivewire encountered corrupt data when trying to hydrate a component.
419Release tokenLivewire detected a release token mismatch.
419Unknown actionUnable to call component method. Public method [save] not found on component
419Locked fieldUnable to update locked property [id] of component [counter]
419Typed hydrationUnable to hydrate [count] into component [counter]: ...
429Failure allowance usedToo many invalid Livewire requests. Please try again later.
500Unknown componentUnable to find component: [posts]
500Field not publicUnable to set component data. Public property [$title] not found on component: [post-editor]
500Payload too largeLivewire request payload is too large (2048KB). Maximum allowed size is 1024KB. followed by the setting's path
500Too many componentsToo many components in a single request (201). Maximum allowed is 200. followed by the setting's path
500Too many callsToo many method calls in a single request (51). Maximum allowed is 50. followed by the setting's path
500Path too deepProperty path [a.b.c] exceeds the maximum nesting depth of 10 levels. followed by the setting's path
500RenderingNo root tag, more than one root element, or a view that does not exist
500Undeclared eventHandler for event [post-saved] does not exist
401Upload URLThe upload endpoint's signature is invalid or expired
403A policy refused an actionThis action is unauthorized.
403Temporary file referenceThe temporary file reference is invalid or expired
422An upload failed validationthe uploaded file is invalid: ...

Production sends the status, not the reason. Every response above is an empty body with its status. In debug mode the framework's error page renders for a corrupt payload, a release mismatch, an unknown method, and an undeclared event; other errors gain an x-livewire-error header carrying the message. A framework error page answers 500 even for a debugged 419.

Validation is not in this table on purpose. A rule failure during an update is an HTTP 200: the messages travel in memo.errors, the component renders with them, and the browser reads them from the snapshot.