SDK (@phosra/sdk)
import { PhosraClient } from "@phosra/sdk";
const phosra = new PhosraClient({
baseUrl: "https://phosra-api-sandbox-production.up.railway.app/api/v1",
accessToken: process.env.PHOSRA_API_KEY,
});
const result = await phosra.webhooks.create({
family_id: "f0000000-0000-4000-8000-0000000000f1",
url: "https://yourapp.com/webhooks/phosra",
events: ["enforcement.completed", "policy.updated"]
});
console.log(result);
curl -sS -X POST "https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks" \
-H "Authorization: Bearer $PHOSRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"family_id": "f0000000-0000-4000-8000-0000000000f1",
"url": "https://yourapp.com/webhooks/phosra",
"events": [
"enforcement.completed",
"policy.updated"
]
}'
import os, requests
BASE = "https://phosra-api-sandbox-production.up.railway.app/api/v1"
res = requests.post(
f"{BASE}/webhooks",
headers={"Authorization": f"Bearer {os.environ['PHOSRA_API_KEY']}"},
json={
"family_id": "f0000000-0000-4000-8000-0000000000f1",
"url": "https://yourapp.com/webhooks/phosra",
"events": [
"enforcement.completed",
"policy.updated"
]
},
)
print(res.status_code, res.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
base := "https://phosra-api-sandbox-production.up.railway.app/api/v1"
body := bytes.NewBufferString(`{
"family_id": "f0000000-0000-4000-8000-0000000000f1",
"url": "https://yourapp.com/webhooks/phosra",
"events": [
"enforcement.completed",
"policy.updated"
]
}`)
req, _ := http.NewRequest("POST", base+"/webhooks", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("PHOSRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.Status, string(out))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'family_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'url' => '<string>',
'events' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"family_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"family_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "d41c8f2a-90b7-4e63-a15c-8f0e2b7d3946",
"family_id": "fcdf4277-ba14-4732-8db5-0369b2c88d8b",
"url": "https://api.rivera-safety.com/webhooks/phosra",
"events": [
"policy.updated",
"enforcement.completed"
],
"active": true,
"created_at": "2026-06-18T14:32:07Z",
"updated_at": "2026-06-30T09:15:44Z"
}{
"error": "Bad Request",
"message": "child_name is required",
"code": 400
}{
"error": "Unauthorized",
"message": "missing or invalid Authorization header",
"code": 401
}{
"error": "Conflict",
"message": "resource already exists",
"code": 409
}{
"error": "Too Many Requests",
"message": "rate limit exceeded",
"code": 429
}{
"error": "Internal Server Error",
"message": "internal error",
"code": 500
}Webhooks
Create a webhook
Register a webhook endpoint to receive event notifications.
POST
/
webhooks
SDK (@phosra/sdk)
import { PhosraClient } from "@phosra/sdk";
const phosra = new PhosraClient({
baseUrl: "https://phosra-api-sandbox-production.up.railway.app/api/v1",
accessToken: process.env.PHOSRA_API_KEY,
});
const result = await phosra.webhooks.create({
family_id: "f0000000-0000-4000-8000-0000000000f1",
url: "https://yourapp.com/webhooks/phosra",
events: ["enforcement.completed", "policy.updated"]
});
console.log(result);
curl -sS -X POST "https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks" \
-H "Authorization: Bearer $PHOSRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"family_id": "f0000000-0000-4000-8000-0000000000f1",
"url": "https://yourapp.com/webhooks/phosra",
"events": [
"enforcement.completed",
"policy.updated"
]
}'
import os, requests
BASE = "https://phosra-api-sandbox-production.up.railway.app/api/v1"
res = requests.post(
f"{BASE}/webhooks",
headers={"Authorization": f"Bearer {os.environ['PHOSRA_API_KEY']}"},
json={
"family_id": "f0000000-0000-4000-8000-0000000000f1",
"url": "https://yourapp.com/webhooks/phosra",
"events": [
"enforcement.completed",
"policy.updated"
]
},
)
print(res.status_code, res.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
base := "https://phosra-api-sandbox-production.up.railway.app/api/v1"
body := bytes.NewBufferString(`{
"family_id": "f0000000-0000-4000-8000-0000000000f1",
"url": "https://yourapp.com/webhooks/phosra",
"events": [
"enforcement.completed",
"policy.updated"
]
}`)
req, _ := http.NewRequest("POST", base+"/webhooks", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("PHOSRA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.Status, string(out))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'family_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'url' => '<string>',
'events' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"family_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"family_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"url\": \"<string>\",\n \"events\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "d41c8f2a-90b7-4e63-a15c-8f0e2b7d3946",
"family_id": "fcdf4277-ba14-4732-8db5-0369b2c88d8b",
"url": "https://api.rivera-safety.com/webhooks/phosra",
"events": [
"policy.updated",
"enforcement.completed"
],
"active": true,
"created_at": "2026-06-18T14:32:07Z",
"updated_at": "2026-06-30T09:15:44Z"
}{
"error": "Bad Request",
"message": "child_name is required",
"code": 400
}{
"error": "Unauthorized",
"message": "missing or invalid Authorization header",
"code": 401
}{
"error": "Conflict",
"message": "resource already exists",
"code": 409
}{
"error": "Too Many Requests",
"message": "rate limit exceeded",
"code": 429
}{
"error": "Internal Server Error",
"message": "internal error",
"code": 500
}Webhooks deliver real-time events — enforcement completions, verification changes, policy updates —
to an HTTPS endpoint you control. Register one, send a test delivery, and inspect the delivery log.
Use Send a test delivery to fire a sample payload, then read
List deliveries to confirm receipt and debug retries.
curl -X POST https://phosra-api-sandbox-production.up.railway.app/api/v1/webhooks \
-H "Authorization: Bearer $PHOSRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/hooks/phosra","events":["enforcement.completed"]}'
Authorizations
Body
application/json
Response
Webhook created