AdminTrigger projection resync for all aggregates via Workflow

Trigger projection resync for all aggregates via Workflow

Lists all aggregate IDs from R2 and starts a Cloudflare Workflow that processes DOs in small batches with configurable delays to avoid overwhelming SpacetimeDB. Returns the workflow instance ID for status tracking. Optionally filter by aggregate type. Requires dual auth: X-Admin-API-Key + JWT.

curl -X POST "https://api.spkey.co/admin/resync-projections?aggregateType=user&aggregateId=example_string&batchSize=example_string&delaySeconds=example_string" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN (JWT)" \
  -H "X-API-Key: YOUR_API_KEY"
{
  "success": true,
  "instanceId": "example_string",
  "aggregateTypes": [
    "example_string"
  ],
  "total": 3.14,
  "batchSize": 3.14,
  "delaySeconds": 3.14,
  "batches": 3.14,
  "counts": {
    "user": 3.14,
    "lock": 3.14,
    "hub": 3.14,
    "matter-device": 3.14,
    "camera": 3.14,
    "camera-role": 3.14,
    "rtsp-camera": 3.14
  },
  "errors": [
    "example_string"
  ]
}
POST
/admin/resync-projections
POST
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token (JWT)
Bearer Tokenstring
Required

JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.

JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.
API Key (header: X-API-Key)
X-API-Keystring
Required

API key for B2B organization access. Provided during organization onboarding.

API key for B2B organization access. Provided during organization onboarding.
query
aggregateTypestring

Limit resync to a single aggregate type. Omit to resync all supported types.

Options: user, lock, hub, matter-device, camera, camera-role, rtsp-camera
query
aggregateIdstring

Optional single aggregate ID to resync. Requires aggregateType. When set, the R2 list step is skipped — the workflow enqueues just this one DO.

query
batchSizestring

Number of DOs to poke per batch (default: 20)

query
delaySecondsstring

Seconds to wait between batches (default: 3)

Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token (JWT). JWT token from SmartphoneKey authentication. Identifies the B2C user or B2B service.

header
X-API-Keystring
Required

API Key for authentication. API key for B2B organization access. Provided during organization onboarding.

Query Parameters

aggregateTypestring

Limit resync to a single aggregate type. Omit to resync all supported types.

Allowed values:userlockhubmatter-devicecameracamera-rolertsp-camera
aggregateIdstring

Optional single aggregate ID to resync. Requires aggregateType. When set, the R2 list step is skipped — the workflow enqueues just this one DO.

batchSizestring

Number of DOs to poke per batch (default: 20)

delaySecondsstring

Seconds to wait between batches (default: 3)

Responses

successboolean
Required
instanceIdstring
Required
aggregateTypesstring[]
Required
totalnumber
Required
batchSizenumber
Required
delaySecondsnumber
Required
batchesnumber
Required
countsobject
Required
errorsstring[]
Required