Databases

SERVER

The Databases service allows you to create structured collections of documents, query and filter lists of documents, and manage an advanced set of read and write access permissions.

All data returned by the Databases service are represented as structured JSON documents.

The Databases service can contain multiple databases, each database can contain multiple collections. A collection is a group of similarly structured documents. The accepted structure of documents is defined by collection attributes. The collection attributes help you ensure all your user-submitted data is validated and stored according to the collection structure.

Using Appwrite permissions architecture, you can assign read or write access to each collection or document in your project for either a specific user, team, user role, or even grant it with public access (any). You can learn more about how Appwrite handles permissions and access control.

Base URL
https://cloud.appwrite.io/v1

List Databases

Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results.

  • Request
    • queries array

      Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name

    • search string

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

  • Response
Endpoint
GET /databases
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.list(
        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());
                }
            }
        }
    );
}

Create Database

Create a new Database.

  • Request
    • databaseId string
      required

      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 string
      required

      Collection name. Max length: 128 chars.

  • Response
Endpoint
POST /databases
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.create(
        databaseId = "[DATABASE_ID]",
        name = "[NAME]"
        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());
                }
            }
        }
    );
}

Get Database

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

  • Request
    • databaseId string
      required

      Database ID.

  • Response
Endpoint
GET /databases/{databaseId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.get(
        databaseId = "[DATABASE_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());
                }
            }
        }
    );
}

Update Database

Update a database by its unique ID.

  • Request
    • databaseId string
      required

      Database ID.

    • name string
      required

      Collection name. Max length: 128 chars.

  • Response
Endpoint
PUT /databases/{databaseId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.update(
        databaseId = "[DATABASE_ID]",
        name = "[NAME]"
        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());
                }
            }
        }
    );
}

Delete Database

Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database.

  • Request
    • databaseId string
      required

      Database ID.

  • Response
    • 204 application/json
Endpoint
DELETE /databases/{databaseId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.delete(
        databaseId = "[DATABASE_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());
                }
            }
        }
    );
}

List Collections

Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results.

  • Request
    • databaseId string
      required

      Database ID.

    • queries array

      Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity

    • search string

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

  • Response
Endpoint
GET /databases/{databaseId}/collections
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.listCollections(
        databaseId = "[DATABASE_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());
                }
            }
        }
    );
}

Create Collection

Create a new Collection. Before using this route, you should create a new database resource using either a server integration API or directly from your database console.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

      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 string
      required

      Collection name. Max length: 128 chars.

    • documentSecurity boolean

      Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. Learn more about permissions.

  • Response
Endpoint
POST /databases/{databaseId}/collections
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createCollection(
        databaseId = "[DATABASE_ID]",
        collectionId = "[COLLECTION_ID]",
        name = "[NAME]",
        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());
                }
            }
        }
    );
}

Get Collection

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

      Collection ID.

  • Response
Endpoint
GET /databases/{databaseId}/collections/{collectionId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.getCollection(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Update Collection

Update a collection by its unique ID.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

      Collection ID.

    • name string
      required

      Collection name. Max length: 128 chars.

    • documentSecurity boolean

      Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. Learn more about permissions.

    • enabled boolean

      Is collection enabled?

  • Response
Endpoint
PUT /databases/{databaseId}/collections/{collectionId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.updateCollection(
        databaseId = "[DATABASE_ID]",
        collectionId = "[COLLECTION_ID]",
        name = "[NAME]",
        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());
                }
            }
        }
    );
}

Delete Collection

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

      Collection ID.

  • Response
    • 204 application/json
