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.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 your own unique ID or pass the string "unique()" to auto generate it. 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 strings with read permissions. By default only the current user is granted with read permissions. learn more about permissions and get a full list of available permissions.
An array of strings with write permissions. By default only the current user is granted with write permissions. learn more about permissions and get a full list of available permissions.
Document
Document ID.
Collection ID.
Document creation date in Unix timestamp.
Document update date in Unix timestamp.
Document read permissions.
Document write permissions.
import { Client, Databases } from "appwrite";
const client = new Client();
const databases = new Databases(client, '[DATABASE_ID]');
client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID;
const promise = databases.createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {});
promise.then(function (response) { console.log(response); // Success}, function (error) { console.log(error); // Failure});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.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 your own unique ID or pass the string "unique()" to auto generate it. 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 strings with read permissions. By default only the current user is granted with read permissions. learn more about permissions and get a full list of available permissions.
An array of strings with write permissions. By default only the current user is granted with write permissions. learn more about permissions and get a full list of available permissions.
Document
Document ID.
Collection ID.
Document creation date in Unix timestamp.
Document update date in Unix timestamp.
Document read permissions.
Document write permissions.
import { Client, Databases } from "appwrite";
const client = new Client();
const databases = new Databases(client, '[DATABASE_ID]');
client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID;
const promise = databases.createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {});
promise.then(function (response) { console.log(response); // Success}, function (error) { console.log(error); // Failure});