GUIDE 17 / 28 · NATIVE 2.0.7

Webhooks & network work

Send explicitly configured metadata, bound waiting time and keep slow services out of recording export.

Choose what you send#

context.fetch uses the bundled Node fetch implementation. Use an HTTPS endpoint supplied by the user, set a JSON content type and send a minimal payload. The documentation example sends ID, name, type, duration and creation time; it does not upload video or include the absolute filePath.

A generic JSON endpoint is not automatically compatible with Discord or another service's required payload schema. Adapt the body to that service's documented format. An HTTP success response only confirms the receiver accepted the request, not that a video was uploaded.

Keep save hooks fast#

onClipSaved is awaited inside export. Returning a slow network promise directly extends saving time. For optional delivery, start a bounded background task, attach catch immediately and return from the hook. Use a cap or a one-in-flight policy so repeated clip saves cannot create unlimited requests.

JavaScript
onClipSaved(clip, context) {
  if (context.getConfig().sendOnSave !== true) return;
  sendMetadata(clip, context).catch(error => context.log(error.message, 'error'));
}

The full downloadable example skips a new request while one is pending and starts with automatic sending disabled.

Timeouts and response checks#

Always check response.ok; HTTP 400, 429 and 500 responses resolve as normal fetch responses. There is no supplied AbortController global in this VM. A Promise.race deadline can bound how long your action waits, but it does not cancel the underlying network request.

The example reports an eight-second wait deadline while preserving its busy guard until the original fetch settles. It does not start automatic retries. For a production queue, use bounded retention, explicit retry policy and backoff, and keep the receiver's credentials out of log text.

Test before enabling automation#

  1. Leave the default endpoint empty and sendOnSave false.
  2. Configure a destination you control and expect to receive the sample metadata.
  3. Use Test webhook once and inspect the result in the plugin console.
  4. Verify the receiver's payload and HTTP status.
  5. Enable sendOnSave only after the single-request test succeeds.

Restart the plugin service after changing code that leaked background timers. Download the complete implementation from Metadata Webhook.

Implementation reference: PluginManager.createPluginContext; src/native/recorder.ts · native 2.0.7.