syntax = "proto3";
package anytype;
option go_package = "pb";

import "models.proto";
import "localstore.proto";

import "events.proto";
import "google/protobuf/struct.proto";


import "google/protobuf/descriptor.proto";

// To disable authorization in specific method use no_auth option inside Request of that method
extend google.protobuf.MessageOptions {
    bool no_auth = 7777;
}

/*
 * Rpc is a namespace, that agregates all of the service commands between client and middleware.
 * Structure: Topic > Subtopic > Subsub... > Action > (Request, Response).
 * Request – message from a client.
 * Response – message from a middleware.
*/
message Rpc {
    message App {
        message GetVersion {
            message Request {
                option (no_auth) = true;
            }
            message Response {
                Error error = 1;
                string version = 2;
                string details = 3; // build date, branch and commit

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message SetDeviceState {
            message Request {
                DeviceState deviceState = 1;

                enum DeviceState {
                    BACKGROUND = 0;
                    FOREGROUND = 1;
                }
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }

            }
        }


        message Shutdown {
            message Request {
            }
            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }

            }
        }
    }

    message Space {
        message LeaveApprove {
            message Request {
                string spaceId = 1;
                repeated string identities = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                        NO_APPROVE_REQUESTS = 105;
                        NOT_SHAREABLE = 106;
                    }
                }
            }
        }

        message MakeShareable {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                    }
                }
            }
        }

        message InviteChange {
            message Request {
                string spaceId = 1;
                model.ParticipantPermissions permissions = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        INCORRECT_PERMISSIONS = 105;
                    }
                }
            }
        }

        message InviteGenerate {
            message Request {
                string spaceId = 1;
                model.InviteType inviteType = 2;
                model.ParticipantPermissions permissions = 3;
            }

            message Response {
                Error error = 1;
                string inviteCid = 2;
                string inviteFileKey = 3;
                model.InviteType inviteType = 4;
                model.ParticipantPermissions permissions = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                        NOT_SHAREABLE = 105;
                    }
                }
            }
        }

        message StopSharing {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                    }
                }
            }
        }

        message InviteGetCurrent {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;
                string inviteCid = 2;
                string inviteFileKey = 3;
                model.InviteType inviteType = 4;
                model.ParticipantPermissions permissions = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_ACTIVE_INVITE = 101;
                    }
                }
            }
        }

        message InviteGetGuest {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;
                string inviteCid = 2;
                string inviteFileKey = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        INVALID_SPACE_TYPE = 101;
                    }
                }
            }
        }


        message InviteRevoke {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        LIMIT_REACHED = 103;
                        REQUEST_FAILED = 104;
                        NOT_SHAREABLE = 105;
                    }
                }
            }
        }

        message InviteView {
            message Request {
                string inviteCid = 1;
                string inviteFileKey = 2;
            }

            message Response {
                Error error = 1;
                string spaceId = 2;
                string spaceName = 3;
                string spaceIconCid = 4;
                string creatorName = 5;
                bool   isGuestUserInvite = 6; // deprecated, use inviteType
                model.InviteType inviteType = 7;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        INVITE_NOT_FOUND = 101;
                        INVITE_BAD_CONTENT = 102;
                        SPACE_IS_DELETED = 103;
                    }
                }
            }
        }

        message Join {
            message Request {
                string networkId = 1; // not-empty only for self-hosting
                string spaceId = 2;
                string inviteCid = 3;
                string inviteFileKey = 4;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        INVITE_NOT_FOUND = 103;
                        INVITE_BAD_CONTENT = 104;
                        REQUEST_FAILED = 105;
                        LIMIT_REACHED = 106;
                        NOT_SHAREABLE = 107;
                        DIFFERENT_NETWORK = 108;
                    }
                }
            }
        }

        message JoinCancel {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                        NO_SUCH_REQUEST = 105;
                        NOT_SHAREABLE = 106;
                    }
                }
            }
        }

        message RequestApprove {
            message Request {
                string spaceId = 1;
                string identity = 2;
                model.ParticipantPermissions permissions = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        NO_SUCH_REQUEST = 103;
                        INCORRECT_PERMISSIONS = 104;
                        REQUEST_FAILED = 105;
                        LIMIT_REACHED = 106;
                        NOT_SHAREABLE = 107;
                    }
                }
            }
        }

        message RequestDecline {
            message Request {
                string spaceId = 1;
                string identity = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                        NO_SUCH_REQUEST = 105;
                        NOT_SHAREABLE = 106;
                    }
                }
            }
        }

        message ParticipantRemove {
            message Request {
                string spaceId = 1;
                repeated string identities = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        PARTICIPANT_NOT_FOUND = 103;
                        REQUEST_FAILED = 104;
                        LIMIT_REACHED = 105;
                        NOT_SHAREABLE = 106;
                    }
                }
            }
        }

        message ParticipantPermissionsChange {
            message Request {
                string spaceId = 1;
                repeated model.ParticipantPermissionChange changes = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                        PARTICIPANT_NOT_FOUND = 105;
                        INCORRECT_PERMISSIONS = 106;
                        NOT_SHAREABLE = 107;
                    }
                }
            }
        }

        message Delete {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;
                int64 timestamp = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NO_SUCH_SPACE = 101;
                        SPACE_IS_DELETED = 102;
                        REQUEST_FAILED = 103;
                        LIMIT_REACHED = 104;
                        NOT_SHAREABLE = 105;
                    }
                }
            }
        }
        message SetOrder {
            message Request {
                string spaceViewId = 1;
                repeated string spaceViewOrder = 2; // result order of space view ids
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message UnsetOrder {
            message Request {
                string spaceViewId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message Wallet {
        message Create {
            /**
            * Front-end-to-middleware request to create a new wallet
            */
            message Request {
                option (no_auth) = true;
                string rootPath = 1; // Path to a wallet directory
                string fulltextPrimaryLanguage = 2; // optional, default fts language
            }

            /**
            * Middleware-to-front-end response, that can contain mnemonic of a created account and a NULL error or an empty mnemonic and a non-NULL error
            */
            message Response {
                Error error = 1;
                string mnemonic = 2; // Mnemonic of a new account (sequence of words, divided by spaces)

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error; mnemonic should be non-empty
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Root path is wrong

                        FAILED_TO_CREATE_LOCAL_REPO = 101;
                        // ...
                    }
                }
            }
        }

        message Recover {
            /**
            * Front end to middleware request-to-recover-a wallet with this mnemonic and a rootPath
            */
            message Request {
                option (no_auth) = true;

                string rootPath = 1; // Path to a wallet directory
                string mnemonic = 2; // Mnemonic of a wallet to recover
                string fulltextPrimaryLanguage = 3; // optional, default fts language
            }

            /**
            * Middleware-to-front-end response, that can contain a NULL error or a non-NULL error
            */
            message Response {
                Error error = 1; // Error while trying to recover a wallet
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error; wallet successfully recovered
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Root path or mnemonic is wrong

                        FAILED_TO_CREATE_LOCAL_REPO = 101;
                    }
                }
            }
        }

        message Convert {
            message Request {
                string mnemonic = 1; // Mnemonic of a wallet to convert
                string entropy = 2; // entropy of a wallet to convert

            }

            message Response {
                Error error = 1; // Error while trying to recover a wallet
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error; wallet successfully recovered
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // mnemonic is wrong
                    }
                }

                string entropy = 2;
                string mnemonic = 3;
            }
        }

        message CreateSession {
            message Request {
                option (no_auth) = true;
                oneof auth {
                    string mnemonic = 1; // cold auth
                    string appKey = 2; // persistent app key, that can be used to restore session
                }
            }

            message Response {
                Error error = 1;
                string token = 2;
                string appToken = 3; // in case of mnemonic auth, need to be persisted by client
                string accountId = 4; // temp, should be replaced with AccountInfo message

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        APP_TOKEN_NOT_FOUND_IN_THE_CURRENT_ACCOUNT = 101; // means the client logged into another account or the account directory has been cleaned
                    }
                }
            }
        }

        message CloseSession {
            message Request {
                string token = 1;
            }

            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

    }

    message Account {
        message Config {
            bool enableDataview = 1;
            bool enableDebug = 2;
            bool enablePrereleaseChannel = 3;
            bool enableSpaces = 4;

            google.protobuf.Struct extra = 100;
        }

        message Create {
            /**
            * Front end to middleware request-to-create-an account
            */
            message Request {
                option (no_auth) = true;

                string name = 1; // Account name
                oneof avatar {//TODO: Remove if not needed, GO-1926
                    string avatarLocalPath = 2; // Path to an image, that will be used as an avatar of this account
                }
                string storePath = 3; // Path to local storage
                int64 icon = 4; // Option of pre-installed icon
                bool disableLocalNetworkSync = 5; // Disable local network discovery
                NetworkMode networkMode = 6; // optional, default is DefaultConfig
                string networkCustomConfigFilePath = 7; // config path for the custom network mode            }
                bool preferYamuxTransport = 8; // optional, default is false, recommended in case of problems with QUIC transport
                string jsonApiListenAddr = 9; // optional, if empty json api will not be started; 127.0.0.1:31009 should be the default one
                string joinStreamUrl = 10; // anytype:// schema URL to join an embed stream
            }
            /**
            * Middleware-to-front-end response for an account creation request, that can contain a NULL error and created account or a non-NULL error and an empty account
            */
            message Response {
                Error error = 1; // Error while trying to create an account
                anytype.model.Account account = 2; // A newly created account; In case of a failure, i.e. error is non-NULL, the account model should contain empty/default-value fields
                Config config = 3; // deprecated, use account, GO-1926
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error; Account should be non-empty
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Avatar or name is not correct

                        ACCOUNT_CREATED_BUT_FAILED_TO_START_NODE = 101;
                        ACCOUNT_CREATED_BUT_FAILED_TO_SET_NAME = 102;
                        FAILED_TO_STOP_RUNNING_NODE = 104;
                        FAILED_TO_WRITE_CONFIG = 105;
                        FAILED_TO_CREATE_LOCAL_REPO = 106;
                        ACCOUNT_CREATION_IS_CANCELED = 107;

                        CONFIG_FILE_NOT_FOUND = 200;
                        CONFIG_FILE_INVALID = 201;
                        CONFIG_FILE_NETWORK_ID_MISMATCH = 202;
                    }
                }
            }
        }

        message Recover {
            /**
            * Front end to middleware request-to-start-search of an accounts for a recovered mnemonic.
            * Each of an account that would be found will come with an AccountAdd event
            */
            message Request {
            }

            /**
            * Middleware-to-front-end response to an account recover request, that can contain a NULL error and created account or a non-NULL error and an empty account
            */
            message Response {
                Error error = 1; // Error while trying to recover an account
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error;
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2;

                        NEED_TO_RECOVER_WALLET_FIRST = 102;
                    }
                }
            }
        }

        message Delete {
            message Request {
            }

            message Response {
                Error error = 1; // Error while trying to recover an account
                anytype.model.Account.Status status = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error;
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2;

                        ACCOUNT_IS_ALREADY_DELETED = 101;
                        UNABLE_TO_CONNECT = 102;
                    }
                }
            }
        }

        message RevertDeletion {
            message Request {
            }

            message Response {
                Error error = 1; // Error while trying to recover an account
                anytype.model.Account.Status status = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error;
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2;

                        ACCOUNT_IS_ACTIVE = 101;
                        UNABLE_TO_CONNECT = 102;
                    }
                }
            }
        }

        message Migrate {
            message Request {
                option (no_auth) = true;
                string id = 1; // Id of a selected account
                string rootPath = 2;
                string fulltextPrimaryLanguage = 3; // optional, default fts language
            }

            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;
                    int64 requiredSpace = 3;

                    enum Code {
                        NULL = 0; // No error
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Id or root path is wrong

                        ACCOUNT_NOT_FOUND = 101;
                        CANCELED = 102;
                        NOT_ENOUGH_FREE_SPACE = 103;
                        // TODO: [storage] Add specific error codes for migration problems
                    }
                }
            }
        }

        message MigrateCancel {
            message Request {
                option (no_auth) = true;
                string id = 1; // Id of a selected account
            }

            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Id or root path is wrong
                    }
                }
            }
        }

        message Select {
            /**
            * Front end to middleware request-to-launch-a specific account using account id and a root path
            * User can select an account from those, that came with an AccountAdd events
            */
            message Request {
                option (no_auth) = true;
                string id = 1; // Id of a selected account
                string rootPath = 2; // Root path is optional, set if this is a first request
                bool disableLocalNetworkSync = 3; // Disable local network discovery
                NetworkMode networkMode = 4; // optional, default is DefaultConfig
                string networkCustomConfigFilePath = 5; // config path for the custom network mode
                bool preferYamuxTransport = 6; // optional, default is false, recommended in case of problems with QUIC transport
                string jsonApiListenAddr = 7; // optional, if empty json api will not be started; 127.0.0.1:31009 should be the default one
                string fulltextPrimaryLanguage = 8; // optional, default fts language
                string joinStreamURL = 9; // anytype:// schema URL to join an embed stream
            }

            /**
            * Middleware-to-front-end response for an account select request, that can contain a NULL error and selected account or a non-NULL error and an empty account
            */
            message Response {
                Error error = 1; // Error while trying to launch/select an account
                anytype.model.Account account = 2; // Selected account
                Config config = 3; // deprecated, use account, GO-1926
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Id or root path is wrong

                        FAILED_TO_CREATE_LOCAL_REPO = 101;
                        LOCAL_REPO_EXISTS_BUT_CORRUPTED = 102;
                        FAILED_TO_RUN_NODE = 103;
                        FAILED_TO_FIND_ACCOUNT_INFO = 104;
                        LOCAL_REPO_NOT_EXISTS_AND_MNEMONIC_NOT_SET = 105;
                        FAILED_TO_STOP_SEARCHER_NODE = 106;
                        ANOTHER_ANYTYPE_PROCESS_IS_RUNNING = 108;
                        FAILED_TO_FETCH_REMOTE_NODE_HAS_INCOMPATIBLE_PROTO_VERSION = 110;
                        ACCOUNT_IS_DELETED = 111;
                        ACCOUNT_LOAD_IS_CANCELED = 112;
                        ACCOUNT_STORE_NOT_MIGRATED = 113;

                        CONFIG_FILE_NOT_FOUND = 200;
                        CONFIG_FILE_INVALID = 201;
                        CONFIG_FILE_NETWORK_ID_MISMATCH = 202;
                    }
                }
            }
        }

        message Stop {
            /**
            * Front end to middleware request to stop currently running account node and optionally remove the locally stored data
            */
            message Request {
                bool removeData = 1;
            }

            /**
            * Middleware-to-front-end response for an account stop request
            */
            message Response {
                Error error = 1; // Error while trying to launch/select an account
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0; // No error
                        UNKNOWN_ERROR = 1; // Any other errors
                        BAD_INPUT = 2; // Id or root path is wrong

                        ACCOUNT_IS_NOT_RUNNING = 101;
                        FAILED_TO_STOP_NODE = 102;
                        FAILED_TO_REMOVE_ACCOUNT_DATA = 103;
                    }
                }
            }
        }

        message Move {
            /**
            * Front-end-to-middleware request to move a account to a new disk location
            */
            message Request {
                string newPath = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        FAILED_TO_STOP_NODE = 101;
                        FAILED_TO_IDENTIFY_ACCOUNT_DIR = 102;
                        FAILED_TO_REMOVE_ACCOUNT_DATA = 103;
                        FAILED_TO_CREATE_LOCAL_REPO = 104;
                        FAILED_TO_WRITE_CONFIG = 105;
                        FAILED_TO_GET_CONFIG = 106;
                    }
                }
            }
        }

        message ConfigUpdate {
            message Request {
                string IPFSStorageAddr = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        ACCOUNT_IS_NOT_RUNNING = 101;
                        FAILED_TO_WRITE_CONFIG = 102;
                    }
                }
            }

            enum Timezones {
                GMT = 0;
                ECT = 1;
                EET = 2;
                EAT = 3;
                MET = 4;
                NET = 5;
                PLT = 6;
                IST = 7;
                BST = 8;
                VST = 9;
                CTT = 10;
                JST = 11;
                ACT = 12;
                AET = 13;
                SST = 14;
                NST = 15;
                MIT = 16;
                HST = 17;
                AST = 18;
                PST = 19;
                MST = 20;
                CST = 21;
                IET = 22;
                PRT = 23;
                CNT = 24;
                BET = 25;
                BRT = 26;
                CAT = 27;
            }
        }

        message GetConfig {//TODO: Remove this request if we do not need it, GO-1926
            message Get {
                message Request {
                }

            }
        }

        message RecoverFromLegacyExport {
            message Request {
                option (no_auth) = true;
                string path = 1;
                string rootPath = 2;
                int64 icon = 3;
                string fulltextPrimaryLanguage = 4; // optional, default fts language
            }

            message Response {
                string accountId = 1;
                string personalSpaceId = 3;
                Error error = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        DIFFERENT_ACCOUNT = 3;
                    }
                }
            }
        }

        message EnableLocalNetworkSync {
            message Request {
            }
            message Response {
                Error error = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        ACCOUNT_IS_NOT_RUNNING = 4;
                    }
                }
            }

        }

        message ChangeJsonApiAddr {
            message Request {
                string listenAddr = 1; // make sure to use 127.0.0.1:x to not listen on all interfaces; recommended value is 127.0.0.1:31009
            }
            message Response {
                Error error = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        ACCOUNT_IS_NOT_RUNNING = 4;
                    }
                }
            }

        }

        message ChangeNetworkConfigAndRestart {
            message Request {
                NetworkMode networkMode = 1;
                string networkCustomConfigFilePath = 2;
            }
            message Response {
                Error error = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        ACCOUNT_IS_NOT_RUNNING = 4;

                        ACCOUNT_FAILED_TO_STOP = 100;
                        CONFIG_FILE_NOT_FOUND = 200;
                        CONFIG_FILE_INVALID = 201;
                        CONFIG_FILE_NETWORK_ID_MISMATCH = 202;

                    }
                }
            }

        }

        enum NetworkMode {
            DefaultConfig = 0; // use network config that embedded in binary
            LocalOnly = 1;  // disable any-sync network and use only local p2p nodes
            CustomConfig = 2; // use config provided in networkConfigFilePath
        }

        message LocalLink {
            message NewChallenge {
                message Request {
                    option (no_auth) = true;
                    string appName = 1; // just for info, not secure to rely on
                    model.Account.Auth.LocalApiScope scope = 2;
                }

                message Response {
                    Error error = 1;
                    string challengeId = 2;
                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;

                            ACCOUNT_IS_NOT_RUNNING = 101;
                            TOO_MANY_REQUESTS = 102; // protection from overuse
                        }
                    }
                }
            }
            message SolveChallenge {
                message Request {
                    option (no_auth) = true;
                    string challengeId = 1;
                    string answer = 2;
                }

                message Response {
                    Error error = 1;
                    string sessionToken = 2; // ephemeral token for the session
                    string appKey = 3;  // persistent key, that can be used to restore session via CreateSession

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;

                            ACCOUNT_IS_NOT_RUNNING = 101;
                            INVALID_CHALLENGE_ID = 102;
                            CHALLENGE_ATTEMPTS_EXCEEDED = 103;
                            INCORRECT_ANSWER = 104;
                        }
                    }
                }
            }
            message ListApps {
                message Request {
                }

                message Response {
                    Error error = 1;
                    repeated model.Account.Auth.AppInfo app = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;

                            ACCOUNT_IS_NOT_RUNNING = 101;
                        }
                    }
                }
            }
            message CreateApp {
                message Request {
                    model.Account.Auth.AppInfo app = 1;
                }

                message Response {
                    Error error = 1;
                    string appKey = 2; // persistent key, that can be used to restore session via CreateSession or for JSON API

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;

                            ACCOUNT_IS_NOT_RUNNING = 101;
                        }
                    }
                }
            }
            message RevokeApp {
                message Request {
                    string appHash = 1;
                }

                message Response {
                    Error error = 1;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            NOT_FOUND = 3;

                            ACCOUNT_IS_NOT_RUNNING = 101;
                        }
                    }
                }
            }

        }

    }
    message Workspace {
        message GetCurrent {
            message Request {
            }
            message Response {
                Error error = 1;
                string workspaceId = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message GetAll {
            message Request {
            }

            message Response {
                Error error = 1;
                repeated string workspaceIds = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Create {
            message Request {
                google.protobuf.Struct details = 1; // object details
                anytype.Rpc.Object.ImportUseCase.Request.UseCase useCase = 2; // use case
                bool withChat = 3; // create space-level chat; temporary solution, should be removed after chats released for all users
            }

            message Response {
                Error error = 1;
                string spaceId = 2;
                string startingObjectId = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Open {
            message Request {
                string spaceId = 1;
                bool withChat = 2; // create space-level chat if not exists; temporary solution, should be removed after chats released for all users
            }

            message Response {
                Error error = 1;
                model.Account.Info info = 2;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        FAILED_TO_LOAD = 100;

                    }
                }
            }
        }

        message Object {
            message Add {
                message Request {
                    string spaceId = 2;
                    string objectId = 1;
                }

                message Response {
                    Error error = 1;
                    string objectId = 2;
                    google.protobuf.Struct details = 3;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
            message ListAdd {
                message Request {
                    string spaceId = 2;
                    repeated string objectIds = 1;
                }

                message Response {
                    Error error = 1;
                    repeated string objectIds = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
            message ListRemove {
                message Request {
                    repeated string objectIds = 1;
                }

                message Response {
                    Error error = 1;
                    repeated string ids = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
        }

        message SetInfo {
            message Request {
                string spaceId = 1;
                google.protobuf.Struct details = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Select {
            message Request {
                string workspaceId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Export {
            message Request {
                // the path where export files will place
                string path = 1;
                string workspaceId = 2;
            }
            message Response {
                Error error = 1;
                string path = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

    }
    message Publishing {
        enum PublishStatus {
            // PublishStatusCreated means publish is created but not uploaded yet
            PublishStatusCreated = 0;
            // PublishStatusCreated means publish is active
            PublishStatusPublished = 1;
        }
        message PublishState {
            string spaceId = 1;
            string objectId = 2;
            string uri = 3;
            PublishStatus status = 4;
            string version = 5;
            int64 timestamp = 6;
            int64 size = 7;
            bool joinSpace = 8;
            google.protobuf.Struct details = 9;
        }

        message Create {
            message Request {
                string spaceId = 1;
                string objectId = 2;
                string uri = 3;
                bool joinSpace = 4;
            }
            message Response {
                Error error = 1;
                string uri = 2;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NO_SUCH_OBJECT = 101;
                        NO_SUCH_SPACE = 102;
                        LIMIT_EXCEEDED = 103;
                    }
                }
            }
        }
        message Remove {
            message Request {
                string spaceId = 1;
                string objectId = 2;
            }
            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NO_SUCH_OBJECT = 101;
                        NO_SUCH_SPACE = 102;
                    }
                }
            }
        }
        message List {
            message Request {
                string spaceId = 1;
            }
            message Response {
                Error error = 1;
                repeated PublishState publishes = 2;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NO_SUCH_SPACE = 102;
                    }
                }
            }
        }
        message ResolveUri {
            message Request {
                string uri = 1;
            }
            message Response {
                Error error = 1;
                PublishState publish = 2;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NO_SUCH_URI = 101;
                    }
                }
            }
        }
        message GetStatus {
            message Request {
                string spaceId = 1;
                string objectId = 2;
            }
            message Response {
                Error error = 1;
                PublishState publish = 2;

                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NO_SUCH_OBJECT = 101;
                        NO_SUCH_SPACE = 102;
                    }
                }
            }
        }
    }

    message Object {
        message Open {
            message Request {
                string contextId = 1; // id of the context blo1k
                string objectId = 2;
                string traceId = 3;
                string spaceId = 5; // Required only for date objects

                bool includeRelationsAsDependentObjects = 4; // some clients may set this option instead if having the single subscription to all relations
            }

            message Response {
                Error error = 1;
                model.ObjectView objectView = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_FOUND = 3;
                        ANYTYPE_NEEDS_UPGRADE = 10; // failed to read unknown data format – need to upgrade anytype
                        OBJECT_DELETED = 4;
                        // ...
                    }
                }
            }
        }

        message Close {
            message Request {
                string contextId = 1; // deprecated, GO-1926
                string objectId = 2;
                string spaceId = 3; // Required only for date objects
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Show {
            message Request {
                string contextId = 1; // deprecated, GO-1926
                string objectId = 2;
                string traceId = 3;
                string spaceId = 5; // Required only for date objects

                bool includeRelationsAsDependentObjects = 4; // some clients may set this option instead if having the single subscription to all relations
            }

            message Response {
                Error error = 1;
                model.ObjectView objectView = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NOT_FOUND = 3;
                        OBJECT_DELETED = 4;
                        ANYTYPE_NEEDS_UPGRADE = 10; // failed to read unknown data format – need to upgrade anytype

                        // ...
                    }
                }
            }
        }

        message Create {
            message Request {
                google.protobuf.Struct details = 1; // object details
                repeated anytype.model.InternalFlag internalFlags = 2;
                string templateId = 3;
                string spaceId = 4;
                string objectTypeUniqueKey = 5;
                bool withChat = 6;
                bool createTypeWidgetIfMissing = 7; // experimental flag to auto-create type widget if missing
            }

            message Response {
                Error error = 1;
                string objectId = 3;
                ResponseEvent event = 4;
                google.protobuf.Struct details = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message CreateBookmark {
            message Request {
                google.protobuf.Struct details = 1;
                string spaceId = 2;
                bool withChat = 3;
                string templateId = 4;
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                google.protobuf.Struct details = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message CreateRelation {
            message Request {
                google.protobuf.Struct details = 1;
                string spaceId = 2;
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                string key = 3;
                google.protobuf.Struct details = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message CreateRelationOption {
            message Request {
                google.protobuf.Struct details = 1;
                string spaceId = 2;
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                google.protobuf.Struct details = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message CreateSet {
            message Request {
                repeated string source = 1;
                google.protobuf.Struct details = 2; // if omitted the name of page will be the same with object type
                string templateId = 3; // optional template id for creating from template
                repeated anytype.model.InternalFlag internalFlags = 4;
                string spaceId = 5;
                bool withChat = 6;
            }

            message Response {
                Error error = 1;
                string objectId = 3;
                ResponseEvent event = 4;
                google.protobuf.Struct details = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        UNKNOWN_OBJECT_TYPE_URL = 3;
                    }
                }
            }
        }

        message CreateObjectType {
            message Request {
                google.protobuf.Struct details = 1;
                repeated anytype.model.InternalFlag internalFlags = 2;
                string spaceId = 3;
            }

            message Response {
                Error error = 1;
                google.protobuf.Struct details = 2;
                string objectId = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message CreateFromUrl {
            message Request {
                string spaceId = 1;
                string objectTypeUniqueKey = 2;
                string url = 3;
                google.protobuf.Struct details = 4;
                bool addPageContent = 5;
                bool withChat = 6;
                string templateId = 7;
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                google.protobuf.Struct details = 3;
                string chatId = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ChatAdd {
            message Request {
                string objectId = 1;
            }

            message Response {
                Error error = 1;
                string chatId = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message BookmarkFetch {
            message Request {
                string contextId = 1;
                string url = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ToBookmark {
            message Request {
                string contextId = 1;
                string url = 2;
            }

            message Response {
                Error error = 1;
                string objectId = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Duplicate {
            message Request {
                string contextId = 1;
            }

            message Response {
                Error error = 1;
                // created template id
                string id = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message OpenBreadcrumbs {
            message Request {
                string contextId = 1; // deprecated, GO-1926
                string traceId = 2;
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                ResponseEvent event = 3;
                model.ObjectView objectView = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetBreadcrumbs {
            message Request {
                string breadcrumbsId = 1;
                repeated string ids = 2; // page ids
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ShareByLink {
            message Request {
                string objectId = 1;
            }

            message Response {
                string link = 1;
                Error error = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }


        // deprecated in favor of SearchWithMeta
        message Search {
            message Request {
                string spaceId = 8;
                repeated anytype.model.Block.Content.Dataview.Filter filters = 1;
                repeated anytype.model.Block.Content.Dataview.Sort sorts = 2;
                string fullText = 3;
                int32 offset = 4;
                int32 limit = 5;
                // additional filter by objectTypes
                repeated string objectTypeFilter = 6; // DEPRECATED, GO-1926
                // needed keys in details for return, when empty - will return all
                repeated string keys = 7;
            }

            message Response {
                Error error = 1;
                repeated google.protobuf.Struct records = 2;
                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message SearchWithMeta {
            message Request {
                string spaceId = 11;
                repeated anytype.model.Block.Content.Dataview.Filter filters = 1;
                repeated anytype.model.Block.Content.Dataview.Sort sorts = 2;
                string fullText = 3;
                int32 offset = 4;
                int32 limit = 5;
                // additional filter by objectTypes
                repeated string objectTypeFilter = 6; // DEPRECATED, GO-1926
                // needed keys in details for return, when empty - will return all
                repeated string keys = 7;
                bool returnMeta = 8; // add ResultMeta to each result
                bool returnMetaRelationDetails = 9; // add relation option details to meta
                bool returnHTMLHighlightsInsteadOfRanges = 10; //DEPRECATED
            }

            message Response {
                Error error = 1;
                repeated model.Search.Result results = 2;
                message Error {
                    Code code = 1;
                    string description = 2;
                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Graph {
            message Request {
                repeated anytype.model.Block.Content.Dataview.Filter filters = 1;
                int32 limit = 2;
                // additional filter by objectTypes
                repeated string objectTypeFilter = 3; // DEPRECATED, GO-1926
                repeated string keys = 4;
                string spaceId = 5;
                string collectionId = 6;
                repeated string setSource = 7;
            }

            message Edge {
                enum Type {
                    Link = 0;
                    Relation = 1;
                }
                string source = 1;
                string target = 2;
                string name = 3;
                Type type = 4;
                string description = 5;
                string iconImage = 6;
                string iconEmoji = 7;
                bool hidden = 8;
            }

            message Response {
                Error error = 1;
                repeated google.protobuf.Struct nodes = 2;
                repeated Edge edges = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SearchSubscribe {
            message Request {
                string spaceId = 15;
                // (optional) subscription identifier
                // client can provide some string or middleware will generate it automatically
                // if subId is already registered on middleware, the new query will replace previous subscription
                string subId = 1;
                // filters
                repeated anytype.model.Block.Content.Dataview.Filter filters = 2;
                // sorts
                repeated anytype.model.Block.Content.Dataview.Sort sorts = 3;
                // results limit
                int64 limit = 5;
                // initial offset; middleware will find afterId
                int64 offset = 6;
                // (required)  needed keys in details for return, for object fields mw will return (and subscribe) objects as dependent
                repeated string keys = 7;

                // (optional) pagination: middleware will return results after given id
                string afterId = 8;
                // (optional) pagination: middleware will return results before given id
                string beforeId = 9;

                repeated string source = 10;

                // disable dependent subscription
                bool noDepSubscription = 13;
                string collectionId = 14;
            }

            message Response {
                Error error = 1;

                repeated google.protobuf.Struct records = 2;
                repeated google.protobuf.Struct dependencies = 3;

                string subId = 4;

                Event.Object.Subscription.Counters counters = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message CrossSpaceSearchSubscribe {
            message Request {
                // (optional) subscription identifier
                // client can provide some string or middleware will generate it automatically
                // if subId is already registered on middleware, the new query will replace previous subscription
                string subId = 1;
                // filters
                repeated anytype.model.Block.Content.Dataview.Filter filters = 2;
                // sorts
                repeated anytype.model.Block.Content.Dataview.Sort sorts = 3;
                // (required)  needed keys in details for return, for object fields mw will return (and subscribe) objects as dependent
                repeated string keys = 7;

                repeated string source = 10;

                // disable dependent subscription
                bool noDepSubscription = 13;
                string collectionId = 14;
            }

            message Response {
                Error error = 1;

                repeated google.protobuf.Struct records = 2;
                repeated google.protobuf.Struct dependencies = 3;

                string subId = 4;

                Event.Object.Subscription.Counters counters = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message CrossSpaceSearchUnsubscribe {
            message Request {
                   string subId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message GroupsSubscribe {
            message Request {
                string spaceId = 6;
                string subId = 1;
                string relationKey = 2;
                repeated anytype.model.Block.Content.Dataview.Filter filters = 3;
                repeated string source = 4;
                string collectionId = 5;
            }

            message Response {
                Error error = 1;

                repeated anytype.model.Block.Content.Dataview.Group groups = 2;

                string subId = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SubscribeIds {
            message Request {
                string spaceId = 13;
                // (optional) subscription identifier
                // client can provide some string or middleware will generate it automatically
                // if subId is already registered on middleware, the new query will replace previous subscription
                string subId = 1;
                // ids for subscribe
                repeated string ids = 2;
                // sorts
                // (required)  needed keys in details for return, for object fields mw will return (and subscribe) objects as dependent
                repeated string keys = 3;

                // disable dependent subscription
                bool noDepSubscription = 12;
            }

            message Response {
                Error error = 1;

                repeated google.protobuf.Struct records = 2;
                repeated google.protobuf.Struct dependencies = 3;

                string subId = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SearchUnsubscribe {
            message Request {
                repeated string subIds = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetLayout {
            message Request {
                string contextId = 1;
                anytype.model.ObjectType.Layout layout = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetIsFavorite {
            message Request {
                string contextId = 1;
                bool isFavorite = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetIsArchived {
            message Request {
                string contextId = 1;
                bool isArchived = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetSource {

            message Request {
                string contextId = 1;
                repeated string source = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message WorkspaceSetDashboard {

            message Request {
                string contextId = 1;
                string objectId = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                string objectId = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetObjectType {
            message Request {
                string contextId = 1;
                string objectTypeUniqueKey = 3;
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetInternalFlags {
            message Request {
                string contextId = 1;
                repeated anytype.model.InternalFlag internalFlags = 7;

            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetDetails {
            message Request {
                string contextId = 1;
                repeated anytype.model.Detail details = 2;
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ToSet {
            message Request {
                string contextId = 1;
                repeated string source = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ToCollection {
            message Request {
                string contextId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        // Available undo/redo operations
        message UndoRedoCounter {
            int32 undo = 1;
            int32 redo = 2;
        }

        message Undo {
            message Request {
                string contextId = 1; // id of the context object
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                UndoRedoCounter counters = 3;
                string blockId = 4;
                anytype.model.Range range = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        CAN_NOT_MOVE = 3;
                        // ...
                    }
                }
            }
        }

        message Redo {
            message Request {
                string contextId = 1; // id of the context object
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                UndoRedoCounter counters = 3;
                string blockId = 4;
                anytype.model.Range range = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        CAN_NOT_MOVE = 3;
                        // ...
                    }
                }
            }
        }

        message ListDuplicate {
            message Request {
                repeated string objectIds = 1;
            }

            message Response {
                Error error = 1;
                repeated string ids = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListDelete {
            // Deletes the object, keys from the local store and unsubscribe from remote changes. Also offloads all orphan files
            message Request {
                repeated string objectIds = 1; // objects to remove
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetIsArchived {
            message Request {
                repeated string objectIds = 1;
                bool isArchived = 2;
            }
            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetIsFavorite {
            message Request {
                repeated string objectIds = 1;
                bool isFavorite = 2;
            }
            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetObjectType {
            message Request {
                repeated string objectIds = 1;
                string objectTypeUniqueKey = 2;
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message ListSetDetails {

            message Request {
                repeated string objectIds = 1;
                repeated anytype.model.Detail details = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListModifyDetailValues {
            message Request {
                repeated string objectIds = 1;
                repeated Operation operations = 2;

                message Operation {
                    string relationKey = 1;
                    google.protobuf.Value add = 2;
                    google.protobuf.Value set = 3;
                    google.protobuf.Value remove = 4;
                }
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message ApplyTemplate {
            message Request {
                string contextId = 1;
                // id of template
                string templateId = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListExport {
            message Request {
                string spaceId = 10;
                // the path where export files will place
                string path = 1;
                // ids of documents for export, when empty - will export all available docs
                repeated string objectIds = 2;
                // export format
                anytype.model.Export.Format format = 3;
                // save as zip file
                bool zip = 4;
                // include all nested
                bool includeNested = 5;
                // include all files
                bool includeFiles = 6;
                // for protobuf export
                bool isJson = 7;
                // for migration
                bool includeArchived = 9;
                // for integrations like raycast and web publishing
                bool noProgress = 11;
                StateFilters linksStateFilters = 12;
                bool includeBacklinks = 13;
                bool includeSpace = 14;
            }
            message StateFilters {
                repeated RelationsWhiteList relationsWhiteList = 1;
                bool removeBlocks = 2;
            }
            message RelationsWhiteList {
                anytype.model.ObjectType.Layout layout = 1;
                repeated string allowedRelations = 2;
            }
            message Response {
                Error error = 1;
                string path = 2;
                int32 succeed = 4;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }

        }

        message Export {
            message Request {
                string spaceId = 10;
                // ids of documents for export, when empty - will export all available docs
                string objectId = 2;
                // export format
                anytype.model.Export.Format format = 3;
            }

            message Response {
                Error error = 1;
                string result = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }

        }

        message Import {
            message Request {
                option (no_auth) = true;
                string spaceId = 14;
                oneof params {
                    NotionParams notionParams = 1;
                    BookmarksParams bookmarksParams = 2; //for internal use
                    MarkdownParams markdownParams = 3;
                    HtmlParams htmlParams = 4;
                    TxtParams txtParams = 5;
                    PbParams pbParams = 6;
                    CsvParams csvParams = 7;
                }
                repeated Snapshot snapshots = 8; // optional, for external developers usage
                bool updateExistingObjects = 9;
                anytype.model.Import.Type type = 10;
                Mode mode = 11;
                bool noProgress = 12;
                bool isMigration = 13;
                bool isNewSpace = 15;

                message NotionParams {
                    string apiKey = 1;
                }

                message MarkdownParams {
                    repeated string path = 1;
                }

                message BookmarksParams {
                    string url = 1;
                }

                message HtmlParams {
                    repeated string path = 1;
                }

                message TxtParams {
                    repeated string path = 1;
                }

                message PbParams {
                    repeated string path = 1;
                    bool noCollection = 2;
                    string collectionTitle = 3;
                    Type importType = 4;
                    enum Type {
                        SPACE = 0;
                        EXPERIENCE = 1;
                    };
                }

                message CsvParams {
                    repeated string path = 1;
                    Mode mode = 2;
                    bool useFirstRowForRelations = 3;
                    string delimiter = 4;
                    bool transposeRowsAndColumns = 5;
                    enum Mode {
                        COLLECTION = 0;
                        TABLE = 1;
                    };
                }

                enum Mode {
                    ALL_OR_NOTHING = 0;
                    IGNORE_ERRORS = 1;
                };

                message Snapshot {
                    string id = 1;
                    anytype.model.SmartBlockSnapshotBase snapshot = 2;
                };
            }

            message Response {
                Error error = 1; // deprecated
                string collectionId = 2; // deprecated
                int64 objectsCount = 3; // deprecated

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INTERNAL_ERROR = 3;
                        NO_OBJECTS_TO_IMPORT = 5;
                        IMPORT_IS_CANCELED = 6;
                        LIMIT_OF_ROWS_OR_RELATIONS_EXCEEDED = 7;
                        FILE_LOAD_ERROR = 8;
                        INSUFFICIENT_PERMISSIONS = 9;
                    }
                }
            }

            message Notion {
                message ValidateToken {
                    message Request {
                        string token = 1;
                    }

                    message Response {
                        Error error = 1;

                        message Error {
                            Code code = 1;
                            string description = 2;

                            enum Code {
                                NULL = 0;
                                UNKNOWN_ERROR = 1;
                                BAD_INPUT = 2;
                                INTERNAL_ERROR = 3;
                                UNAUTHORIZED = 4;
                                FORBIDDEN = 5;
                                SERVICE_UNAVAILABLE = 6;
                                ACCOUNT_IS_NOT_RUNNING = 7;
                            }
                        }
                    }
                }
            }

        }
        message ImportList {
            message Request {}

            message Response {
                Error error = 1;
                repeated ImportResponse response = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INTERNAL_ERROR = 3;
                    }
                }

            }
            message ImportResponse {
                Type type = 1;
                enum Type {
                    Notion = 0;
                    Markdown = 1;
                    Html = 2;
                    Txt = 3;
                };
            }
        }

        message ImportUseCase {
            message Request {
                string spaceId = 2;
                UseCase useCase = 1;

                enum UseCase {
                    NONE = 0;
                    GET_STARTED = 1;
                    EMPTY = 2;
                    GUIDE_ONLY = 3; // only the guide without other tables
                    GET_STARTED_MOBILE = 4;
                    EMPTY_MOBILE = 5;
                }
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                string startingObjectId = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message ImportExperience {
            message Request {
                string spaceId = 1;
                string url = 2;
                string title = 3;
                bool isNewSpace = 4;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INSUFFICIENT_PERMISSION = 3;
                    }
                }
            }
        }

        message DateByTimestamp {
            message Request {
                string spaceId = 1;
                int64 timestamp = 2;
            }

            message Response {
                Error error = 1;
                google.protobuf.Struct details = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message ObjectCollection {
        message Add {
            message Request {
                string contextId = 1;
                string afterId = 2;
                repeated string objectIds = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Remove {
            message Request {
                string contextId = 1;
                repeated string objectIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Sort {
            message Request {
                string contextId = 1;
                repeated string objectIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message ObjectRelation {
        message Add {
            message Request {
                string contextId = 1;
                repeated string relationKeys = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message Delete {
            message Request {
                string contextId = 1;
                repeated string relationKeys = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message ListAvailable {
            message Request {
                string contextId = 1;
            }
            message Response {
                Error error = 1;
                repeated anytype.model.Relation relations = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message AddFeatured {
            message Request {
                string contextId = 1;
                repeated string relations = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message RemoveFeatured {
            message Request {
                string contextId = 1;
                repeated string relations = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message ObjectType {
        message Relation {
            message Add {
                message Request {
                    string objectTypeUrl = 1;
                    repeated string relationKeys = 2;
                }

                message Response {
                    Error error = 1;
                    repeated anytype.model.Relation relations = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            READONLY_OBJECT_TYPE = 3;
                            // ...
                        }
                    }
                }
            }
            message Remove {
                message Request {
                    string objectTypeUrl = 1;
                    repeated string relationKeys = 2;
                }

                message Response {
                    Error error = 1;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            READONLY_OBJECT_TYPE = 3;
                            // ...
                        }
                    }
                }
            }
        }

        message Recommended {
            message RelationsSet {
                message Request {
                    string typeObjectId = 1;
                    repeated string relationObjectIds = 2;
                }

                message Response {
                    Error error = 1;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            READONLY_OBJECT_TYPE = 3;
                            // ...
                        }
                    }
                }
            }

            message FeaturedRelationsSet {
                message Request {
                    string typeObjectId = 1;
                    repeated string relationObjectIds = 2;
                }

                message Response {
                    Error error = 1;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            READONLY_OBJECT_TYPE = 3;
                            // ...
                        }
                    }
                }
            }
        }

        message ListConflictingRelations {
            message Request {
                string spaceId = 1;
                string typeObjectId = 2;
            }

            message Response {
                Error error = 1;
                repeated string relationIds = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        READONLY_OBJECT_TYPE = 3;
                    }
                }
            }
        }

        message ResolveLayoutConflicts {
            message Request {
                string typeObjectId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message Relation {
        message ListRemoveOption {
            message Request {
                repeated string optionIds = 1;
                bool checkInObjects = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        OPTION_USED_BY_OBJECTS = 3;
                    }
                }
            }
        }

        message Options {
            message Request {
                string relationKey = 1;
            }

            message Response {
                Error error = 1;
                model.RelationOptions options = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message ListWithValue {
            message Request {
                string spaceId = 1;
                google.protobuf.Value value = 2;
            }

            message Response {
                Error error = 1;
                repeated ResponseItem list = 2;

                message ResponseItem {
                    string relationKey = 1;
                    int64 counter = 2;
                }

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message History {
        message Version {
            string id = 1;
            repeated string previousIds = 2;
            string authorId = 3;
            string authorName = 4;
            int64 time = 5;
            int64 groupId = 6;
        }

        // returns list of versions (changes)
        message GetVersions {
            message Request {
                string objectId = 1;
                // when indicated, results will include versions before given id
                string lastVersionId = 2;
                // desired count of versions
                int32 limit = 3;
                bool notIncludeVersion = 4;
            }

            message Response {
                Error error = 1;
                repeated Version versions = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        // returns blockShow event for given version
        message ShowVersion {
            message Request {
                string objectId = 1;
                string versionId = 2;
                string traceId = 3;
            }

            message Response {
                Error error = 1;
                model.ObjectView objectView = 2;
                History.Version version = 3;
                string traceId = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetVersion {
            message Request {
                string objectId = 1;
                string versionId = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message DiffVersions {
            message Request {
                string objectId = 1;
                string spaceId = 2;
                string currentVersion = 3;
                string previousVersion = 4;
            }

            message Response {
                Error error = 1;
                repeated Event.Message historyEvents = 2;
                anytype.model.ObjectView objectView = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message File {
        message Reconcile {
            message Request {}

            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Offload {
            message Request {
                string id = 1;
                bool includeNotPinned = 2;
            }
            message Response {
                Error error = 1;
                uint64 bytesOffloaded = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                        NODE_NOT_STARTED = 103;

                    }
                }
            }
        }

        message SpaceOffload {
            message Request {
                string spaceId = 1;
            }
            message Response {
                Error error = 1;
                int32 filesOffloaded = 2;
                uint64 bytesOffloaded = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                        NODE_NOT_STARTED = 103;

                    }
                }
            }
        }

        message ListOffload {
            message Request {
                repeated string onlyIds = 1; // empty means all
                bool includeNotPinned = 2; // false mean not-yet-pinned files will be not
            }

            message Response {
                Error error = 1;
                int32 filesOffloaded = 2;
                uint64 bytesOffloaded = 3;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                        NODE_NOT_STARTED = 103;

                    }
                }
            }
        }
        message Upload {
            message Request {
                string spaceId = 6;
                string url = 1;
                string localPath = 2;
                anytype.model.Block.Content.File.Type type = 3;
                bool disableEncryption = 4; // deprecated, has no affect, GO-1926
                anytype.model.Block.Content.File.Style style = 5;
                google.protobuf.Struct details = 7; // additional details for file object
                anytype.model.ObjectOrigin origin = 8;
                anytype.model.ImageKind imageKind = 9;
                bool createTypeWidgetIfMissing = 10; // experimental flag to auto-create type widget if missing
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                google.protobuf.Struct details = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Download {
            message Request {
                string objectId = 1;
                string path = 2; // path to save file. Temp directory is used if empty
            }

            message Response {
                Error error = 1;
                string localPath = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Drop {
            message Request {
                string contextId = 1;
                string dropTargetId = 2; // id of the simple block to insert considering position
                anytype.model.Block.Position position = 3;  // position relatively to the dropTargetId simple block
                repeated string localFilePaths = 4;
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SpaceUsage {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;
                Usage usage = 2;

                message Usage {
                    uint64 filesCount = 1;
                    uint64 cidsCount = 2;
                    uint64 bytesUsage = 3;
                    uint64 bytesLeft = 4;
                    uint64 bytesLimit = 5;
                    uint64 localBytesUsage = 6;
                }

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message NodeUsage {
            message Request {}

            message Response {
                Error error = 1;
                Usage usage = 2;
                repeated Space spaces = 3;

                message Usage {
                    uint64 filesCount = 1;
                    uint64 cidsCount = 2;
                    uint64 bytesUsage = 3;
                    uint64 bytesLeft = 4;
                    uint64 bytesLimit = 5;
                    uint64 localBytesUsage = 6;
                }

                message Space {
                    string spaceId = 1;
                    uint64 filesCount = 2;
                    uint64 cidsCount = 3;
                    uint64 bytesUsage = 4;
                }

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message Navigation {
        enum Context {
            Navigation = 0;
            MoveTo = 1; // do not show sets/archive
            LinkTo = 2; // same for mention, do not show sets/archive
        }

        message ListObjects {
            message Request {
                Context context = 1;
                string fullText = 2;
                int32 limit = 3;
                int32 offset = 4;
            }

            message Response {
                Error error = 1;
                repeated anytype.model.ObjectInfo objects = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        /*
          * Get the info for page alongside with info for all inbound and outbound links from/to this page
        */
        message GetObjectInfoWithLinks {
            message Request {
                string objectId = 1;
                Context context = 2;
            }

            message Response {
                Error error = 1;
                anytype.model.ObjectInfoWithLinks object = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message Template {
        message CreateFromObject {
            message Request {
                // id of block for making them template
                string contextId = 1;
            }

            message Response {
                Error error = 1;
                // created template id
                string id = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message Clone {
            message Request {
                // id of template block for cloning
                string contextId = 1;
                string spaceId = 2;
            }

            message Response {
                Error error = 1;
                // created template id
                string id = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message ExportAll {
            message Request {
                // the path where export files will place
                string path = 1;
            }

            message Response {
                Error error = 1;
                string path = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message LinkPreview {
        message Request {
            string url = 1;
        }

        message Response {
            Error error = 1;
            anytype.model.LinkPreview linkPreview = 2;

            message Error {
                Code code = 1;
                string description = 2;

                enum Code {
                    NULL = 0;
                    UNKNOWN_ERROR = 1;
                    BAD_INPUT = 2;
                }
            }
        }
    }

    message Unsplash {
        message Search {
            message Request {
                string query = 1; // empty means random images
                int32 limit = 2; // may be omitted if the request was cached previously with another limit
            }

            message Response {
                Error error = 1;
                repeated Picture pictures = 2;

                message Picture {
                    string id = 1;
                    string url = 2;
                    string artist = 3;
                    string artistUrl = 4;
                }

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        RATE_LIMIT_EXCEEDED = 100;
                        // ...
                    }
                }
            }
        }

        message Download {
            message Request {
                string pictureId = 1;
                string spaceId = 2;
                anytype.model.ImageKind imageKind = 3;
            }

            message Response {
                Error error = 1;
                string objectId = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        RATE_LIMIT_EXCEEDED = 100;
                        // ...
                    }
                }
            }
        }
    }

    message AI {
        message WritingTools {
            message Request {
                ProviderConfig config = 1;
                WritingMode mode = 2;
                Language language = 3;
                string text = 4;

                enum WritingMode {
                    DEFAULT = 0;
                    SUMMARIZE = 1;
                    GRAMMAR = 2;
                    SHORTEN = 3;
                    EXPAND = 4;
                    BULLET = 5;
                    TABLE = 6;
                    CASUAL = 7;
                    FUNNY = 8;
                    CONFIDENT = 9;
                    STRAIGHTFORWARD = 10;
                    PROFESSIONAL = 11;
                    TRANSLATE = 12;
                    // ...
                }

                enum Language {
                    EN = 0;
                    ES = 1;
                    FR = 2;
                    DE = 3;
                    IT = 4;
                    PT = 5;
                    HI = 6;
                    TH = 7;
                    // ...
                }
            }

            message Response {
                Error error = 1;
                string text = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        RATE_LIMIT_EXCEEDED = 100;
                        ENDPOINT_NOT_REACHABLE = 101;
                        MODEL_NOT_FOUND = 102;
                        AUTH_REQUIRED = 103;
                        LANGUAGE_NOT_SUPPORTED = 104;
                        // ...
                    }
                }
            }
        }

        message Autofill {
            message Request {
                ProviderConfig config = 1;
                AutofillMode mode = 2;
                repeated string options = 3;
                repeated string context = 4;

                enum AutofillMode {
                    TAG = 0;
                    RELATION = 1;
                    TYPE = 2;
                    TITLE = 3;
                    DESCRIPTION = 4;
                    // ...
                }
            }

            message Response {
                Error error = 1;
                string text = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        RATE_LIMIT_EXCEEDED = 100;
                        ENDPOINT_NOT_REACHABLE = 101;
                        MODEL_NOT_FOUND = 102;
                        AUTH_REQUIRED = 103;
                        // ...
                    }
                }
            }
        }

        message ListSummary {
            message Request {
                ProviderConfig config = 1;
                string spaceId = 2;
                repeated string objectIds = 3;
                string prompt = 4;
            }

            message Response {
                Error error = 1;
                string objectId = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        RATE_LIMIT_EXCEEDED = 100;
                        ENDPOINT_NOT_REACHABLE = 101;
                        MODEL_NOT_FOUND = 102;
                        AUTH_REQUIRED = 103;
                        // ...
                    }
                }
            }
        }

        message ObjectCreateFromUrl {
            message Request {
                ProviderConfig config = 1;
                string spaceId = 2;
                string url = 3;
                google.protobuf.Struct details = 4;
            }

            message Response {
                Error error = 1;
                string objectId = 2;
                google.protobuf.Struct details = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        RATE_LIMIT_EXCEEDED = 100;
                        ENDPOINT_NOT_REACHABLE = 101;
                        MODEL_NOT_FOUND = 102;
                        AUTH_REQUIRED = 103;
                        // ...
                    }
                }
            }
        }

        message ProviderConfig {
            Provider provider = 1;
            string endpoint = 2;
            string model = 3;
            string token = 4;
            float temperature = 5;
        }

        enum Provider {
            OLLAMA = 0;
            OPENAI = 1;
            LMSTUDIO = 2;
            LLAMACPP = 3;
            // ...
        }
    }

    message Gallery {
        message DownloadManifest {
            message Request {
                string url = 1;
            }

            message Response {
                Error error = 1;
                anytype.model.ManifestInfo info = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message DownloadIndex {
            message Request {
            }

            message Response {
                Error error = 1;
                repeated Category categories = 2;
                repeated anytype.model.ManifestInfo experiences = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        UNMARSHALLING_ERROR = 3;
                        DOWNLOAD_ERROR = 4;
                    }
                }

                message Category {
                    string id = 1;
                    repeated string experiences = 2;
                    string icon = 3;
                }
            }
        }
    }

    // Block commands
    message Block {
        message Replace {
            message Request {
                string contextId = 1;
                string blockId = 2;
                anytype.model.Block block = 3;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Split {
            message Request {
                string contextId = 1;
                string blockId = 2;
                anytype.model.Range range = 3;
                anytype.model.Block.Content.Text.Style style = 4;
                Mode mode = 5;

                enum Mode {
                    // new block will be created under existing
                    BOTTOM = 0;
                    // new block will be created above existing
                    TOP = 1;
                    // new block will be created as the first children of existing
                    INNER = 2;
                    // new block will be created after header (not required for set at client side, will auto set for title block)
                    TITLE = 3;
                }
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Merge {
            message Request {
                string contextId = 1;
                string firstBlockId = 2;
                string secondBlockId = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Copy {
            message Request {
                string contextId = 1;
                repeated anytype.model.Block blocks = 2;
                anytype.model.Range selectedTextRange = 3;
            }

            message Response {
                Error error = 1;
                string textSlot = 2;
                string htmlSlot = 3;
                repeated anytype.model.Block anySlot = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Paste {
            message Request {
                string contextId = 1;
                string focusedBlockId = 2;
                anytype.model.Range selectedTextRange = 3;
                repeated string selectedBlockIds = 4;
                bool isPartOfBlock = 5;

                string textSlot = 6;
                string htmlSlot = 7;
                repeated anytype.model.Block anySlot = 8;
                repeated File fileSlot = 9;
                string url = 10;

                message File {
                    string name = 1;
                    bytes data = 2;
                    string localPath = 3;
                }
            }

            message Response {
                Error error = 1;
                repeated string blockIds = 2;
                int32 caretPosition = 3;
                bool isSameBlockCaret = 4;
                ResponseEvent event = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Cut {
            message Request {
                string contextId = 1;
                repeated anytype.model.Block blocks = 2;
                anytype.model.Range selectedTextRange = 3;
            }

            message Response {
                Error error = 1;
                string textSlot = 2;
                string htmlSlot = 3;
                repeated anytype.model.Block anySlot = 4;
                ResponseEvent event = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Upload {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string filePath = 3;
                string url = 4;
                bytes bytes = 5;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Download {
            message Request {
                string contextId = 1;
                string blockId = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        /*
         * Create a Smart/Internal block. Request can contain a block with a content, or it can be an empty block with a specific block.content.
         * **Example scenario**
         * 1A. Create Page on a dashboard
         *     1. Front -> MW: Rpc.Block.Create.Request(blockId:dashboard.id, position:bottom, block: emtpy block with page content and id = "")
         *     2. Front -> MW: Rpc.Block.Close.Request(block: dashboard.id)
         *     3. Front <- MW: Rpc.Block.Close.Response(err)
         *     4. Front <- MW: Rpc.Block.Create.Response(page.id)
         *     5. Front <- MW: Rpc.Block.Open.Response(err)
         *     6. Front <- MW: Event.Block.Show(page)
         * 1B. Create Page on a Page
         *     1. Front -> MW: Rpc.Block.Create.Request(blockId:dashboard.id, position:bottom, block: emtpy block with page content and id = "")
         *     2. Front <- MW: Rpc.Block.Create.Response(newPage.id)
         *     3. Front <- MW: Event.Block.Show(newPage)
        */
        message Create {
            // common simple block command
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest block
                anytype.model.Block block = 3;
                anytype.model.Block.Position position = 4;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message CreateWidget {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest block
                anytype.model.Block block = 3;
                anytype.model.Block.Position position = 4;
                anytype.model.Block.Content.Widget.Layout widgetLayout = 5;
                int32 objectLimit = 6;
                string viewId = 7;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        /*
         * Remove blocks from the childrenIds of its parents
        */
        message ListDelete {
            message Request {
                string contextId = 1; // id of the context object
                repeated string blockIds = 2; // targets to remove

            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetFields {
            message Request {
                string contextId = 1;
                string blockId = 2;
                google.protobuf.Struct fields = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetAlign {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2; // when empty - align will be applied as layoutAlign
                anytype.model.Block.Align align = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetVerticalAlign {
            message Request {
                string contextId = 1; // id of the context object
                repeated string blockIds = 2;
                anytype.model.Block.VerticalAlign verticalAlign = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetFields {
            message Request {
                string contextId = 1;
                repeated BlockField blockFields = 2;

                message BlockField {
                    string blockId = 1;
                    google.protobuf.Struct fields = 2;
                }
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        /*
       * Makes blocks copy by given ids and paste it to shown place
      */
        message ListDuplicate {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest block
                repeated string blockIds = 3; // id of block for duplicate
                anytype.model.Block.Position position = 4;
                string targetContextId = 5;
            }

            message Response {
                Error error = 1;
                repeated string blockIds = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListUpdate {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                oneof field {
                    Text text = 3;
                    string backgroundColor = 4;
                    anytype.model.Block.Align align = 5;
                    google.protobuf.Struct fields = 6;
                    anytype.model.Block.Content.Div.Style divStyle = 7;
                    model.Block.Content.File.Style fileStyle = 8;
                }
                message Text {
                    oneof field {
                        anytype.model.Block.Content.Text.Style style = 1;
                        string color = 2;
                        anytype.model.Block.Content.Text.Mark mark = 3;
                    }
                }
            }
        }

        message ListConvertToObjects {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                string objectTypeUniqueKey = 3;
                string templateId = 4;
                anytype.model.Block block = 5;
            }

            message Response {
                Error error = 1;
                repeated string linkIds = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListMoveToExistingObject {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                string targetContextId = 3;
                string dropTargetId = 4; // id of the simple block to insert considering position
                anytype.model.Block.Position position = 5; // position relatively to the dropTargetId simple block
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListMoveToNewObject {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                google.protobuf.Struct details = 3; // new object details
                string dropTargetId = 4; // id of the simple block to insert considering position
                anytype.model.Block.Position position = 5; // position relatively to the dropTargetId simple block
            }

            message Response {
                Error error = 1;
                string linkId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListTurnInto {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                anytype.model.Block.Content.Text.Style style = 3;
            }
            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetBackgroundColor {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                string color = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Export {
            message Request {
                string contextId = 1;
                repeated anytype.model.Block blocks = 2;
            }

            message Response {
                Error error = 1;
                string path = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetCarriage {
            message Request {
                string contextId = 1;
                string blockId = 2;
                anytype.model.Range range = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Preview {
            message Request {
                string html = 1;
                string url = 2;
            }

            message Response {
                Error error = 1;
                repeated anytype.model.Block blocks = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message BlockLatex {
        message SetText {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string text = 3;
                model.Block.Content.Latex.Processor processor = 4;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message SetProcessor {
            message Request {
                string contextId = 1;
                string blockId = 2;
                model.Block.Content.Latex.Processor processor = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

    }

    message BlockText {
        message SetText {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string text = 3;
                anytype.model.Block.Content.Text.Marks marks = 4;
                anytype.model.Range selectedTextRange = 5;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetColor {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string color = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetMarks {
            /*
            * Get marks list in the selected range in text block.
           */
            message Get {
                message Request {
                    string contextId = 1;
                    string blockId = 2;
                    anytype.model.Range range = 3;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
        }

        message SetStyle {
            message Request {
                string contextId = 1;
                string blockId = 2;
                anytype.model.Block.Content.Text.Style style = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetChecked {
            message Request {
                string contextId = 1;
                string blockId = 2;
                bool checked = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetIcon {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string iconImage = 3; // in case both image and emoji are set, image has a priority to show
                string iconEmoji = 5;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetStyle {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                anytype.model.Block.Content.Text.Style style = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetColor {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                string color = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListSetMark {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                anytype.model.Block.Content.Text.Mark mark = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListClearStyle {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ListClearContent {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockTable {
        message Create {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest block
                anytype.model.Block.Position position = 3;
                uint32 rows = 4;
                uint32 columns = 5;
                bool withHeaderRow = 6;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message RowCreate {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest row
                anytype.model.Block.Position position = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message RowSetHeader {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2;
                bool isHeader = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message RowListFill {
            message Request {
                string contextId = 1; // id of the context object
                repeated string blockIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message RowListClean {
            message Request {
                string contextId = 1; // id of the context object
                repeated string blockIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ColumnListFill {
            message Request {
                string contextId = 1; // id of the context object
                repeated string blockIds = 2;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ColumnCreate {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest column
                anytype.model.Block.Position position = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message RowDelete {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest row
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message ColumnDelete {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2; // id of the closest column
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ColumnMove {
            message Request {
                string contextId = 1;
                string targetId = 2;
                string dropTargetId = 3;
                anytype.model.Block.Position position = 4;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message RowDuplicate {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2;
                string blockId = 3; // block to duplicate
                anytype.model.Block.Position position = 4;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ColumnDuplicate {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2;
                string blockId = 3; // block to duplicate
                anytype.model.Block.Position position = 4;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Expand {
            message Request {
                string contextId = 1; // id of the context object
                string targetId = 2;
                uint32 columns = 3; // number of columns to append
                uint32 rows = 4; // number of rows to append
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Sort {
            message Request {
                string contextId = 1; // id of the context object
                string columnId = 2;
                anytype.model.Block.Content.Dataview.Sort.Type type = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockFile {
        message SetName {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string name = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetTargetObjectId {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string objectId = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message CreateAndUpload {
            message Request {
                string contextId = 1;
                string targetId = 2;
                anytype.model.Block.Position position = 3;
                string url = 4;
                string localPath = 5;
                anytype.model.Block.Content.File.Type fileType = 6;
                anytype.model.ImageKind imageKind = 7;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message ListSetStyle {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                model.Block.Content.File.Style style = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockImage {
        message SetName {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string name = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetWidth {
            message Request {
                string contextId = 1;
                string blockId = 2;
                int32 width = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockVideo {
        message SetName {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string name = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SetWidth {
            message Request {
                string contextId = 1;
                string blockId = 2;
                int32 width = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockLink {
        message CreateWithObject {
            message Request {
                string contextId = 1; // id of the context object
                google.protobuf.Struct details = 3; // new object details
                string templateId = 5; // optional template id for creating from template
                repeated anytype.model.InternalFlag internalFlags = 7;
                string spaceId = 8;
                string objectTypeUniqueKey = 9;
                anytype.model.Block block = 10;

                // link block params
                string targetId = 2; // id of the closest simple block
                anytype.model.Block.Position position = 4;
                google.protobuf.Struct fields = 6; // deprecated link block fields

            }

            message Response {
                Error error = 1;
                string blockId = 2;
                string targetId = 3;
                ResponseEvent event = 4;
                google.protobuf.Struct details = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message ListSetAppearance {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                anytype.model.Block.Content.Link.IconSize iconSize = 4;
                anytype.model.Block.Content.Link.CardStyle cardStyle = 5;
                anytype.model.Block.Content.Link.Description description = 6;
                repeated string relations = 7;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockRelation {
        message SetKey {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string key = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Add {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string relationKey = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message BlockBookmark {
        message Fetch {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string url = 3;
                string templateId = 4;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message CreateAndFetch {
            message Request {
                string contextId = 1;
                string targetId = 2;
                anytype.model.Block.Position position = 3;
                string url = 4;
                string templateId = 5;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message BlockDiv {
        message ListSetStyle {
            message Request {
                string contextId = 1;
                repeated string blockIds = 2;
                anytype.model.Block.Content.Div.Style style = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message BlockDataview {
        message View {
            message Create {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to insert the new block
                    anytype.model.Block.Content.Dataview.View view = 4;
                    repeated string source = 5;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;
                    string viewId = 3;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
            message Update {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    anytype.model.Block.Content.Dataview.View view = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
            message Delete {
                message Request {
                    string contextId = 1; // id of the context object
                    string blockId = 2; // id of the dataview
                    string viewId = 4; // id of the view to remove
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
            message SetPosition {
                message Request {
                    string contextId = 1; // id of the context object
                    string blockId = 2; // id of the dataview
                    string viewId = 4; // id of the view to remove
                    uint32 position = 5; // index of view position (0 - means first)
                }
                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            // ...
                        }
                    }
                }
            }
            // set the current active view locally
            message SetActive {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block
                    string viewId = 3; // id of active view
                }
                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }
        message Relation {
            message Set {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to set relation
                    repeated string relationKeys = 3;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Add {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to add relation
                    repeated string relationKeys = 3;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Delete {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to add relation
                    repeated string relationKeys = 3;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 3;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }
        message SetSource {
            message Request {
                string contextId = 1;
                string blockId = 2;
                repeated string source = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message GroupOrder {
            message Update {
                message Request {
                    string contextId = 1;
                    string blockId = 2;
                    anytype.model.Block.Content.Dataview.GroupOrder groupOrder = 3;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }
        message ObjectOrder {
            message Update {
                message Request {
                    string contextId = 1;
                    string blockId = 2;
                    repeated anytype.model.Block.Content.Dataview.ObjectOrder objectOrders = 3;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Move {
                message Request {
                    string contextId = 1;
                    string blockId = 2;
                    string viewId = 3;
                    string groupId = 4;
                    string afterId = 5;
                    repeated string objectIds = 6;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }

        message CreateFromExistingObject {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string targetObjectId = 3;
            }

            message Response {
                Error error = 1;
                string blockId = 2;
                string targetObjectId = 3;
                repeated anytype.model.Block.Content.Dataview.View view = 4;
                ResponseEvent event = 5;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Filter {
            message Add {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    anytype.model.Block.Content.Dataview.Filter filter = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Remove {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    repeated string ids = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Replace {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    string id = 4;
                    anytype.model.Block.Content.Dataview.Filter filter = 5;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Sort {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    repeated string ids = 4; // new order of filters
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }
        message Sort {
            message Add {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    anytype.model.Block.Content.Dataview.Sort sort = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Remove {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    repeated string ids = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Replace {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    string id = 4;
                    anytype.model.Block.Content.Dataview.Sort sort = 5;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message SSort {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    repeated string ids = 4; // new order of sorts
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }
        message ViewRelation {
            message Add {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    anytype.model.Block.Content.Dataview.Relation relation = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Remove {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    repeated string relationKeys = 4;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Replace {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    string relationKey = 4;
                    anytype.model.Block.Content.Dataview.Relation relation = 5;
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }

            message Sort {
                message Request {
                    string contextId = 1;
                    string blockId = 2; // id of dataview block to update
                    string viewId = 3; // id of view to update
                    repeated string relationKeys = 4; // new order of relations
                }

                message Response {
                    Error error = 1;
                    ResponseEvent event = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                        }
                    }
                }
            }
        }
    }

    message BlockWidget {
        message SetTargetId {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string targetId = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetLayout {
            message Request {
                string contextId = 1;
                string blockId = 2;
                anytype.model.Block.Content.Widget.Layout layout = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetLimit {
            message Request {
                string contextId = 1;
                string blockId = 2;
                int32 limit = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message SetViewId {
            message Request {
                string contextId = 1;
                string blockId = 2;
                string viewId = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

    }

    message Debug {

        message TreeInfo {
            string treeId = 1;
            repeated string headIds = 2;
        }

        message Stat {
            message Request {
            }

            message Response {
                Error error = 1;
                string jsonStat = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message TreeHeads {
            message Request {
                string treeId = 1;
            }

            message Response {
                Error error = 1;
                string spaceId = 2;
                TreeInfo info = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Tree {
            message Request {
                string treeId = 1;
                string path = 2;
                bool unanonymized = 3; // set to true to disable mocking of the actual data inside changes
                bool generateSvg = 4; // set to true to write both ZIP and SVG files
            }

            message Response {
                Error error = 1;
                string filename = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SpaceSummary {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;
                string spaceId = 2;
                repeated TreeInfo infos = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message StackGoroutines {
            message Request {
                string path = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ExportLocalstore {
            message Request {
                // the path where export files will place
                string path = 1;
                // ids of documents for export, when empty - will export all available docs
                repeated string docIds = 2;
                string spaceId = 3;
            }

            message Response {
                Error error = 1;
                string path = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Subscriptions {
            message Request {}

            message Response {
                Error error = 1;
                repeated string subscriptions = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message OpenedObjects {
            message Request {}

            message Response {
                Error error = 1;
                repeated string objectIDs = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message RunProfiler {
            message Request {
                option (no_auth) = true;
                int32 durationInSeconds = 1;
            }

            message Response {
                Error error = 1;
                string path = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message AccountSelectTrace {
            message Request {
                option (no_auth) = true;
                string dir = 1; // empty means using OS-provided temp dir
            }

            message Response {
                Error error = 1;
                string path = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message ExportLog {
            message Request {
                option (no_auth) = true;
                string dir = 1; // empty means using OS-provided temp dir
            }

            message Response {
                Error error = 1;
                string path = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        NO_FOLDER = 3;
                    }
                }
            }
        }

        message Ping {
            message Request {
                int32 index = 1;
                int32 numberOfEventsToSend = 2;
            }

            message Response {
                Error error = 1;
                int32 index = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message AnystoreObjectChanges {
            message Request {
                string objectId = 1;
                OrderBy orderBy = 2;

                enum OrderBy {
                    ORDER_ID = 0;
                    ITERATION_ORDER = 1;
                }
            }

            message Response {
                Error error = 1;
                repeated Change changes = 2;
                bool wrongOrder = 3;

                message Change {
                    string changeId = 1;
                    string orderId = 2;
                    string error = 3;
                    google.protobuf.Struct change = 4;
                }

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message NetCheck {
            message Request {
                string clientYml = 1;
            }

            message Response {
                Error error = 1;
                string result = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message Initial {
        message SetParameters {
            message Request {
                option (no_auth) = true;
                string platform = 1;
                string version = 2;
                string workdir = 3;
                string logLevel = 4;
                bool doNotSendLogs = 5;
                bool doNotSaveLogs = 6;
                bool doNotSendTelemetry = 7;
            }

            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
    }

    message Log {
        message Send {
            message Request {
                string message = 1;
                Level level = 2;

                enum Level {
                    DEBUG = 0;
                    ERROR = 1;
                    FATAL = 2;
                    INFO = 3;
                    PANIC = 4;
                    WARNING = 5;
                }
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message Process {
        message Cancel {
            message Request {
                string id = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Subscribe {
            message Request {}

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message Unsubscribe {
            message Request {}

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }

    message GenericErrorResponse {
        Error error = 1;
        message Error {
            Code code = 1;
            string description = 2;

            enum Code {
                NULL = 0;
                UNKNOWN_ERROR = 1;
                BAD_INPUT = 2;
                // ...
            }
        }
    }

    message Notification {
        message List {
            message Request {
                bool includeRead = 1;
                int64 limit = 2;
            }
            message Response {
                Error error = 1;
                repeated anytype.model.Notification notifications = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INTERNAL_ERROR = 3;
                    }
                }
            }
        }

        message Reply {
            message Request {
                repeated string ids = 1;
                anytype.model.Notification.ActionType actionType = 2;
            }
            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INTERNAL_ERROR = 3;
                    }
                }
            }
        }

        message Test {
            message Request {}
            message Response {
                Error error = 1;
                anytype.model.Notification notification = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INTERNAL_ERROR = 3;
                    }
                }
            }
        }
    }

    /**
    * A Membership is a bundle of several "Features"
    * every user should have one and only one tier
    * users can not have N tiers (no combining)
    */
    message Membership {
        /**
        * Get the current status of the membership
        * including the tier, status, dates, etc
        * WARNING: this can be cached by Anytype heart
        */
        message GetStatus {
            message Request {
                // pass true to force the cache update
                // by default this is false
                bool noCache = 1;
            }

            message Response {
                Error error = 1;

                anytype.model.Membership data = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;

                        MEMBERSHIP_NOT_FOUND = 6;
                        MEMBERSHIP_WRONG_STATE = 7;
                        CAN_NOT_CONNECT = 8;
                    }
                }
            }
        }

        /**
        * Check if the requested name is valid and vacant for the requested tier
        * before requesting a payment link and paying
        */
        message IsNameValid {
            message Request {
                uint32 requestedTier = 1;

                string nsName = 2;

                anytype.model.NameserviceNameType nsNameType = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        TOO_SHORT = 3;
                        TOO_LONG = 4;
                        HAS_INVALID_CHARS = 5;
                        TIER_FEATURES_NO_NAME = 6;
                        // if everything is fine - "name is already taken" check should be done in the NS
                        // see IsNameAvailable()
                        TIER_NOT_FOUND = 7;

                        NOT_LOGGED_IN = 8;
                        PAYMENT_NODE_ERROR = 9;
                        CACHE_ERROR = 10;
                        // for some probable future use (if needed)
                        CAN_NOT_RESERVE = 11;
                        CAN_NOT_CONNECT = 12;
                        // Same as if NameService.ResolveName returned that name is already
                        // occupied by some user
                        NAME_IS_RESERVED = 13;
                    }
                }
            }
        }

        /**
        * Generate a unique id for payment request (for mobile clients)
        * Generate a link to Stripe/Crypto where user can pay for the membership (for desktop client)
        */
        message RegisterPaymentRequest {
            message Request {
                uint32 requestedTier = 1;

                anytype.model.Membership.PaymentMethod paymentMethod = 2;

                // if empty - then no name requested
                // if non-empty - PP node will register that name on behalf of the user
                string nsName = 3;

                anytype.model.NameserviceNameType nsNameType = 4;

                // for some tiers and payment methods (like crypto) we need an e-mail
                // please get if either from:
                // 1. Membership.GetStatus() -> anytype.model.Membership.userEmail field
                // 2. Ask user from the UI
                string userEmail = 5;
            }

            message Response {
                Error error = 1;

                // will feature current billing ID
                // stripe.com/?client_reference_id=1234
                string paymentUrl = 2;
                // billingID is only needed for mobile clients
                string billingId = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;

                        TIER_NOT_FOUND = 6;
                        TIER_INVALID = 7;
                        PAYMENT_METHOD_INVALID = 8;
                        BAD_ANYNAME = 9;
                        MEMBERSHIP_ALREADY_EXISTS = 10;
                        CAN_NOT_CONNECT = 11;
                        // for tiers and payment methods that require that
                        EMAIL_WRONG_FORMAT = 12;
                    }
                }
            }
        }

        /**
        * Generate a link to the portal where user can:
        * a) change his billing details
        * b) see payment info, invoices, etc
        * c) cancel membership
        */
        message GetPortalLinkUrl {
            message Request {

            }

            message Response {
                Error error = 1;

                string portalUrl = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;
                        CAN_NOT_CONNECT = 6;
                    }
                }
            }
        }

        message Finalize {
            message Request {
                // if empty - then no name requested
                // if non-empty - PP node will register that name on behalf of the user
                string nsName = 1;

                anytype.model.NameserviceNameType nsNameType = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;

                        MEMBERSHIP_NOT_FOUND = 6;
                        MEMBERSHIP_WRONG_STATE = 7;

                        BAD_ANYNAME = 8;

                        CAN_NOT_CONNECT = 9;
                    }
                }
            }
        }

        /**
        * Get the current status of the e-mail verification.
        * Status can change if you call GetVerificationEmail or VerifyEmailCode
        */
        message GetVerificationEmailStatus {
            message Request {
            }

            message Response {
                Error error = 1;

                anytype.model.Membership.EmailVerificationStatus status = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CAN_NOT_CONNECT = 12;
                    }
                }
            }
        }

        /**
        * Send an e-mail with verification code to the user
        * can be called multiple times but with some timeout (N seconds) between calls
        */
        message GetVerificationEmail {
            message Request {
                string email = 1;

                bool subscribeToNewsletter = 2;

                bool insiderTipsAndTutorials = 3;

                // if we are coming from the onboarding list
                bool isOnboardingList = 4;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;

                        EMAIL_WRONG_FORMAT = 6;
                        EMAIL_ALREADY_VERIFIED = 7;
                        EMAIL_ALREDY_SENT = 8;
                        EMAIL_FAILED_TO_SEND = 9;

                        MEMBERSHIP_ALREADY_EXISTS = 10;
                        CAN_NOT_CONNECT = 11;
                    }
                }
            }
        }

        /**
        * Verify the e-mail address of the user
        * need a correct code that was sent to the user when calling GetVerificationEmail
        */
        message VerifyEmailCode {
            message Request {
                string code = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;

                        EMAIL_ALREADY_VERIFIED = 6;
                        CODE_EXPIRED = 7;
                        CODE_WRONG = 8;

                        MEMBERSHIP_NOT_FOUND = 9;
                        MEMBERSHIP_ALREADY_ACTIVE = 10;
                        CAN_NOT_CONNECT = 11;
                    }
                }
            }
        }

        /**
        * Tiers can change on the backend so if you want to show users the latest data
        * you can call this method to get the latest tiers
        */
        message GetTiers {
            message Request {
                // pass true to force the cache update
                // by default this is false
                bool noCache = 1;

                string locale = 2;
            }

            message Response {
                Error error = 1;
                repeated anytype.model.MembershipTierData tiers = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;
                        CAN_NOT_CONNECT = 6;
                    }
                }
            }
        }

        message VerifyAppStoreReceipt {
            message Request {
                // receipt is a JWT-encoded string including info about subscription purchase
                string receipt = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        NOT_LOGGED_IN = 3;
                        PAYMENT_NODE_ERROR = 4;
                        CACHE_ERROR = 5;
                        INVALID_RECEIPT = 6;
                        PURCHASE_REGISTRATION_ERROR = 7;
                        SUBSCRIPTION_RENEW_ERROR = 8;
                    }
                }
            }
        }
    }

    message NameService {
        message ResolveName {
            message Request {
                string nsName = 1;

                anytype.model.NameserviceNameType nsNameType = 2;
            }

            message Response {
                Error error = 1;

                bool available = 2;

                // EOA -> SCW -> name
                // This field is non-empty only if name is "already registered"
                string ownerScwEthAddress = 3;

                // This field is non-empty only if name is "already registered"
                string ownerEthAddress = 4;

                // A content hash attached to this name
                // This field is non-empty only if name is "already registered"
                string ownerAnyAddress = 5;

                // A SpaceId attached to this name
                // This field is non-empty only if name is "already registered"
                string spaceId = 6;

                // A timestamp when this name expires
                int64 nameExpires = 7;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        CAN_NOT_CONNECT = 3;
                    }
                }
            }
        }

        message ResolveAnyId {
            message Request {
                string anyId = 1;
            }

            message Response {
                Error error = 1;

                bool found = 2;

                // not including suffix
                string nsName = 3;

                anytype.model.NameserviceNameType nsNameType = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        CAN_NOT_CONNECT = 3;
                    }
                }
            }
        }

        message ResolveSpaceId {
            message Request {
                string spaceId = 1;
            }

            message Response {
                Error error = 1;

                bool found = 2;

                // not including suffix
                string nsName = 3;

                anytype.model.NameserviceNameType nsNameType = 4;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        CAN_NOT_CONNECT = 3;
                    }
                }
            }
        }

        message UserAccount {
            message Get {
                message Request {

                }

                message Response {
                    Error error = 1;

                    // this will use ReverseResolve to get current name
                    // user can buy many names, but
                    // only 1 name can be set as "current": ETH address <-> name
                    string nsNameAttached = 2;

                    anytype.model.NameserviceNameType nsNameType = 3;

                    // Number of names that the user can reserve
                    uint64 namesCountLeft = 4;

                    // Number of operations: update name, add new data, etc
                    uint64 operationsCountLeft = 5;

                    // TODO: all operations list

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            NOT_LOGGED_IN = 3;
                            BAD_NAME_RESOLVE = 4;
                            CAN_NOT_CONNECT = 5;
                        }
                    }
                }
            }
        }
    }

    message Broadcast {
        message PayloadEvent {
            message Request {
                string payload = 1;
            }
            message Response {
                ResponseEvent event = 1;
                Error error = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        INTERNAL_ERROR = 3;
                    }
                }
            }
        }
    }

    message Device {
        message SetName {
            message Request {
                string deviceId = 1;
                string name = 2;
            }
            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }

        message List {
            message Request {}
            message Response {
                Error error = 1;
                repeated anytype.model.DeviceInfo devices = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
        message NetworkState {
            message Set {
                message Request {
                    anytype.model.DeviceNetworkType deviceNetworkType = 1;
                }
                message Response {
                    Error error = 2;

                    message Error {
                        Code code = 1;
                        string description = 2;

                        enum Code {
                            NULL = 0;
                            UNKNOWN_ERROR = 1;
                            BAD_INPUT = 2;
                            INTERNAL_ERROR = 3;
                        }
                    }
                }
            }
        }
    }

    message Chat {
        message AddMessage {
            message Request {
                string chatObjectId = 1;
                model.ChatMessage message = 2;
            }

            message Response {
                Error error = 1;
                string messageId = 2;
                ResponseEvent event = 3;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }
        message EditMessageContent {
            message Request {
                string chatObjectId = 1;
                string messageId = 2;
                model.ChatMessage editedMessage = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ToggleMessageReaction {
            message Request {
                string chatObjectId = 1;
                string messageId = 2;
                string emoji = 3;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message DeleteMessage {
            message Request {
                string chatObjectId = 1;
                string messageId = 2;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message GetMessages {
            message Request {
                string chatObjectId = 1;
                string afterOrderId = 4; // OrderId of the message after which to get messages
                string beforeOrderId = 2; // OrderId of the message before which to get messages
                int32 limit = 3;
                bool includeBoundary = 5; // If true, include a message at the boundary (afterOrderId or beforeOrderId)
            }

            message Response {
                Error error = 1;
                repeated model.ChatMessage messages = 2;
                model.ChatState chatState = 3;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message GetMessagesByIds {
            message Request {
                string chatObjectId = 1;
                repeated string messageIds = 2;
            }

            message Response {
                Error error = 1;
                repeated model.ChatMessage messages = 2;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SubscribeLastMessages {
            message Request {
                string chatObjectId = 1;  // Identifier for the chat
                int32 limit = 2;  // Number of max last messages to return and subscribe
                string subId = 3;
            }

            message Response {
                Error error = 1;
                repeated model.ChatMessage messages = 2;  // List of messages
                int32 numMessagesBefore = 3;  // Number of messages before the returned messages
                model.ChatState chatState = 4;  // Chat state
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message Unsubscribe {
            message Request {
                string chatObjectId = 1;  // Identifier for the chat
                string subId = 2;
            }
            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message SubscribeToMessagePreviews {
            message Request {
                string subId = 1;
            }

            message Response {
                Error error = 1;
                repeated ChatPreview previews = 2;

                message ChatPreview {
                    string spaceId = 1;
                    string chatObjectId = 2;
                    model.ChatMessage message = 3;
                    model.ChatState state = 4;
                    repeated google.protobuf.Struct dependencies = 5;
                }

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message UnsubscribeFromMessagePreviews {
            message Request {
                string subId = 1;
            }

            message Response {
                Error error = 1;

                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                        // ...
                    }
                }
            }
        }

        message ReadMessages {
            enum ReadType {
                Messages = 0;
                Mentions = 1;
            }

            message Request {
                ReadType type = 1;
                string chatObjectId = 2; // id of the chat object
                string afterOrderId = 3; // read from this orderId; if empty - read from the beginning of the chat
                string beforeOrderId = 4; // read til this orderId
                string lastStateId = 5; // stateId from the last processed ChatState event(or GetMessages). Used to prevent race conditions
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;

                        MESSAGES_NOT_FOUND = 100; // chat is empty or invalid beforeOrderId/lastDbState
                        // ...
                    }
                }
            }
        }

        message Unread {
            enum ReadType {
                Messages = 0;
                Mentions = 1;
            }

            message Request {
                ReadType type = 1;
                string chatObjectId = 2;
                string afterOrderId = 3;
            }

            message Response {
                Error error = 1;
                ResponseEvent event = 2;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }
    message PushNotification {
        message RegisterToken {
            message Request {
                string token = 1;
                Platform platform = 2;
            }
            enum Platform {
                IOS = 0;
                Android = 1;
            }
            message Response {
                Error error = 1;
                message Error {
                    Code code = 1;
                    string description = 2;

                    enum Code {
                        NULL = 0;
                        UNKNOWN_ERROR = 1;
                        BAD_INPUT = 2;
                    }
                }
            }
        }
    }
}

message Empty {

}

message StreamRequest {
    string token = 1;
}
