Backfill the aggregate registry from R2
Scans the R2 event store and upserts a registry row for every aggregate found (optionally limited to one type). Idempotent. Requires dual admin auth (X-Admin-API-Key + JWT with an allowed email domain).
curl -X POST "https://api.spkey.co/admin/aggregates/backfill?type=example_string" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Authorization: Bearer YOUR_API_TOKEN"
import requests
import json
url = "https://api.spkey.co/admin/aggregates/backfill?type=example_string"
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY",
"Authorization": "Bearer YOUR_API_TOKEN"
}
response = requests.post(url, headers=headers)
print(response.json())
const response = await fetch("https://api.spkey.co/admin/aggregates/backfill?type=example_string", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY",
"Authorization": "Bearer YOUR_API_TOKEN"
}
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
)
func main() {
req, err := http.NewRequest("POST", "https://api.spkey.co/admin/aggregates/backfill?type=example_string", nil)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.spkey.co/admin/aggregates/backfill?type=example_string')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['X-API-Key'] = 'YOUR_API_KEY'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
response = http.request(request)
puts response.body
{
"success": true,
"scannedTypes": [
"example_string"
],
"upserted": 3.14,
"byType": {},
"truncated": true,
"durationMs": 3.14
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Forbidden",
"message": "You don't have permission to access this resource",
"code": 403
}
POST
/admin/aggregates/backfill
POST
Base URLstring
Target server for requests. Edit to use your own host.
⚠️Authentication configuration error - security schemes not found
query
typestring
Limit the scan to one aggregate type or slug.
Request Preview
Response
Response will appear here after sending the request
Query Parameters
typestring
Limit the scan to one aggregate type or slug.
Responses
successboolean
RequiredscannedTypesstring[]
Requiredupsertednumber
RequiredbyTypeobject
Requiredtruncatedboolean
RequireddurationMsnumber
RequiredWas this page helpful?