Skip to main content
PUT, PATCH, and DELETE require a paramKey in the action config to identify which document to target. Omitting paramKey from these actions will cause them to fail.

POST — Create a document

Use POST to create a new document in a collection. The SDK auto-generates the Firestore document ID.
{
  collection: "users",
  endpoint: "/api/users",
  request: { type: "POST" },
}
Send all documentAttributes in the request body:
{ "name": "Jane Doe", "age": 28, "email": "jane@example.com" }
Success response:
{ "status": "success", "data": { "id": "newDocId" } }
The SDK validates the request body against the collection’s documentAttributes. It rejects requests with missing or extra fields: Missing field:
{ "status": "ERROR", "message": "Missed keys: email" }
Extra field:
{
  "status": "ERROR",
  "message": "Don't use these keys: role: they are not in the schema"
}

PUT — Replace a document

Use PUT to fully replace an existing document. You must provide all documentAttributes in the request body.
{
  collection: "users",
  endpoint: "/api/users/:id",
  request: { type: "PUT", paramKey: "id" },
}
Example request: PUT /api/users/abc123 with body { "name": "Jane Doe", "age": 29, "email": "jane@example.com" } Success response:
{ "status": "success", "message": "Document with id abc123 was updated" }

PATCH — Partial update

Use PATCH to update one or more fields on an existing document without replacing the entire document.
{
  collection: "users",
  endpoint: "/api/users/:id",
  request: { type: "PATCH", paramKey: "id" },
}
Send only the fields you want to change. At least one documentAttribute must be present in the body. Example request body:
{ "age": 29 }
Success response:
{ "status": "success", "message": "Document with id abc123 was updated" }
No valid field in body:
{ "status": "error", "message": "Your request body must have at least one key from documentAttributes: name, age, email" }
Extra field in body:
{ "status": "ERROR", "message": "Don't use these keys: role: they are not in the schema" }
PUT vs. PATCH: PUT performs a full replacement — it overwrites the entire document with the fields you provide, so all documentAttributes are required. PATCH performs a partial update using Firestore’s .update() method, so you only need to include the fields you want to change.

DELETE — Remove a document

Use DELETE to permanently remove a document from a collection.
{
  collection: "users",
  endpoint: "/api/users/:id",
  request: { type: "DELETE", paramKey: "id" },
}
Example request: DELETE /api/users/abc123 Success response:
{ "status": "success", "message": "Document with id abc123 was deleted" }