We're having lots of fun on Discord! Come and join us! 💬
Docs

Database API


Server integration with  

The Database 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 the data in the database service is stored in structured JSON documents. The Appwrite database service also allows you to nest child documents in parent documents and use deep filters to both search and query your data.

Each database document structure in your project is defined using the Appwrite 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 (role:all). You can learn more about how Appwrite handles permissions and access control.

Create Collection

POST/v1/database/collections

Create a new Collection.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Unique 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.

name required string

Collection name. Max length: 128 chars.

permission required string

Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the read and write params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. learn more about permissions and get a full list of available permissions.

read required array

An array of strings with read permissions. By default no user is granted with any read permissions. learn more about permissions and get a full list of available permissions.

write required array

An array of strings with write permissions. By default no user is granted with any write permissions. learn more about permissions and get a full list of available permissions.

HTTP Response

Status Code Content Type Payload
201  Created application/json Collection Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createCollection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"]);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createCollection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"]);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createCollection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"]);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_collection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"])
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]', permission: 'document', read: ["role:all"], write: ["role:all"])
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createCollection(
        collectionId: '[COLLECTION_ID]',
        name: '[NAME]',
        permission: 'document',
        read: ["role:all"],
        write: ["role:all"],
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createCollection \
            --collectionId="[COLLECTION_ID]" \
            --name="[NAME]" \
            --permission="document" \
            --read="[&quot;role:all&quot;]" \
            --write="[&quot;role:all&quot;]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createCollection(
            collectionId = "[COLLECTION_ID]",
            name = "[NAME]",
            permission = "document",
            read = ["role:all"],
            write = ["role:all"]
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createCollection(
            collectionId = "[COLLECTION_ID]",
            name = "[NAME]",
            permission = "document",
            read = ["role:all"],
            write = ["role:all"]
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createCollection(
            collectionId: "[COLLECTION_ID]",
            name: "[NAME]",
            permission: "document",
            read: ["role:all"],
            write: ["role:all"]
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let collection):
                print(String(describing: collection)
            }
        }
    }
    

List Collections

GET/v1/database/collections

Get a list of all the user collections. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's collections. Learn more about different API modes.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.read" permission scope.

HTTP Request

Name Type Description
search optional string

Search term to filter your list results. Max length: 256 chars.

limit optional integer

Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.

offset optional integer

Offset value. The default value is 0. Use this param to manage pagination. learn more about pagination

cursor optional string

ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data.

cursorDirection optional string

Direction of the cursor.

orderType optional string

Order result by ASC or DESC order.

HTTP Response

