Skip to main content

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

string
required
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

The endpoint returns the created document object directly.
string
The assigned unique MongoDB ObjectId string.
boolean
Always false for new documents.
string
Always null for new documents.
string
ISO date string of when the document was created.
string
ISO date string of when the document was last updated.
Other fields returned depend on your collection schema and the data sent.

Code examples

Success response

Errors