Skip to main content

Ingest telemetry

Use the common setup and a key with telemetry:write and topology:read. The record must name a ground station, antenna, and satellite from your network config; this example uses the IDs from the example document. It uses curl, jq, and a current UTC timestamp so the record falls inside the read window.

#!/usr/bin/env bash
set -euo pipefail
: "${CONSTELLATION_API_URL:?Set the API base URL}"
: "${CONSTELLATION_API_KEY:?Set a scoped API key}"
base="${CONSTELLATION_API_URL%/}"
sample_time="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
sample_id="docs-smoke-$(date -u +%Y%m%dT%H%M%S)-$$"
station="gs-1" antenna="ant-1" satellite="sat-1"

payload="$(jq -n --arg time "$sample_time" --arg id "$sample_id" \
--arg gs "$station" --arg ant "$antenna" --arg sat "$satellite" '[{
time: $time,
ground_station_id: $gs,
ground_antenna_id: $ant,
satellite_id: $sat,
contact_id: $id,
fields: {elevation_deg: 22.8}
}]')"

result="$(curl --fail-with-body --connect-timeout 10 --max-time 30 -sS \
-H "x-api-key: $CONSTELLATION_API_KEY" \
-H "Content-Type: application/json" \
--data-binary "$payload" "$base/telemetry")"
printf '%s\n' "$result" | jq .
printf '%s\n' "$result" | jq -e \
'.accepted_count == 1 and .rejected_count == 0' >/dev/null

curl --fail-with-body --connect-timeout 10 --max-time 30 -sS \
-H "x-api-key: $CONSTELLATION_API_KEY" \
"$base/topology?ground_antenna_id=$antenna&satellite_id=$satellite&freshness_seconds=900" \
| jq --arg id "$sample_id" '.state[] | select(.fields.contact_id == $id)'

The write should report one accepted record. The read selects that sample's link by its contact_id. GET /topology holds the current state for 5 seconds, so if the sample is not there yet, repeat only the read after 5 seconds. Do not repeat the write.

Before sending larger batches, read Telemetry for the batch limits, partial rejection, and what a replay does.