Adding and Updating Data
Ingest single objects or small batches and update existing objects with stable IDs.
Use POST /v1/data/{namespace} to send single objects or small batches in arrays.
This endpoint is the fastest way to integrate ongoing production traffic where objects arrive continuously.
Using a stable id is important for:
- matching webhook outputs to your internal records
- re-processing when object data changes
- maintaining object history in one identity
Add data
Section titled “Add data”import Safetykit from "safetykit";
const client = new Safetykit({ apiKey: process.env.SAFETYKIT_API_KEY,});
const response = await client.data.ingest("products", { data: [ { id: "product_12345", title: "Ceramic Mug", description: "Handmade mug, 12oz", images: ["https://example.com/mug.jpg"], price: 24.0, }, ],});
console.log(response.requestId);from safetykit import Safetykit
client = Safetykit(api_key="sk_your_api_key")
response = client.data.ingest("products", { "data": [ { "id": "product_12345", "title": "Ceramic Mug", "description": "Handmade mug, 12oz", "images": ["https://example.com/mug.jpg"], "price": 24.0, } ]})
print(response.request_id)curl -X POST "https://api.safetykit.com/v1/data/products" \ -H "Authorization: Bearer sk_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "data": [ { "id": "product_12345", "title": "Ceramic Mug", "description": "Handmade mug, 12oz", "images": ["https://example.com/mug.jpg"], "price": 24.0 } ] }'Update data (upsert behavior)
Section titled “Update data (upsert behavior)”To update an object, send the same id again.
The service will treat it as a new evaluation for that entity identity, which keeps your latest state and decisions aligned.
{ "data": { "id": "product_12345", "title": "Ceramic Mug - Updated", "price": 28.0 }}Request shape
Section titled “Request shape”dataaccepts either a single object or an array- configure
schemaseparately viaPUT /v1/data/{namespace}/settings - each object in
datamust include anid
In most integrations, you should persist both id and requestId from each call so you can reconcile webhook events, monitor replay jobs, and debug edge cases quickly.
For large imports, see Adding Data in Batches.