Skip to content

Create a record

Save the request body as a record and return its URI.

Trigger: xrpc.procedure:<nsid>. Needs: happyview-record.

local record = require("happyview.record")
function handle(input, ctx)
return record.create("com.example.post", input)
end
  1. record.create writes the record to the caller’s PDS, in the collection the script names.
  2. The write is also put into HappyView’s index straight away, without waiting for the network to echo it.
  3. create returns { uri, cid }, which becomes the response.

Writing as the caller needs a PDS session, which a procedure has when its caller is signed in. Check ctx.has_pds_auth if you need to handle the case where it isn’t.

curl
curl -X POST http://127.0.0.1:3000/xrpc/xyz.statusphere.createRecord \  -H "X-Client-Key: $CLIENT_KEY" \  -H "Authorization: DPoP $ACCESS_TOKEN" \  -H "DPoP: $DPOP_PROOF" \  -H "Content-Type: application/json" \  -d '{ "text": "Hello world", "createdAt": "2025-01-01T00:00:00Z" }'