Introducing a new way to review your PRs.

Read the announcement

appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎

View on GitHub

24 documents · Updated Nov 18, 2026

docs / models-and-enumerations

Models and enumerations

The typed response models declared in src/models.ts describe the resources that Appwrite services return. The exported enumerations constrain common request and response values so that callers use the platform's accepted provider, browser, execution, image, and regional codes. This page extends SDK value types and query building and complements queries, permissions, and roles.

Typed resource models

The Models namespace gives each service a shared vocabulary for resource objects and list responses. A service method returns a model type such as Models.User or Models.Execution, while list methods return an envelope with both a result count and an array of those resources.

List response envelopes

List models keep pagination and result data together. Each envelope has a total count and a domain-specific array, such as rows, documents, files, memberships, or executions.

Resource areaList modelResult field
Tables and databasesRowListrows
DocumentsDocumentListdocuments
Realtime and audit dataPresenceList, LogListpresences, logs
Account and teamsIdentityList, SessionList, TeamList, MembershipListMatching plural field
Storage and functionsFileList, ExecutionListfiles, executions
Locale dataCountryList, ContinentList, LanguageList, CurrencyList, PhoneList, LocaleCodeListMatching plural field
Transactions and app accessTransactionList, AppInstallationList, Oauth2ConsentList, Oauth2ConsentTokenListtransactions, installations, consents, tokens

The count can be disabled by service methods that accept a total option. In that case the result array still carries the returned resources, but the count is not calculated. See query and list behavior for how these list calls accept query values.

References: src/models.ts• L8-214 src/…/account.ts• L188-240 src/…/locale.ts• L35-151

Resource identity and access fields

Many stored resources share system fields that let callers identify the resource and understand its lifetime. Rows, documents, files, teams, memberships, sessions, identities, executions, transactions, and app-access records use IDs and ISO 8601 date strings; resources that support access rules expose a $permissions string array.

Rows and documents also carry their parent table or collection and database IDs. Their default forms allow application fields that are not known to the SDK. A caller can supply a narrower row or document type through the generic list model when the application has a known schema.

References: src/models.ts• L217-311 src/models.ts• L386-469 src/models.ts• L577-725 src/models.ts• L809-1000 src/models.ts• L1155-1390

Account and security resources

Account services return models for the user, sessions, linked identities, tokens, MFA work, and message targets. Models.User includes account state, verification flags, MFA state, targets, and preferences. Its preference type is generic, so an application can replace the open default preference shape with its own type.

MFA operations connect several model shapes. An MFA setup returns MfaType with an authenticator secret and URI. A challenge returns MfaChallenge, a successful challenge returns a Session, and recovery-code operations return MfaRecoveryCodes. MfaFactors reports which challenge factors are available for an account. Treat secret-bearing fields as sensitive data rather than as display-only metadata.

References: src/models.ts• L386-469 src/models.ts• L577-725 src/models.ts• L1096-1153 src/models.ts• L1213-1243 src/…/account.ts• L442-596 src/…/account.ts• L751-917

Execution, storage, and locale resources

Function and site calls return Execution objects that describe the resource, deployment, trigger, status, request, response, logs, errors, duration, and optional schedule. The model uses typed execution resource, trigger, and status values so callers can relate an execution to both its source and its lifecycle. Storage calls return File objects with file identity, names, signatures, media type, sizes, upload progress, and storage properties. These models let the caller inspect the result of an operation without depending on the service's transport form.

Locale calls return either a Locale lookup for the current IP or reference data for languages, countries, continents, currencies, phones, and language codes. Locale reference models use standard code systems, while their list models provide the data needed to build user-facing selectors.

References: src/models.ts• L737-860 src/models.ts• L940-1000 src/…/functions.ts• L17-228 src/…/storage.ts• L1-44 src/…/locale.ts• L16-151

Transactions and delegated app access

Transaction models describe a group of work that can be pending, committed, rolled back, or failed. They also expose the operation count and expiry so callers can track the transaction window without treating the transaction as an individual data row.

Delegated app access uses separate models for an installation, a user consent, and the token family created from that consent. These models preserve the app or client identity, granted scopes, resource indicators, authorization details, and expiry information needed to understand the access grant.

References: src/models.ts• L1155-1177 src/models.ts• L1245-1390

Enumerated SDK values

The SDK exports its enumerations from src/index.ts, so callers can use names such as ExecutionMethod.POST instead of writing a raw wire value. The enum member name is for TypeScript code; its assigned string is the value sent to the service.

Platform and browser values

The platform value group controls browser-aware avatar and screenshot requests. Browser identifies a browser by the short code used by session data. BrowserTheme limits screenshot themes to light and dark, while BrowserPermission names browser capabilities such as geolocation, camera, microphone, notifications, clipboard access, and sensors.

Timezone supplies IANA time zone identifiers for browser rendering. Screenshot locale remains a string because it accepts locale forms such as en-US and fr-FR; use the locale service's code data when an application needs a supported language list.

References: src/…/browser.ts• L1-16 src/…/browser-theme.ts• L1-4 src/…/browser-permission.ts• L1-22 src/…/timezone.ts• L1-421 src/…/avatars.ts• L595-625

Authentication values

Authentication enums constrain which external identity provider or MFA path a request can use. OAuthProvider contains the supported provider identifiers across social, enterprise, and platform-specific login services, including sandbox and OIDC-style provider choices. AuthenticatorType currently permits the totp authenticator, and AuthenticationFactor permits email, phone, totp, or the recovery-code factor.

These values describe different parts of the auth flow. A provider identifies an external login source, an authenticator type identifies the device setup method, and a factor identifies the proof used for a challenge. The enum values are the contract sent to the account service, including their exact lower-case or mixed-case spelling.

