The Databases service allows you to create structured collections of documents, query and filter lists of documents, and manage an advanced set of read and write access permissions.
All data returned by the Databases service are represented as structured JSON documents.
The Databases service can contain multiple databases, each database can contain multiple collections. A collection is a group of similarly structured documents. The accepted structure of documents is defined by collection attributes. The collection attributes help you ensure all your user-submitted data is validated and stored according to the collection structure.
Using Appwrite permissions architecture, you can assign read or write access to each collection or document in your project for either a specific user, team, user role, or even grant it with public access (any
). You can learn more about how Appwrite handles permissions and access control.
https://cloud.appwrite.io/v1
List databases
Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.
Request
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /databases
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.list(
[], // queries (optional)
'<SEARCH>' // search (optional)
);
Create database
Create a new Database.
Request
databaseId requiredUnique 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.name requiredDatabase name. Max length: 128 chars.
enabled Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
Response
201
POST /databases
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.create(
'<DATABASE_ID>', // databaseId
'<NAME>', // name
false // enabled (optional)
);
Get database
Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata.
Request
databaseId requiredDatabase ID.
Response
200
GET /databases/{databaseId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.get(
'<DATABASE_ID>' // databaseId
);
Update database
Update a database by its unique ID.
Request
databaseId requiredDatabase ID.
name requiredDatabase name. Max length: 128 chars.
enabled Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
Response
200
PUT /databases/{databaseId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.update(
'<DATABASE_ID>', // databaseId
'<NAME>', // name
false // enabled (optional)
);
Delete database
Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database.
Request
databaseId requiredDatabase ID.
Response
204
DELETE /databases/{databaseId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.delete(
'<DATABASE_ID>' // databaseId
);
List collections
Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results.
Request
databaseId requiredDatabase ID.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /databases/{databaseId}/collections
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.listCollections(
'<DATABASE_ID>', // databaseId
[], // queries (optional)
'<SEARCH>' // search (optional)
);
Create collection
Create a new Collection. Before using this route, you should create a new database resource using either a server integration API or directly from your database console.
Request
databaseId requiredDatabase ID.
collectionId requiredUnique 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.name requiredCollection name. Max length: 128 chars.
permissions An array of permissions strings. By default, no user is granted with any permissions. Learn more about permissions.
documentSecurity Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. Learn more about permissions.
enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.
Response
201
POST /databases/{databaseId}/collections
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createCollection(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<NAME>', // name
["read("any")"], // permissions (optional)
false, // documentSecurity (optional)
false // enabled (optional)
);
Get collection
Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
Response
200
GET /databases/{databaseId}/collections/{collectionId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.getCollection(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>' // collectionId
);
Update collection
Update a collection by its unique ID.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
name requiredCollection name. Max length: 128 chars.
permissions An array of permission strings. By default, the current permissions are inherited. Learn more about permissions.
documentSecurity Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. Learn more about permissions.
enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.
Response
200
PUT /databases/{databaseId}/collections/{collectionId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateCollection(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<NAME>', // name
["read("any")"], // permissions (optional)
false, // documentSecurity (optional)
false // enabled (optional)
);
Delete collection
Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.deleteCollection(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>' // collectionId
);
List attributes
List attributes in the collection.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error
Response
200
GET /databases/{databaseId}/collections/{collectionId}/attributes
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.listAttributes(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
[] // queries (optional)
);
Create boolean attribute
Create a boolean attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/boolean
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createBooleanAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
false, // default (optional)
false // array (optional)
);
Update boolean attribute
Update a boolean attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateBooleanAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
false, // default
'' // newKey (optional)
);
Create datetime attribute
Create a date time attribute according to the ISO 8601 standard.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for the attribute in ISO 8601 format. Cannot be set when attribute is required.
array Is attribute an array?
Response
POST /databases/{databaseId}/collections/{collectionId}/attributes/datetime
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createDatetimeAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'', // default (optional)
false // array (optional)
);
Update dateTime attribute
Update a date time attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateDatetimeAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'', // default
'' // newKey (optional)
);
Create email attribute
Create an email attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/email
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createEmailAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'email@example.com', // default (optional)
false // array (optional)
);
Update email attribute
Update an email attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/email/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateEmailAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'email@example.com', // default
'' // newKey (optional)
);
Create enum attribute
Create an enumeration attribute. The elements
param acts as a white-list of accepted values for this attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
elements requiredArray of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/enum
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createEnumAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
[], // elements
false, // required
'<DEFAULT>', // default (optional)
false // array (optional)
);
Update enum attribute
Update an enum attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
elements requiredArray of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateEnumAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
[], // elements
false, // required
'<DEFAULT>', // default
'' // newKey (optional)
);
Create float attribute
Create a float attribute. Optionally, minimum and maximum values can be provided.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
min Minimum value to enforce on new documents
max Maximum value to enforce on new documents
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/float
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createFloatAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
null, // min (optional)
null, // max (optional)
null, // default (optional)
false // array (optional)
);
Update float attribute
Update a float attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
min requiredMinimum value to enforce on new documents
max requiredMaximum value to enforce on new documents
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/float/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateFloatAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
null, // min
null, // max
null, // default
'' // newKey (optional)
);
Create integer attribute
Create an integer attribute. Optionally, minimum and maximum values can be provided.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
min Minimum value to enforce on new documents
max Maximum value to enforce on new documents
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/integer
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createIntegerAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
null, // min (optional)
null, // max (optional)
null, // default (optional)
false // array (optional)
);
Update integer attribute
Update an integer attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
min requiredMinimum value to enforce on new documents
max requiredMaximum value to enforce on new documents
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateIntegerAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
null, // min
null, // max
null, // default
'' // newKey (optional)
);
Create IP address attribute
Create IP address attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/ip
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createIpAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'', // default (optional)
false // array (optional)
);
Update IP address attribute
Update an ip attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateIpAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'', // default
'' // newKey (optional)
);
Create relationship attribute
Create relationship attribute. Learn more about relationship attributes.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
relatedCollectionId requiredRelated Collection ID. You can create a new collection using the Database service server integration.
type requiredRelation type
twoWay Is Two Way?
key Attribute Key.
twoWayKey Two Way Attribute Key.
onDelete Constraints option
Response
POST /databases/{databaseId}/collections/{collectionId}/attributes/relationship
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createRelationshipAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<RELATED_COLLECTION_ID>', // relatedCollectionId
sdk.RelationshipType.OneToOne, // type
false, // twoWay (optional)
'', // key (optional)
'', // twoWayKey (optional)
sdk.RelationMutate.Cascade // onDelete (optional)
);
Create string attribute
Create a string attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
size requiredAttribute size for text attributes, in number of characters.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
encrypt Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried.
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/string
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createStringAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
1, // size
false, // required
'<DEFAULT>', // default (optional)
false, // array (optional)
false // encrypt (optional)
);
Update string attribute
Update a string attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
size Maximum size of the string attribute.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/string/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateStringAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'<DEFAULT>', // default
null, // size (optional)
'' // newKey (optional)
);
Create URL attribute
Create a URL attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default Default value for attribute when not provided. Cannot be set when attribute is required.
array Is attribute an array?
Response
202
POST /databases/{databaseId}/collections/{collectionId}/attributes/url
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createUrlAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'https://example.com', // default (optional)
false // array (optional)
);
Update URL attribute
Update an url attribute. Changing the default
value will not update already existing documents.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
required requiredIs attribute required?
default requiredDefault value for attribute when not provided. Cannot be set when attribute is required.
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/url/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateUrlAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'https://example.com', // default
'' // newKey (optional)
);
Get attribute
Get attribute by ID.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
GET /databases/{databaseId}/collections/{collectionId}/attributes/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.getAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'' // key
);
Delete attribute
Deletes an attribute.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}/attributes/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.deleteAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'' // key
);
Update relationship attribute
Update relationship attribute. Learn more about relationship attributes.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredAttribute Key.
onDelete Constraints option
newKey New attribute key.
Response
200
PATCH /databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.updateRelationshipAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
sdk.RelationMutate.Cascade, // onDelete (optional)
'' // newKey (optional)
);
List documents
Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/documents
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const databases = new sdk.Databases(client);
const result = await databases.listDocuments(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
[] // queries (optional)
);
Create document
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.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration. Make sure to define attributes before creating documents.
documentId requiredDocument 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.data requiredDocument data as JSON object.
permissions An array of permissions strings. By default, only the current user is granted all permissions. Learn more about permissions.
Response
201
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 120 requests IP + METHOD + URL + USER ID
POST /databases/{databaseId}/collections/{collectionId}/documents
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const databases = new sdk.Databases(client);
const result = await databases.createDocument(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>', // documentId
{}, // data
["read("any")"] // permissions (optional)
);
Get document
Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
documentId requiredDocument ID.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const databases = new sdk.Databases(client);
const result = await databases.getDocument(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>', // documentId
[] // queries (optional)
);
Update document
Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID.
documentId requiredDocument ID.
data Document data as JSON object. Include only attribute and value pairs to be updated.
permissions An array of permissions strings. By default, the current permissions are inherited. Learn more about permissions.
Response
200
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 120 requests IP + METHOD + URL + USER ID
PATCH /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const databases = new sdk.Databases(client);
const result = await databases.updateDocument(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>', // documentId
{}, // data (optional)
["read("any")"] // permissions (optional)
);
Delete document
Delete a document by its unique ID.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
documentId requiredDocument ID.
Response
204
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 60 requests IP + METHOD + URL + USER ID
DELETE /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const databases = new sdk.Databases(client);
const result = await databases.deleteDocument(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'<DOCUMENT_ID>' // documentId
);
List indexes
List indexes in the collection.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error
Response
200
GET /databases/{databaseId}/collections/{collectionId}/indexes
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.listIndexes(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
[] // queries (optional)
);
Create index
Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request.
Attributes can be key
, fulltext
, and unique
.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredIndex Key.
type requiredIndex type.
attributes requiredArray of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
orders Array of index orders. Maximum of 100 orders are allowed.
Response
202
POST /databases/{databaseId}/collections/{collectionId}/indexes
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.createIndex(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
sdk.IndexType.Key, // type
[], // attributes
[] // orders (optional)
);
Get index
Get index by ID.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredIndex Key.
Response
200
GET /databases/{databaseId}/collections/{collectionId}/indexes/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.getIndex(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'' // key
);
Delete index
Delete an index.
Request
databaseId requiredDatabase ID.
collectionId requiredCollection ID. You can create a new collection using the Database service server integration.
key requiredIndex Key.
Response
204
DELETE /databases/{databaseId}/collections/{collectionId}/indexes/{key}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const databases = new sdk.Databases(client);
const result = await databases.deleteIndex(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'' // key
);