Skip to main content

HTTP Sync Target

The HTTP sync target sends price data to any arbitrary HTTP endpoint via POST, PUT, or PATCH. Use this when you need to integrate pricing with a system that does not have a dedicated provider (e.g., a custom API or third-party service).


How It Works

The provider:

  1. Builds a compact JSON payload with all nFusion prices.
  2. Adds configured headers (including an optional auth token read from an env var).
  3. Issues an HTTP request to the configured endpoint using the configured method and timeout.

Configuration Settings

SettingDefaultDescription
endpoint_url(required)Full HTTPS URL to POST/PUT/PATCH prices to
methodPOSTHTTP method: POST, PUT, or PATCH
timeout30Request timeout in seconds (5–300)
custom_headers(optional)JSON object of additional headers, e.g. {"X-API-Version": "v1"}
auth_header_env_var(optional)Name of the .env var containing the auth token
auth_header_nameAuthorizationHeader name for the auth token

Payload Format

{
"tenant": "Retail",
"tenant_id": 1,
"synced_at": "2026-03-27T10:30:00Z",
"count": 150,
"prices": [
{"s": "SKU-001", "b": 100.50, "a": 105.00, "wb": 95.00, "wa": 99.00},
{"s": "SKU-002", "b": 200.00, "a": 210.00}
]
}

Compact Key Reference

KeyFull NameDescription
sSKUProduct identifier
bBidBid price
aAskAsk price
wbWholesale BidWholesale bid
waWholesale AskWholesale ask

Authentication

Set the token in .env:

HTTP_SYNC_AUTH_TOKEN="Bearer my-token-here"

In the sync target settings:

  • Auth Header Env Var: HTTP_SYNC_AUTH_TOKEN
  • Auth Header Name: Authorization

The provider will include Authorization: Bearer my-token-here in every request automatically.


Example Receiving Endpoint (PHP)

<?php
header('Content-Type: application/json');

$auth = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
if ($auth !== 'Bearer ' . getenv('API_SECRET_TOKEN')) {
http_response_code(401);
echo json_encode(['error' => 'Unauthorized']);
exit;
}

$data = json_decode(file_get_contents('php://input'), true);

foreach ($data['prices'] as $price) {
$sku = $price['s'];
$ask = $price['a'];
// update your system...
}

http_response_code(200);
echo json_encode(['success' => true, 'processed' => count($data['prices'])]);

Key File

app/SyncTargets/Http/HttpSyncTargetProvider.php