POST /api/data/:collectionName
Inserts a new document into the specified collection and returns the created document on success.
Required Header
x-api-key: sk_live_… by default. pk_live_… is accepted only when the collection has RLS enabled and the request includes a valid Authorization: Bearer <accessToken> header.
Path Parameters
The name of the collection to insert into (e.g.,
posts, orders).Request Body
Send a JSON object containing the document fields. The fields must conform to the collection’s schema if one is defined.When using
pk_live with RLS enabled, the owner field (e.g., userId) is automatically
injected from the authenticated user’s JWT if you omit it. If you include the owner field
but it doesn’t match the token’s user ID, the request is rejected with 403.Response Fields
true when the document was created.The newly created document, including its assigned
_id and any auto-injected fields.Human-readable status message.
Code Examples
Success Response
Errors
| Status | Cause |
|---|---|
400 Bad Request | Schema validation failed — missing required field or wrong type |
401 Unauthorized | Missing/invalid API key, or missing Bearer token when using pk_live with RLS |
403 Forbidden | pk_live without RLS enabled, or owner field in body doesn’t match the token’s user ID |
