Create document
Endpoint
posthttps://<REGION>.cloud.appwrite.io...ollections/{collectionId}/documents
Description
Create a new Document. Before using this route, you should create a new collection resource using either a server integration API or directly from your database console.
Required scopes
Authentication
setProject() and ensure the user is signed in. The SDK sends the session header automatically after login.Rate limit
Path
Database ID.
Collection ID. You can create a new collection using the Database service server integration. Make sure to define attributes before creating documents.
Body
Document ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
Document data as JSON object.
An array of permissions strings. By default, only the current user is granted all permissions. Learn more about permissions.
Document
Document ID.
Collection ID.
Database ID.
Document creation date in ISO 8601 format.
Document update date in ISO 8601 format.
Document permissions. Learn more about permissions.
import { Client, Databases } from "appwrite";
const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const databases = new Databases(client);
const result = await databases.createDocument( '<DATABASE_ID>', // databaseId '<COLLECTION_ID>', // collectionId '<DOCUMENT_ID>', // documentId {}, // data ["read("any")"] // permissions (optional));
console.log(result);Databases
Create document
Endpoint
posthttps://<REGION>.cloud.appwrite.io...ollections/{collectionId}/documents
Description
Create a new Document. Before using this route, you should create a new collection resource using either a server integration API or directly from your database console.
Required scopes
Authentication
setProject() and ensure the user is signed in. The SDK sends the session header automatically after login.Rate limit
Path
Database ID.
Collection ID. You can create a new collection using the Database service server integration. Make sure to define attributes before creating documents.
Body
Document ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
Document data as JSON object.
An array of permissions strings. By default, only the current user is granted all permissions. Learn more about permissions.
Document
Document ID.
Collection ID.
Database ID.
Document creation date in ISO 8601 format.
Document update date in ISO 8601 format.
Document permissions. Learn more about permissions.
import { Client, Databases } from "appwrite";
const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const databases = new Databases(client);
const result = await databases.createDocument( '<DATABASE_ID>', // databaseId '<COLLECTION_ID>', // collectionId '<DOCUMENT_ID>', // documentId {}, // data ["read("any")"] // permissions (optional));
console.log(result);