Vigil

API · PHP

PHP guide

The curl extension on your server. Walk through register or sign-in, create a key, send one ordinary request, read alerts, then the follow-up calls you will need later.

Uses the curl extension. Ingest answers HTTP 202; other workspace routes answer HTTP 200.

Before you start

  • API host defaults to https://api-vigil.bizinvestify.com.
  • Put VIGIL_API_KEY in the server environment.
  • Check success before reading data.

Day one in PHP

Helper + day-one flow

Login, create a key, ingest, list alerts.

<?php
function vigil(string $path, string $method = "GET", ?string $token = null, ?string $apiKey = null, ?array $body = null): array {
    $base = getenv("VIGIL_ENDPOINT") ?: "https://api-vigil.bizinvestify.com";
    $ch = curl_init($base . $path);
    $headers = ["accept: application/json"];
    if ($body !== null) {
        $headers[] = "content-type: application/json";
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    }
    if ($token) $headers[] = "authorization: Bearer " . $token;
    if ($apiKey) $headers[] = "x-api-key: " . $apiKey;
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_RETURNTRANSFER => true,
    ]);
    $payload = json_decode(curl_exec($ch), true);
    curl_close($ch);
    if (empty($payload["success"])) {
        throw new RuntimeException($payload["message"] ?? $payload["error"] ?? "Vigil request failed");
    }
    return $payload["data"] ?? [];
}

$session = vigil("/api/v1/auth/login", "POST", null, null, [
    "email" => "ada@example.com",
    "password" => "Password!234",
]);
$created = vigil("/api/v1/api-keys", "POST", $session["accessToken"], null, [
    "name" => "Production server",
]);
echo "Copy this once: " . $created["apiKey"] . PHP_EOL;

$recorded = vigil("/api/v1/ingest", "POST", null, getenv("VIGIL_API_KEY") ?: $created["apiKey"], [
    "method" => "GET",
    "path" => "/products",
    "query" => "q=shoes",
    "statusCode" => 200,
    "ip" => "102.89.1.20",
    "userAgent" => "Mozilla/5.0",
    "headers" => ["host" => "shop.example", "accept" => "application/json"],
    "durationMs" => 18,
    "authFailed" => false,
]);
print_r(vigil("/api/v1/alerts?limit=20", "GET", $session["accessToken"]));

More useful calls

Ack an alert

Same bearer token as the dashboard.

vigil("/api/v1/alerts/" . $alertId . "/ack", "POST", $session["accessToken"]);

Set webhook URL

Growth and Scale only. Public https required.

vigil("/api/v1/settings/webhook", "PUT", $session["accessToken"], null, [
    "url" => "https://example.com/vigil",
]);

What success looks like

Envelope on failure

Always check success before trusting data.

{"success": false, "error": "...", "message": "Sentence for a person."}

Tips

  • A wrong password, used-up plan, or bad key still returns the envelope with success false.
  • Do not print the full API key in web logs.

Prefer the dashboard for day-to-day work. Prefer these language pages when you wire by hand. The interactive operator reference stays on the console at https://api-vigil.bizinvestify.com/docs.

New here? Open a workspace on the site, create a key under API keys, then come back and run step 3.