PushizoDocs
Messaging & campaigns

Data Feeds

Data Feeds fetch data from an external JSON endpoint for each recipient at send time and make it available in templates as {{ feed.<name>.field }} (loyalty points, stock, cart, weather…). Decision record:…

Data Feeds fetch data from an external JSON endpoint for each recipient at send time and make it available in templates as {{ feed.<name>.field }} (loyalty points, stock, cart, weather…). Decision record: docs/adr/0028-data-feeds-dynamic-content-ai.md.

Defining a feed

Dashboard → Messages → Dynamic Content → Data Feeds → New feed, or the public API:

curl -X POST https://api.pushizo.example/v1/apps/$APP_ID/data-feeds \
  -H "Authorization: Bearer $API_KEY" -H "content-type: application/json" \
  -d '{
    "name": "profil",
    "url_template": "https://api.ornek.com/u/{{ user.external_id }}?sehir={{ user.tags.sehir }}",
    "secret_headers": { "Authorization": "Bearer <servis-anahtarı>" },
    "cache_ttl_seconds": 300,
    "timeout_ms": 1500
  }'
FieldDescription
nameLiquid name: lowercase letters, digits, underscores (feed.profil). Unique within the app.
url_templateCan use user.*, subscription.*, custom_data.* via Liquid; values are URL-encoded.
methodGET (default) or POST.
body_templatePOST only: a JSON template; variables are JSON string-escaped.
headersNon-secret headers (visible in responses).
secret_headersSecret headers: stored with envelope encryption and never shown again (only their names). Kept if omitted on update; null removes them all.
cache_ttl_seconds0–86400; the cache key is feed + resolved URL (+ body). Editing the feed invalidates the cache.
timeout_ms100–2000 (2 s maximum).

Security (SSRF)

  • Only https:// and public addresses: localhost, .local/.internal, private/reserved IPs (10/8, 172.16/12, 192.168/16, 127/8, the 169.254.169.254 metadata address, local IPv6…) and usernames/passwords in the URL are rejected.
  • The hostname is resolved via DNS at request time; if it resolves to a private address no request is made, and the connection is pinned to the verified IP (DNS rebinding protection). Redirects are not followed.
  • The response must be at most 256 KB and JSON (an object or array).
  • In local development, WEBHOOK_ALLOW_INSECURE_TARGETS=true allows http/local addresses (it cannot be enabled in production).

Using feeds in templates and fallback content

If a feed cannot be fetched (timeout, HTTP error, non-JSON response, open circuit), sending does not stop; the feed value is simply empty. So always provide a fallback wherever you use a feed:

{% if feed.profil %}You have {{ feed.profil.puan }} points!{% else %}Discover your points!{% endif %}

Only feeds referenced in the template are fetched (feed.profil → only profil). Within a single send, the same resolved URL is requested only once.

Circuit breaker

If a feed fails 5 times in a row, the circuit opens for 30 s and no requests are made during that time. When the period ends, a single attempt is made: if it succeeds the circuit closes, otherwise it opens again. The state is shared across all worker instances in Redis.

Trying it out (test)

Click Try in the dashboard or call POST /v1/apps/{appId}/data-feeds/{feedId}/test {"external_id": "…"}: it fetches with the sample user's values, bypassing the cache, and returns the status, HTTP code, duration, resolved URL and a JSON preview.

Monitoring

  • Metrics: data_feed_fetch_total{status="ok|cached|timeout|error|circuit_open|blocked"}, data_feed_fetch_duration_seconds.
  • The worker log warning "data feed çekilemedi; varsayılan içerikle devam" (data feed could not be fetched; continuing with default content) includes the feed ID, status and a short error; URLs and headers are not logged.

On this page