MageSentinel
Τεκμηρίωση

REST API

Ό,τι προσφέρει το API αφορά μόνο το δικό σας workspace και απαιτεί API key. Η βασική διεύθυνση είναι https://magesentinel.com/api/v1.

← Όλη η τεκμηρίωση · Ενημερώθηκε 2026-10-26

Πιστοποίηση

Δημιουργήστε key στο dashboard, στα API keys. Τα keys ξεκινούν με cg_ και εμφανίζονται μία φορά· κρατήστε το ως secret στο CI σας. Στείλτε το σε κάθε αίτημα ως bearer token. Αιτήματα χωρίς key, ή με οτιδήποτε άλλο εκτός από API key, παίρνουν 401. Διαγράψτε ένα key από το dashboard για να το ανακαλέσετε αμέσως.

bash
curl -H "Authorization: Bearer $MAGESENTINEL_API_KEY" \
  https://magesentinel.com/api/v1/stores

Κάθε απάντηση είναι JSON με το αποτέλεσμα στο data. Τα σφάλματα έχουν μήνυμα στο error και τον αντίστοιχο κωδικό HTTP:

json
{ "data": [ { "id": "cmssp3dol0007dgj7luxpe85j", "url": "https://example-shop.com/", "platform": "magento2" } ] }

{ "error": "Invalid or missing API key" }

Endpoints

Όλες οι διαδρομές είναι σχετικές με το https://magesentinel.com/api/v1. Τα παραδείγματα στη σελίδα API keys του dashboard δείχνουν την πλήρη απάντηση κάθε endpoint ανάγνωσης.

text
GET    /stores                        List your stores
POST   /stores                        Add a store
GET    /stores/{id}                   One store, with its monitors
PATCH  /stores/{id}                   Update a store
DELETE /stores/{id}                   Remove a store

GET    /monitors                      List your monitors
POST   /monitors                      Add a monitor
PATCH  /monitors/{id}                 Update a monitor
DELETE /monitors/{id}                 Remove a monitor
POST   /monitors/{id}/run             Start a check now
GET    /monitors/{id}/uptime          Hourly uptime

GET    /runs                          Runs (storeId, monitorId, status, flowType, limit)
GET    /runs/{id}                     One run, with its checkout payload
GET    /runs/{id}/evidence            Screenshots captured for a run
GET    /runs/stats                    The numbers behind the success rate

GET    /incidents                     Incidents
GET    /incidents/{id}                One incident
GET    /alerts                        Alerts that have been sent
GET    /alert-channels                Your alert channels
GET    /overview/board                Per-step latency across stores

Έλεγχος μετά από deploy

Βρείτε το id του monitor με GET /monitors και ξεκινήστε έλεγχο στο τελευταίο βήμα του deploy:

bash
curl -X POST -H "Authorization: Bearer $MAGESENTINEL_API_KEY" \
  https://magesentinel.com/api/v1/monitors/MONITOR_ID/run

Η απάντηση είναι 202. Ο έλεγχος τρέχει μέσα σε ένα δυο λεπτά και ειδοποιεί από τα συνηθισμένα κανάλια αν αποτύχει κάποιο βήμα:

json
{ "data": { "jobId": "…", "status": "queued" } }

Για να περιμένει το pipeline το αποτέλεσμα, ξεκινήστε τον έλεγχο και ρωτάτε τον πιο πρόσφατο έλεγχο του monitor. Το script θέλει curl και jq:

bash
#!/usr/bin/env bash
# Start a check and fail the pipeline if it does not PASS within 5 minutes.
set -euo pipefail
API=https://magesentinel.com/api/v1
AUTH="Authorization: Bearer $MAGESENTINEL_API_KEY"
SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ)

curl -fsS -X POST -H "$AUTH" "$API/monitors/$MONITOR_ID/run" > /dev/null

for i in $(seq 1 30); do
  sleep 10
  run=$(curl -fsS -H "$AUTH" "$API/runs?monitorId=$MONITOR_ID&limit=1" | jq -r --arg s "$SINCE" \
    '.data[0] | select(.startedAt >= $s) | .status')
  case "$run" in
    PASS) echo "Checkout OK"; exit 0 ;;
    FAIL) echo "Checkout FAILED"; exit 1 ;;
  esac
done
echo "No result in time"; exit 1

Στο GitHub Actions, αποθηκεύστε το key ως secret και καλέστε το script ως τελευταίο βήμα:

yaml
# .github/workflows/deploy.yml (last step)
- name: Check the checkout
  env:
    MAGESENTINEL_API_KEY: ${{ secrets.MAGESENTINEL_API_KEY }}
    MONITOR_ID: ${{ vars.MAGESENTINEL_MONITOR_ID }}
  run: ./scripts/check-checkout.sh

Όρια

Κάθε API key μπορεί να κάνει 60 αιτήματα το λεπτό και να ξεκινήσει το πολύ 6 ελέγχους κάθε 10 λεπτά. Οι προγραμματισμένοι έλεγχοι δεν επηρεάζονται και κρατούν τη συχνότητα του πακέτου σας. Πάνω από το όριο το API απαντά 429 με Retry-After σε δευτερόλεπτα:

json
HTTP/1.1 429 Too Many Requests
Retry-After: 600

{ "error": "Too many check runs: at most 6 every 10 minutes per API key" }