---
title: "Post-Dispatch Scripting"
description: "Run PHP code after a successful delivery to process the response and write data back to WordPress."
url: "https://wpwebhooks.org/docs/post-dispatch-scripting/"
---

[WP Webhooks](https://wpwebhooks.org/) / [Docs](https://wpwebhooks.org/docs/) / Post-Dispatch Scripting

Feature Pro since v1.7.0

# Post-Dispatch Scripting

Run PHP code after a successful delivery to process the response and write data back to WordPress.

Attach a post-dispatch snippet to a webhook+trigger. It fires via `fswa_glue_post_dispatch` after a 2xx response. Use it to parse the response, persist returned IDs to post meta, or trigger follow-up logic.

## Available variables

`$payload` — the payload that was sent. `$originalPayload` — the pre-mapping payload. `$responseCode` — the HTTP status code. `$responseBody` — the raw response body.

## Shorthand syntax

Curly-brace placeholders resolve to array access for any variable: `{{ $originalPayload.args.0.id }}` → `$originalPayload['args'][0]['id']`.

## Return value

The return value is ignored — use the snippet for side effects: `update_post_meta()`, `wp_mail()`, `error_log()`, etc. To act on the response with another request, chain a webhook after this one with Webhook Chains instead of calling an API here.

/ Examples

Store a HubSpot deal ID returned in the response

```
// Available: $payload (sent), $originalPayload (pre-mapping), $responseCode, $responseBody
$data = json_decode( $responseBody, true );
if ( isset( $data['id'], $payload['order_id'] ) ) {
    update_post_meta( $payload['order_id'], '_hs_deal_id', $data['id'] );
}
```

/ Related

[Code Glue](https://wpwebhooks.org/docs/code-glue/)[Webhook Chains](https://wpwebhooks.org/docs/webhook-chains/)[fswa\_glue\_post\_dispatch](https://wpwebhooks.org/docs/fswa-glue-post-dispatch/)[fswa\_webhook\_response](https://wpwebhooks.org/docs/fswa-webhook-response/)

/Ready

## Your next automation is  
one sentence away.

[Install Plugin→](https://wordpress.org/plugins/flowsystems-webhook-actions/) [See the Plugin →](https://wpwebhooks.org/wordpress-webhook-plugin/)

$ wp plugin install flowsystems-webhook-actions --activate

## Structured data

```json
{"@context":"https://schema.org","@type":"TechArticle","name":"Post-Dispatch Scripting — Feature — Webhook Actions Docs","description":"Run PHP code after a successful delivery to process the response and write data back to WordPress.","url":"https://wpwebhooks.org/docs/post-dispatch-scripting/","isPartOf":{"@type":"WebSite","name":"WP Webhooks","url":"https://wpwebhooks.org"},"about":{"@type":"SoftwareApplication","name":"Webhook Actions","applicationCategory":"WordPress Plugin"}}
```