Status Code Content Type Payload
200  OK application/json Collections List Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.listCollections();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.listCollections();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->listCollections();
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.list_collections()
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.list_collections()
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.listCollections(
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database listCollections \
            --search="[SEARCH]" \
            --limit="0" \
            --offset="0" \
            --cursor="[CURSOR]" \
            --cursorDirection="after" \
            --orderType="ASC"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.listCollections(
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.listCollections(
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.listCollections() { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let collectionList):
                print(String(describing: collectionList)
            }
        }
    }
    

Get Collection

GET/v1/database/collections/{collectionId}

Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.read" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID.

HTTP Response

Status Code Content Type Payload
200  OK application/json Collection Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.getCollection('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.getCollection('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->getCollection('[COLLECTION_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.get_collection('[COLLECTION_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.get_collection(collection_id: '[COLLECTION_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.getCollection(
        collectionId: '[COLLECTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database getCollection \
            --collectionId="[COLLECTION_ID]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.getCollection(
            collectionId = "[COLLECTION_ID]"
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.getCollection(
            collectionId = "[COLLECTION_ID]"
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.getCollection(
            collectionId: "[COLLECTION_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let collection):
                print(String(describing: collection)
            }
        }
    }
    

Update Collection

PUT/v1/database/collections/{collectionId}

Update a collection by its unique ID.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID.

name required string

Collection name. Max length: 128 chars.

permission required string

Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the read and write params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. learn more about permissions and get a full list of available permissions.

read optional array

An array of strings with read permissions. By default inherits the existing read permissions. learn more about permissions and get a full list of available permissions.

write optional array

An array of strings with write permissions. By default inherits the existing write permissions. learn more about permissions and get a full list of available permissions.

enabled optional boolean

Is collection enabled?

HTTP Response

Status Code Content Type Payload
200  OK application/json Collection Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.updateCollection('[COLLECTION_ID]', '[NAME]', 'document');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.updateCollection('[COLLECTION_ID]', '[NAME]', 'document');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->updateCollection('[COLLECTION_ID]', '[NAME]', 'document');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.update_collection('[COLLECTION_ID]', '[NAME]', 'document')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.update_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]', permission: 'document')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.updateCollection(
        collectionId: '[COLLECTION_ID]',
        name: '[NAME]',
        permission: 'document',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database updateCollection \
            --collectionId="[COLLECTION_ID]" \
            --name="[NAME]" \
            --permission="document" \
            --read="[&quot;role:all&quot;]" \
            --write="[&quot;role:all&quot;]" \
            --enabled=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.updateCollection(
            collectionId = "[COLLECTION_ID]",
            name = "[NAME]",
            permission = "document",
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.updateCollection(
            collectionId = "[COLLECTION_ID]",
            name = "[NAME]",
            permission = "document",
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.updateCollection(
            collectionId: "[COLLECTION_ID]",
            name: "[NAME]",
            permission: "document"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let collection):
                print(String(describing: collection)
            }
        }
    }
    

Delete Collection

DELETE/v1/database/collections/{collectionId}

Delete a collection by its unique ID. Only users with write permissions have access to delete this resource.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID.

HTTP Response

Status Code Content Type Payload
204  No Content - -
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.deleteCollection('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.deleteCollection('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->deleteCollection('[COLLECTION_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.delete_collection('[COLLECTION_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.delete_collection(collection_id: '[COLLECTION_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.deleteCollection(
        collectionId: '[COLLECTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database deleteCollection \
            --collectionId="[COLLECTION_ID]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.deleteCollection(
            collectionId = "[COLLECTION_ID]"
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.deleteCollection(
            collectionId = "[COLLECTION_ID]"
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.deleteCollection(
            collectionId: "[COLLECTION_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let ):
                print(String(describing: )
            }
        }
    }
    

Create String Attribute

POST/v1/database/collections/{collectionId}/attributes/string

Create a string attribute.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

size required integer

Attribute size for text attributes, in number of characters.

required required boolean

Is attribute required?

default optional string

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeString Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createStringAttribute('[COLLECTION_ID]', '', 1, false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createStringAttribute('[COLLECTION_ID]', '', 1, false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createStringAttribute('[COLLECTION_ID]', '', 1, false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_string_attribute('[COLLECTION_ID]', '', 1, False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_string_attribute(collection_id: '[COLLECTION_ID]', key: '', size: 1, required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createStringAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        size: 1,
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createStringAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --size="1" \
            --required="" \
            --default="[DEFAULT]" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createStringAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            size = 1,
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createStringAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            size = 1,
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createStringAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            size: 1,
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeString):
                print(String(describing: attributeString)
            }
        }
    }
    

Create Email Attribute

POST/v1/database/collections/{collectionId}/attributes/email

Create an email attribute.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

required required boolean

Is attribute required?

default optional string

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeEmail Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createEmailAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createEmailAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createEmailAttribute('[COLLECTION_ID]', '', false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_email_attribute('[COLLECTION_ID]', '', False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_email_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createEmailAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createEmailAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --required="" \
            --default="email@example.com" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createEmailAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createEmailAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createEmailAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeEmail):
                print(String(describing: attributeEmail)
            }
        }
    }
    

Create Enum Attribute

POST/v1/database/collections/{collectionId}/attributes/enum

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

elements required array

Array of elements in enumerated type. Uses length of longest element to determine size.

required required boolean

Is attribute required?

default optional string

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeEnum Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createEnumAttribute('[COLLECTION_ID]', '', [], false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createEnumAttribute('[COLLECTION_ID]', '', [], false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createEnumAttribute('[COLLECTION_ID]', '', [], false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_enum_attribute('[COLLECTION_ID]', '', [], False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_enum_attribute(collection_id: '[COLLECTION_ID]', key: '', elements: [], required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createEnumAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        elements: [],
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createEnumAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --elements="" \
            --required="" \
            --default="[DEFAULT]" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createEnumAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            elements = listOf(),
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createEnumAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            elements = listOf(),
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createEnumAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            elements: [],
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeEnum):
                print(String(describing: attributeEnum)
            }
        }
    }
    

Create IP Address Attribute

POST/v1/database/collections/{collectionId}/attributes/ip

Create IP address attribute.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

required required boolean

Is attribute required?

default optional string

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeIP Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createIpAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createIpAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createIpAttribute('[COLLECTION_ID]', '', false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_ip_attribute('[COLLECTION_ID]', '', False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_ip_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createIpAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createIpAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --required="" \
            --default="" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createIpAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createIpAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createIpAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeIp):
                print(String(describing: attributeIp)
            }
        }
    }
    

Create URL Attribute

POST/v1/database/collections/{collectionId}/attributes/url

Create a URL attribute.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

required required boolean

Is attribute required?

default optional string

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeURL Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createUrlAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createUrlAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createUrlAttribute('[COLLECTION_ID]', '', false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_url_attribute('[COLLECTION_ID]', '', False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_url_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createUrlAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createUrlAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --required="" \
            --default="https://example.com" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createUrlAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createUrlAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createUrlAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeUrl):
                print(String(describing: attributeUrl)
            }
        }
    }
    

Create Integer Attribute

POST/v1/database/collections/{collectionId}/attributes/integer

Create an integer attribute. Optionally, minimum and maximum values can be provided.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

required required boolean

Is attribute required?

min optional integer

Minimum value to enforce on new documents

max optional integer

Maximum value to enforce on new documents

default optional integer

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeInteger Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createIntegerAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createIntegerAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createIntegerAttribute('[COLLECTION_ID]', '', false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_integer_attribute('[COLLECTION_ID]', '', False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_integer_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createIntegerAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createIntegerAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --required="" \
            --min="" \
            --max="" \
            --default="" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createIntegerAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createIntegerAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createIntegerAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeInteger):
                print(String(describing: attributeInteger)
            }
        }
    }
    

Create Float Attribute

POST/v1/database/collections/{collectionId}/attributes/float

Create a float attribute. Optionally, minimum and maximum values can be provided.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

required required boolean

Is attribute required?

min optional string

Minimum value to enforce on new documents

max optional string

Maximum value to enforce on new documents

default optional string

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeFloat Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createFloatAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createFloatAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createFloatAttribute('[COLLECTION_ID]', '', false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_float_attribute('[COLLECTION_ID]', '', False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_float_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createFloatAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createFloatAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --required="" \
            --min="" \
            --max="" \
            --default="" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createFloatAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createFloatAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createFloatAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeFloat):
                print(String(describing: attributeFloat)
            }
        }
    }
    

Create Boolean Attribute

POST/v1/database/collections/{collectionId}/attributes/boolean

Create a boolean attribute.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

required required boolean

Is attribute required?

default optional boolean

Default value for attribute when not provided. Cannot be set when attribute is required.

array optional boolean

Is attribute an array?

HTTP Response

Status Code Content Type Payload
201  Created application/json AttributeBoolean Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createBooleanAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createBooleanAttribute('[COLLECTION_ID]', '', false);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createBooleanAttribute('[COLLECTION_ID]', '', false);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_boolean_attribute('[COLLECTION_ID]', '', False)
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_boolean_attribute(collection_id: '[COLLECTION_ID]', key: '', required: false)
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createBooleanAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
        required: false,
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createBooleanAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --required="" \
            --default="" \
            --array=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createBooleanAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createBooleanAttribute(
            collectionId = "[COLLECTION_ID]",
            key = "",
            required = false,
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createBooleanAttribute(
            collectionId: "[COLLECTION_ID]",
            key: "",
            required: xfalse
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeBoolean):
                print(String(describing: attributeBoolean)
            }
        }
    }
    

List Attributes

GET/v1/database/collections/{collectionId}/attributes

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.read" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

HTTP Response

Status Code Content Type Payload
200  OK application/json Attributes List Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.listAttributes('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.listAttributes('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->listAttributes('[COLLECTION_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.list_attributes('[COLLECTION_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.list_attributes(collection_id: '[COLLECTION_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.listAttributes(
        collectionId: '[COLLECTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database listAttributes \
            --collectionId="[COLLECTION_ID]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.listAttributes(
            collectionId = "[COLLECTION_ID]"
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.listAttributes(
            collectionId = "[COLLECTION_ID]"
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.listAttributes(
            collectionId: "[COLLECTION_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let attributeList):
                print(String(describing: attributeList)
            }
        }
    }
    

Get Attribute

GET/v1/database/collections/{collectionId}/attributes/{key}

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.read" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

HTTP Response

Status Code Content Type Payload
200  OK application/json attributeBoolean
attributeInteger
attributeFloat
attributeEmail
attributeEnum
attributeUrl
attributeIp
attributeString
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.getAttribute('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.getAttribute('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->getAttribute('[COLLECTION_ID]', '');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.get_attribute('[COLLECTION_ID]', '')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.get_attribute(collection_id: '[COLLECTION_ID]', key: '')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.getAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database getAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.getAttribute(
            collectionId = "[COLLECTION_ID]",
            key = ""
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.getAttribute(
            collectionId = "[COLLECTION_ID]",
            key = ""
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.getAttribute(
            collectionId: "[COLLECTION_ID]",
            key: ""
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let ):
                print(String(describing: )
            }
        }
    }
    

Delete Attribute

DELETE/v1/database/collections/{collectionId}/attributes/{key}

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Attribute Key.

HTTP Response

Status Code Content Type Payload
204  No Content - -
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.deleteAttribute('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.deleteAttribute('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->deleteAttribute('[COLLECTION_ID]', '');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.delete_attribute('[COLLECTION_ID]', '')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.delete_attribute(collection_id: '[COLLECTION_ID]', key: '')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.deleteAttribute(
        collectionId: '[COLLECTION_ID]',
        key: '',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database deleteAttribute \
            --collectionId="[COLLECTION_ID]" \
            --key=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.deleteAttribute(
            collectionId = "[COLLECTION_ID]",
            key = ""
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.deleteAttribute(
            collectionId = "[COLLECTION_ID]",
            key = ""
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.deleteAttribute(
            collectionId: "[COLLECTION_ID]",
            key: ""
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let ):
                print(String(describing: )
            }
        }
    }
    

Create Index

POST/v1/database/collections/{collectionId}/indexes

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Index Key.

type required string

Index type.

attributes required array

Array of attributes to index.

orders optional array

Array of index orders.

HTTP Response

Status Code Content Type Payload
201  Created application/json Index Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createIndex('[COLLECTION_ID]', '', 'key', []);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createIndex('[COLLECTION_ID]', '', 'key', []);
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createIndex('[COLLECTION_ID]', '', 'key', []);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_index('[COLLECTION_ID]', '', 'key', [])
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_index(collection_id: '[COLLECTION_ID]', key: '', type: 'key', attributes: [])
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createIndex(
        collectionId: '[COLLECTION_ID]',
        key: '',
        type: 'key',
        attributes: [],
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createIndex \
            --collectionId="[COLLECTION_ID]" \
            --key="" \
            --type="key" \
            --attributes="" \
            --orders=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createIndex(
            collectionId = "[COLLECTION_ID]",
            key = "",
            type = "key",
            attributes = listOf(),
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createIndex(
            collectionId = "[COLLECTION_ID]",
            key = "",
            type = "key",
            attributes = listOf(),
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createIndex(
            collectionId: "[COLLECTION_ID]",
            key: "",
            type: "key",
            attributes: []
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let index):
                print(String(describing: index)
            }
        }
    }
    

List Indexes

GET/v1/database/collections/{collectionId}/indexes

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.read" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

HTTP Response

Status Code Content Type Payload
200  OK application/json Indexes List Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.listIndexes('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.listIndexes('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->listIndexes('[COLLECTION_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.list_indexes('[COLLECTION_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.list_indexes(collection_id: '[COLLECTION_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.listIndexes(
        collectionId: '[COLLECTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database listIndexes \
            --collectionId="[COLLECTION_ID]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.listIndexes(
            collectionId = "[COLLECTION_ID]"
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.listIndexes(
            collectionId = "[COLLECTION_ID]"
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.listIndexes(
            collectionId: "[COLLECTION_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let indexList):
                print(String(describing: indexList)
            }
        }
    }
    

Get Index

GET/v1/database/collections/{collectionId}/indexes/{key}

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.read" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Index Key.

HTTP Response

Status Code Content Type Payload
200  OK application/json Index Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.getIndex('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.getIndex('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->getIndex('[COLLECTION_ID]', '');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.get_index('[COLLECTION_ID]', '')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.get_index(collection_id: '[COLLECTION_ID]', key: '')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.getIndex(
        collectionId: '[COLLECTION_ID]',
        key: '',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database getIndex \
            --collectionId="[COLLECTION_ID]" \
            --key=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.getIndex(
            collectionId = "[COLLECTION_ID]",
            key = ""
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.getIndex(
            collectionId = "[COLLECTION_ID]",
            key = ""
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.getIndex(
            collectionId: "[COLLECTION_ID]",
            key: ""
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let index):
                print(String(describing: index)
            }
        }
    }
    

Delete Index

DELETE/v1/database/collections/{collectionId}/indexes/{key}

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "collections.write" permission scope.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

key required string

Index Key.

HTTP Response

Status Code Content Type Payload
204  No Content - -
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.deleteIndex('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.deleteIndex('[COLLECTION_ID]', '');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->deleteIndex('[COLLECTION_ID]', '');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.delete_index('[COLLECTION_ID]', '')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.delete_index(collection_id: '[COLLECTION_ID]', key: '')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.deleteIndex(
        collectionId: '[COLLECTION_ID]',
        key: '',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database deleteIndex \
            --collectionId="[COLLECTION_ID]" \
            --key=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.deleteIndex(
            collectionId = "[COLLECTION_ID]",
            key = ""
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.deleteIndex(
            collectionId = "[COLLECTION_ID]",
            key = ""
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.deleteIndex(
            collectionId: "[COLLECTION_ID]",
            key: ""
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let ):
                print(String(describing: )
            }
        }
    }
    

Create Document

POST/v1/database/collections/{collectionId}/documents

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.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "documents.write" permission scope. You can also authenticate using a valid JWT and perform actions on behalf of your user.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration. Make sure to define attributes before creating documents.

documentId required string

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.

data required object

Document data as JSON object.

read optional array

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.

write optional array

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.

HTTP Response

Status Code Content Type Payload
201  Created application/json Document Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {});
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {});
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', []);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.create_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {})
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.create_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {})
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.createDocument(
        collectionId: '[COLLECTION_ID]',
        documentId: '[DOCUMENT_ID]',
        data: {},
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database createDocument \
            --collectionId="[COLLECTION_ID]" \
            --documentId="[DOCUMENT_ID]" \
            --data="{}" \
            --read="[&quot;role:all&quot;]" \
            --write="[&quot;role:all&quot;]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.createDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]",
            data = mapOf( "a" to "b" ),
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.createDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]",
            data = mapOf( "a" to "b" ),
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.createDocument(
            collectionId: "[COLLECTION_ID]",
            documentId: "[DOCUMENT_ID]",
            data: 
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let document):
                print(String(describing: document)
            }
        }
    }
    

List Documents

GET/v1/database/collections/{collectionId}/documents

Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's documents. Learn more about different API modes.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "documents.read" permission scope. You can also authenticate using a valid JWT and perform actions on behalf of your user.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

queries optional array

Array of query strings.

limit optional integer

Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.

offset optional integer

Offset value. The default value is 0. Use this value to manage pagination. learn more about pagination

cursor optional string

ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. learn more about pagination

cursorDirection optional string

Direction of the cursor.

orderAttributes optional array

Array of attributes used to sort results.

orderTypes optional array

Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order.

HTTP Response

Status Code Content Type Payload
200  OK application/json Documents List Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.listDocuments('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.listDocuments('[COLLECTION_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->listDocuments('[COLLECTION_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.list_documents('[COLLECTION_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.list_documents(collection_id: '[COLLECTION_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.listDocuments(
        collectionId: '[COLLECTION_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database listDocuments \
            --collectionId="[COLLECTION_ID]" \
            --queries="" \
            --limit="0" \
            --offset="0" \
            --cursor="[CURSOR]" \
            --cursorDirection="after" \
            --orderAttributes="" \
            --orderTypes=""
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.listDocuments(
            collectionId = "[COLLECTION_ID]",
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.listDocuments(
            collectionId = "[COLLECTION_ID]",
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.listDocuments(
            collectionId: "[COLLECTION_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let documentList):
                print(String(describing: documentList)
            }
        }
    }
    

Get Document

GET/v1/database/collections/{collectionId}/documents/{documentId}

Get a document by its unique ID. This endpoint response returns a JSON object with the document data.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "documents.read" permission scope. You can also authenticate using a valid JWT and perform actions on behalf of your user.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

documentId required string

Document ID.

HTTP Response

Status Code Content Type Payload
200  OK application/json Document Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.get_document('[COLLECTION_ID]', '[DOCUMENT_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.get_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.getDocument(
        collectionId: '[COLLECTION_ID]',
        documentId: '[DOCUMENT_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database getDocument \
            --collectionId="[COLLECTION_ID]" \
            --documentId="[DOCUMENT_ID]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.getDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]"
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.getDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]"
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.getDocument(
            collectionId: "[COLLECTION_ID]",
            documentId: "[DOCUMENT_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let document):
                print(String(describing: document)
            }
        }
    }
    

Update Document

PATCH/v1/database/collections/{collectionId}/documents/{documentId}

Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "documents.write" permission scope. You can also authenticate using a valid JWT and perform actions on behalf of your user.

HTTP Request

Name Type Description
collectionId required string

Collection ID.

documentId required string

Document ID.

data required object

Document data as JSON object.

read optional array

An array of strings with read permissions. By default inherits the existing read permissions. learn more about permissions and get a full list of available permissions.

write optional array

An array of strings with write permissions. By default inherits the existing write permissions. learn more about permissions and get a full list of available permissions.

HTTP Response

Status Code Content Type Payload
200  OK application/json Document Object
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {});
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {});
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', []);
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.update_document('[COLLECTION_ID]', '[DOCUMENT_ID]', {})
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.update_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {})
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.updateDocument(
        collectionId: '[COLLECTION_ID]',
        documentId: '[DOCUMENT_ID]',
        data: {},
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database updateDocument \
            --collectionId="[COLLECTION_ID]" \
            --documentId="[DOCUMENT_ID]" \
            --data="{}" \
            --read="[&quot;role:all&quot;]" \
            --write="[&quot;role:all&quot;]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.updateDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]",
            data = mapOf( "a" to "b" ),
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.updateDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]",
            data = mapOf( "a" to "b" ),
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.updateDocument(
            collectionId: "[COLLECTION_ID]",
            documentId: "[DOCUMENT_ID]",
            data: 
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let document):
                print(String(describing: document)
            }
        }
    }
    

Delete Document

DELETE/v1/database/collections/{collectionId}/documents/{documentId}

Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents will not be deleted.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "documents.write" permission scope. You can also authenticate using a valid JWT and perform actions on behalf of your user.

HTTP Request

Name Type Description
collectionId required string

Collection ID. You can create a new collection using the Database service server integration.

documentId required string

Document ID.

HTTP Response

Status Code Content Type Payload
204  No Content - -
Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = database.deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • import * as sdk from "https://deno.land/x/appwrite/mod.ts";
    
    // Init SDK
    let client = new sdk.Client();
    
    let database = new sdk.Database(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    
    let promise = database.deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Database;
    
    $client = new Client();
    
    $client
        ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $database = new Database($client);
    
    $result = $database->deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]');
  • from appwrite.client import Client
    from appwrite.services.database import Database
    
    client = Client()
    
    (client
      .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    database = Database(client)
    
    result = database.delete_document('[COLLECTION_ID]', '[DOCUMENT_ID]')
    
  • require 'appwrite'
    
    client = Appwrite::Client.new
    
    client
        .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
        .set_project('5df5acd0d48c2') # Your project ID
        .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    
    database = Appwrite::Database.new(client)
    
    response = database.delete_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]')
    
    puts response.inspect
  • import 'package:dart_appwrite/dart_appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Database database = Database(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
      ;
    
      Future result = database.deleteDocument(
        collectionId: '[COLLECTION_ID]',
        documentId: '[DOCUMENT_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
  • appwrite database deleteDocument \
            --collectionId="[COLLECTION_ID]" \
            --documentId="[DOCUMENT_ID]"
    
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    suspend fun main() {
        val client = Client(context)
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        val database = Database(client)
        val response = database.deleteDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]"
        )
        val json = response.body?.string()
    }
  • import io.appwrite.Client
    import io.appwrite.services.Database
    
    public void main() {
        Client client = Client(context)
            .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
            .setProject("5df5acd0d48c2") // Your project ID
            .setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
    
        Database database = new Database(client);
        database.deleteDocument(
            collectionId = "[COLLECTION_ID]",
            documentId = "[DOCUMENT_ID]"
            new Continuation<Response>() {
                @NotNull
                @Override
                public CoroutineContext getContext() {
                    return EmptyCoroutineContext.INSTANCE;
                }
    
                @Override
                public void resumeWith(@NotNull Object o) {
                    String json = "";
                    try {
                        if (o instanceof Result.Failure) {
                            Result.Failure failure = (Result.Failure) o;
                            throw failure.exception;
                        } else {
                            Response response = (Response) o;
                        }
                    } catch (Throwable th) {
                        Log.e("ERROR", th.toString());
                    }
                }
            }
        );
    }
  • import Appwrite
    
    func main() {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
          .setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        let database = Database(client)
        database.deleteDocument(
            collectionId: "[COLLECTION_ID]",
            documentId: "[DOCUMENT_ID]"
        ) { result in
            switch result {
            case .failure(let error):
                print(error.message)
            case .success(let ):
                print(String(describing: )
            }
        }
    }