Skip to content

SDK Bridge

webdesign29 edited this page Jun 13, 2026 · 2 revisions

SDK Bridge

The optional SDK module lets WordPress offload work to bext's managed-execution SDK. Both features are off by default and fail open — if bext can't take the work, WordPress's normal path runs and nothing is lost.

Enable under Bext → Settings → SDK bridge, or with constants:

define( 'BEXT_WP_SDK_EMAIL', true );
define( 'BEXT_WP_SDK_JOBS', true );

Email via bext (wp_mail)

When enabled, the plugin hooks pre_wp_mail and sends through POST /__bext/sdk/email/send (with X-Bext-App-Id). It maps the standard wp_mail arguments — to / cc / bcc, subject, HTML-vs-text (from the Content-Type header), reply_to, from, and file attachments (base64-encoded).

  • On a confirmed bext success (HTTP 200 + {"ok":true}) it short-circuits wp_mail.
  • Otherwise it returns control to WordPress (native wp_mail runs) and fires bext/sdk_email_fallback so you can log why:
add_action( 'bext/sdk_email_fallback', function ( $res, $atts ) {
    error_log( 'bext email fallback: ' . wp_json_encode( $res ) );
}, 10, 2 );

bext's email/send needs a per-app SMTP config (POST /__bext/sdk/email/config/set). Until that's set it returns {"ok":false} and the plugin falls back to WordPress — by design.

Background jobs (bext/enqueue)

Push work onto a bext queue (POST /__bext/sdk/queue/push):

// Fire-and-forget (action form):
do_action( 'bext/enqueue', 'thumbnails', array( 'attachment' => 42 ) );

// …or get the job id back (filter form):
$id = apply_filters( 'bext/enqueue_job', null, 'emails', array( 'to' => 'a@b.co' ), 30 /* delay s */ );

A bext-side worker consumes the queue. If jobs are disabled or bext is unreachable, enqueue returns null and the action is a no-op.

App ID

SDK calls carry X-Bext-App-Id, which scopes the bext-side queue/email config. It defaults to the site host; override via the App ID setting or BEXT_WP_APP_ID.

Cloud mode

In Cloud mode, SDK calls also send the bearer token, but the remote endpoint must authorize the SDK surface (purge is the natively token-gated endpoint). If it doesn't, the bridge fails open to WordPress's normal path.

Clone this wiki locally