Endpoint
DELETE /databases/{databaseId}/collections/{collectionId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.deleteCollection(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

List Attributes

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

  • Response
Endpoint
GET /databases/{databaseId}/collections/{collectionId}/attributes
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.listAttributes(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Boolean Attribute

Create a boolean attribute.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • default boolean

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/boolean
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createBooleanAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create DateTime Attribute

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • default string

      Default value for the attribute in ISO 8601 format. Cannot be set when attribute is required.

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/datetime
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createDatetimeAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Email Attribute

Create an email attribute.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • default string

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/email
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createEmailAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Enum Attribute

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • elements array
      required

      Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long.

    • required boolean
      required

      Is attribute required?

    • default string

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/enum
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createEnumAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Float Attribute

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • min number

      Minimum value to enforce on new documents

    • max number

      Maximum value to enforce on new documents

    • default number

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/float
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createFloatAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Integer Attribute

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • min integer

      Minimum value to enforce on new documents

    • max integer

      Maximum value to enforce on new documents

    • default integer

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/integer
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createIntegerAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create IP Address Attribute

Create IP address attribute.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • default string

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/ip
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createIpAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create String Attribute

Create a string attribute.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • size integer
      required

      Attribute size for text attributes, in number of characters.

    • required boolean
      required

      Is attribute required?

    • default string

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/string
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createStringAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create URL Attribute

Create a URL attribute.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

    • required boolean
      required

      Is attribute required?

    • default string

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

    • array boolean

      Is attribute an array?

  • Response
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/attributes/url
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createUrlAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Get Attribute

Endpoint
GET /databases/{databaseId}/collections/{collectionId}/attributes/{key}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.getAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Delete Attribute

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Attribute Key.

  • Response
    • 204 application/json
Endpoint
DELETE /databases/{databaseId}/collections/{collectionId}/attributes/{key}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.deleteAttribute(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

List Documents

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • queries array

      Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.

  • Response
Endpoint
GET /databases/{databaseId}/collections/{collectionId}/documents
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.listDocuments(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Document

Create a new Document. Before using this route, you should create a new collection resource using either a server integration API or directly from your database console.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • documentId string
      required

      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 object
      required

      Document data as JSON object.

    • permissions array

      An array of permissions strings. By default the current user is granted with all permissions. Learn more about permissions.

  • Response
  • Rate limits

    This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with setSession, these rate limits will still apply. Learn more about SSR rate limits.

    The limit is applied for each unique limit key.

    Time frame
    Attempts
    Key
    1 minutes 120 requests IP + METHOD + URL + USER ID
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/documents
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createDocument(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Get Document

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • documentId string
      required

      Document ID.

  • Response
Endpoint
GET /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.getDocument(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Update Document

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

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

      Collection ID.

    • documentId string
      required

      Document ID.

    • data object

      Document data as JSON object. Include only attribute and value pairs to be updated.

  • Response
  • Rate limits

    This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with setSession, these rate limits will still apply. Learn more about SSR rate limits.

    The limit is applied for each unique limit key.

    Time frame
    Attempts
    Key
    1 minutes 120 requests IP + METHOD + URL + USER ID
Endpoint
PATCH /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.updateDocument(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Delete Document

Delete a document by its unique ID.

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • documentId string
      required

      Document ID.

  • Response
    • 204 application/json
  • Rate limits

    This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with setSession, these rate limits will still apply. Learn more about SSR rate limits.

    The limit is applied for each unique limit key.

    Time frame
    Attempts
    Key
    1 minutes 60 requests IP + METHOD + URL + USER ID
Endpoint
DELETE /databases/{databaseId}/collections/{collectionId}/documents/{documentId}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.deleteDocument(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

List Indexes

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

  • Response
Endpoint
GET /databases/{databaseId}/collections/{collectionId}/indexes
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.listIndexes(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Create Index

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Index Key.

    • type string
      required

      Index type.

    • attributes array
      required

      Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.

    • orders array

      Array of index orders. Maximum of 100 orders are allowed.

  • Response
    • 202 application/json
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/indexes
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.createIndex(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Get Index

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Index Key.

  • Response
    • 200 application/json
Endpoint
GET /databases/{databaseId}/collections/{collectionId}/indexes/{key}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.getIndex(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}

Delete Index

  • Request
    • databaseId string
      required

      Database ID.

    • collectionId string
      required

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

    • key string
      required

      Index Key.

  • Response
    • 204 application/json
Endpoint
DELETE /databases/{databaseId}/collections/{collectionId}/indexes/{key}
Java
import io.appwrite.Client
import io.appwrite.services.Databases

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

    Databases databases = new Databases(client);
    databases.deleteIndex(
        databaseId = "[DATABASE_ID]",
        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());
                }
            }
        }
    );
}