Skip to content

Tokens

CLIENT

The Tokens service allows you to create, manage, and validate file tokens for your storage files. These tokens provide a way to grant temporary, controlled access to files without requiring user authentication or exposing sensitive permissions.

File tokens are particularly useful when you need to share access to private storage files with unauthenticated users or services for a limited time period. Each token is linked to a specific file and can be configured with an expiry date to ensure access is only granted for the necessary duration.

You can use tokens to generate secure URLs to view, preview, or download files. The Tokens service provides endpoints to create, list, retrieve, update, and delete tokens, giving you complete control over file access management.

For more detailed information about using file tokens in your application, refer to the File tokens documentation.

Base URL
https://<REGION>.cloud.appwrite.io/v1

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

      Document ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.

    • data object

      Document data as JSON object.

    • permissions array

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

  • Response
  • Rate limits

    This endpoint is rate limited. You can only make a limited number of request to his endpoint within a specific time frame.

    The limit is applied for each unique limit key.

    Time frame
    Attempts
    Key
    1 minutes120 requestsIP + METHOD + URL + USER ID
Endpoint
POST /databases/{databaseId}/collections/{collectionId}/documents
Web
import { Client, Databases } from "appwrite";

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.createDocument(
    '<DATABASE_ID>', // databaseId
    '<COLLECTION_ID>', // collectionId
    '<DOCUMENT_ID>', // documentId
    {}, // data
    ["read("any")"] // permissions (optional)
);

console.log(result);