Create Record
The simplest write: take the request body, save it as a record, and return the URI.
Lexicon type: procedure
function handle() local r = Record(collection, input) r:save() return { uri = r._uri, cid = r._cid }endHow it works
Section titled “How it works”- Create a new
Recordinstance from the target collection, populated with the fields from the request body. - Call
r:save(), which creates the record on the caller’s PDS and indexes it locally. - Return the AT URI and CID of the newly created record.
const response = await fetch("http://127.0.0.1:3000/xrpc/xyz.statusphere.createRecord", { method: "POST", headers: { "X-Client-Key": CLIENT_KEY, Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({ text: "Hello world", createdAt: "2025-01-01T00:00:00Z", }),});const data = await response.json();const response = await fetch("http://127.0.0.1:3000/xrpc/xyz.statusphere.createRecord", { method: "POST", headers: { "X-Client-Key": CLIENT_KEY, Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({ text: "Hello world", createdAt: "2025-01-01T00:00:00Z", }),});const data = await response.json();let response = client .post("http://127.0.0.1:3000/xrpc/xyz.statusphere.createRecord") .header("X-Client-Key", client_key) .header("Authorization", format!("Bearer {}", token)) .json(&serde_json::json!({ "text": "Hello world", "createdAt": "2025-01-01T00:00:00Z" })) .send() .await?;body := `{ "text": "Hello world", "createdAt": "2025-01-01T00:00:00Z" }`req, _ := http.NewRequest("POST", "http://127.0.0.1:3000/xrpc/xyz.statusphere.createRecord", bytes.NewBufferString(body))req.Header.Set("X-Client-Key", clientKey)req.Header.Set("Authorization", "Bearer "+token)req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)curl -X POST http://127.0.0.1:3000/xrpc/xyz.statusphere.createRecord \ -H "X-Client-Key: $CLIENT_KEY" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "text": "Hello world", "createdAt": "2025-01-01T00:00:00Z" }'Use case
Section titled “Use case”This is the simplest possible write procedure. It works well when the client is responsible for populating all record fields and no server-side validation or transformation is needed.