References: src/…/o-auth-provider.ts• L1-55 src/…/authenticator-type.ts• L1-3 src/…/authentication-factor.ts• L1-6 src/…/account.ts• L442-596 src/…/account.ts• L751-852

Execution values

ExecutionMethod limits the HTTP method used when a function execution starts to GET, POST, PUT, PATCH, DELETE, OPTIONS, or HEAD. ExecutionResourceType distinguishes functions from sites. These values describe the target and request shape, while the returned Execution model records the trigger and status that describe how the run progressed.

ExecutionTrigger distinguishes http, schedule, event, and email causes. ExecutionStatus describes the lifecycle as waiting, processing, completed, failed, or scheduled. These two enums are most useful when reading execution results or building filters for execution lists.

References: src/…/execution-method.ts• L1-9 src/…/execution-resource-type.ts• L1-4 src/…/execution-trigger.ts• L1-6 src/…/execution-status.ts• L1-7 src/…/functions.ts• L17-228 src/models.ts• L940-1000

Image and avatar values

ImageFormat limits generated image output to the formats supported by avatar, screenshot, and file-preview services: jpg, jpeg, png, webp, heic, avif, and gif. It also provides auto when the service should select the output format. ImageGravity selects the crop anchor from the center, edges, or corners. These values affect image transformation rather than the resource model returned by a JSON service.

Avatar icon endpoints also use Browser, CreditCard, and Flag codes to select a browser, payment-card brand, or country flag. The CreditCard and Flag enums therefore act as lookup keys for image resources, while ImageFormat and ImageGravity act as rendering options.

References: src/…/image-format.ts• L1-10 src/…/image-gravity.ts• L1-11 src/…/credit-card.ts• L1-19 src/…/flag.ts• L1-197 src/…/avatars.ts• L23-35 src/…/avatars.ts• L595-625 src/…/storage.ts• L592-612

Locale and regional values

Locale data uses several standard code families rather than one large enum. Countries use ISO 3166-1 alpha-2 codes, languages and locale codes use ISO 639-1 codes, currencies use ISO 4217-style codes, and time zones use IANA identifiers. The Flag and Timezone enums cover common request choices, but the Locale service remains the source for lists and translated names.

This split keeps request options strict where the SDK knows a fixed platform set, while allowing locale data to come from the service. Use Locale.get() for the current IP-based location and the list methods for selectable country, language, currency, phone, continent, or locale-code data.

References: src/models.ts• L737-806 src/…/flag.ts• L1-197 src/…/timezone.ts• L1-421 src/…/locale.ts• L16-151

Model and value flow

Service methods combine typed inputs with a shared response model. An enum contributes its wire string to the request, and the service result is exposed as a model or model list so downstream code can handle the platform response by domain rather than by untyped objects.

The main relationship is shown below.

flowchart LR
    A[Application request] --> B[Service method]
    C[Enum value] --> B
    B --> D[Appwrite API]
    D --> E[Typed model or model list]
    E --> F[Application domain logic]
    G[Locale reference data] --> A

The transport accepts enum values as ordinary strings in query parameters or request bodies. JSON responses are decoded and returned through the model types declared by the SDK, while binary image endpoints return image data instead of a model object.

References: src/index.ts• L14-36 src/client.ts• L689-736 src/…/functions.ts• L80-173 src/…/avatars.ts• L716-811

Change checklist

When these files or sections are changed, remember to consider these:

  • When a model field or list envelope changes, update every service return type and the corresponding domain name used by callers.
  • When an enum wire value changes, check both request parameters and any response fields or query filters that use the same value.
  • When a generic model such as User, Team, Row, or Document changes, preserve the custom preference or application-field extension path.
  • When locale code data changes, keep the standard code meaning aligned between Locale models, Flag, Timezone, and the avatar or screenshot inputs that consume them.
  • When an MFA enum changes, check the full setup, challenge, verification, and recovery-code flow because each step uses a different model or factor value.
  • When delegated access models change, keep installation, consent, and token-list fields aligned with the access lifecycle they describe.

Important failure modes

TriggerConsequenceGuard
A raw browser, provider, execution, image, or resource-type string is outside the enum setThe service rejects the request or produces an unsupported resource choiceUse the exported enum and its assigned wire value
An MFA factor uses documentation spelling instead of the enum wire valueThe challenge request can fail because the factor does not match the account API contractUse AuthenticationFactor.Recoverycode, whose value is recoverycode
Code treats a list response as a direct arrayThe caller misses total or reads the wrong result fieldRead the domain list envelope and its named array
Code assumes every model has the same access fieldsAccess checks or UI code reads fields that a resource does not exposeCheck the specific model before using $permissions or other optional data
Code assumes a model always contains sensitive or synchronous execution fieldsThe caller exposes secrets or treats an absent response body or log as an errorRespect the model's conditional field behavior and request context
Code treats consent, token, and installation records as one access objectThe caller loses the difference between granted consent, installed app scope, and issued token stateKeep the three model roles separate when showing or changing delegated access

Key files

FileWhy to read it
src/models.tsDefines the shared resource models, list envelopes, generic row and document shapes, locale data contracts, transaction records, and delegated app-access models.
src/index.tsShows which model and enum types are part of the public SDK surface.
src/…/account.tsConnects user and MFA operations to account models and authentication enums.
src/…/functions.tsConnects execution inputs and lifecycle values to Models.Execution.
src/…/avatars.tsShows how browser, regional, image, theme, time zone, and permission values shape media requests.
src/…/locale.tsShows how location and locale reference models are returned for application use.
src/…/storage.tsShows image format and gravity values applied to file previews and returns Models.File for storage resources.
src/client.tsShows the shared request and response boundary through which enum strings and model data travel.