<metaproperty="description"content="Indicates info about a certain user. Unless specified otherwise, when updating the local peer database, all fields from the newly received constructor take priority over the old constructor cached locally (including by removing fields that aren't set in the new constructor). See here » for an implementation of the logic to use when updating the local user peer database.">
<metaproperty="og:description"content="Indicates info about a certain user. Unless specified otherwise, when updating the local peer database, all fields from the newly received constructor take priority over the old constructor cached locally (including by removing fields that aren't set in the new constructor). See here » for an implementation of the logic to use when updating the local user peer database.">
<divid="dev_page_content"><p>Indicates info about a certain user.</p>
<p>Unless specified otherwise, when updating the <ahref="/api/peers">local peer database</a>, all fields from the newly received constructor take priority over the old constructor cached locally (including by removing fields that aren't set in the new constructor).</p>
<p>See <ahref="https://github.com/tdlib/td/blob/cb164927417f22811c74cd8678ed4a5ab7cb80ba/td/telegram/UserManager.cpp#L2267">here »</a> for an implementation of the logic to use when updating the <ahref="/api/peers">local user peer database</a>.</p>
<td>Whether this user is a contact <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.</td>
<td>Whether this user is a mutual contact. <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.</td>
<td>Whether the account of this user was deleted. <br>Changes to this flag should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID, see <ahref="/api/peers#full-info-database">here »</a> for more info.</td>
<td>Is this user a bot? <br>Changes to this flag should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID, see <ahref="/api/peers#full-info-database">here »</a> for more info.</td>
<td>If set and <code>min</code> is set, the value of <code>photo</code> can be used to update the local database, see the documentation of that flag for more info.</td>
<td>Whether this user is a Telegram Premium user <br>Changes to this flag should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID, see <ahref="/api/peers#full-info-database">here »</a> for more info. <br>Changes to this flag if the <code>self</code> flag is set should also trigger the following calls, to refresh the respective caches: <br>- The <ahref="/method/help.getConfig">help.getConfig</a> cache <br>- The <ahref="/method/messages.getTopReactions">messages.getTopReactions</a> cache if the <code>bot</code> flag is <strong>not</strong> set</td>
<td>Whether we installed the <ahref="/api/bots/attach">attachment menu web app</a> offered by this bot. <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.</td>
<td>Whether we can edit the profile picture, name, about text and description of this bot because we own it. <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set. <br>Changes to this flag (if <code>min</code> is not set) should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID.</td>
<td>Whether we marked this user as a <ahref="/api/privacy">close friend, see here » for more info</a>. <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.</td>
<td>Whether we have <ahref="/api/stories#hiding-stories-of-other-users">hidden »</a> all active stories of this user. <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag is set.</td>
<td>If set, we can only write to this user if they have already sent some messages to us, if we are subscribed to <ahref="/api/premium">Telegram Premium</a>, or if they're a mutual contact (<ahref="/constructor/user">user</a>.<code>mutual_contact</code>). <br>All the secondary conditions listed above must be checked separately to verify whether we can still write to the user, even if this flag is set (i.e. a mutual contact will have this flag set even if we can still write to them, and so on...); to avoid doing these extra checks if we haven't yet cached all the required information (for example while displaying the chat list in the sharing UI) the <ahref="/method/users.getIsPremiumRequiredToContact">users.getIsPremiumRequiredToContact</a> method may be invoked instead, passing the list of users currently visible in the UI, returning a list of booleans that directly specify whether we can or cannot write to each user; alternatively, the <ahref="/constructor/userFull">userFull</a>.<code>contact_require_premium</code> flag contains the same (fully checked, i.e. it's not just a copy of this flag) info returned by <ahref="/method/users.getIsPremiumRequiredToContact">users.getIsPremiumRequiredToContact</a>. <br>To set this flag for ourselves invoke <ahref="/method/account.setGlobalPrivacySettings">account.setGlobalPrivacySettings</a>, setting the <code>settings.new_noncontact_peers_require_premium</code> flag.</td>
<td>Access hash of the user, see <ahref="/api/peers#access-hash">here »</a> for more info. <br>If this flag is set, when updating the <ahref="/api/peers">local peer database</a>, generate a virtual flag called <code>min_access_hash</code>, which is: <br>- Set to <code>true</code> if <code>min</code> is set AND <br>- The <code>phone</code> flag is <strong>not</strong> set OR <br>- The <code>phone</code> flag is set and the associated phone number string is non-empty <br>- Set to <code>false</code> otherwise. <br><br>Then, apply both <code>access_hash</code> and <code>min_access_hash</code> to the local database if: <br>- <code>min_access_hash</code> is false OR <br>- <code>min_access_hash</code> is true AND <br>- There is no locally cached object for this user OR <br>- There is no <code>access_hash</code> in the local cache OR <br>- The cached object's <code>min_access_hash</code> is also true <br>If the final merged object stored to the database has the <code>min_access_hash</code> field set to true, the related <code>access_hash</code> is <strong>only</strong> suitable to use in <ahref="/constructor/inputPeerPhotoFileLocation"><code>inputPeerPhotoFileLocation</code> »</a>, to directly <ahref="/api/files">download the profile pictures</a> of users, everywhere else a <code>inputPeer*FromMessage</code> constructor will have to be generated as specified <ahref="/api/min">here »</a>. <br>Bots can also use min access hashes in some conditions, by passing <code>0</code> instead of the min access hash.</td>
<td>First name. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>min</code> flag of the locally cached user entry is set.</td>
<td>Last name. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>min</code> flag of the locally cached user entry is set.</td>
<td>Main active username. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>min</code> flag of the locally cached user entry is set. <br>Changes to this flag should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID if the above conditions are respected and the <code>bot_can_edit</code> flag is also set.</td>
<td>Phone number. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>min</code> flag of the locally cached user entry is set.</td>
<td>Profile picture of user. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>apply_min_photo</code> flag is set OR <br>- The <code>min</code> flag of the locally cached user entry is set.</td>
<td>Online status of user. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>min</code> flag of the locally cached user entry is set OR <br>- The locally cached user entry is equal to <ahref="/constructor/userStatusEmpty">userStatusEmpty</a>.</td>
<td>Version of the <ahref="/constructor/userFull">bot_info field in userFull</a>, incremented every time it changes. <br>Changes to this flag should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID, see <ahref="/api/peers#full-info-database">here »</a> for more info.</td>
<td>Additional usernames. <br>When updating the <ahref="/api/peers">local peer database</a>, apply changes to this field only if: <br>- The <code>min</code> flag is not set OR <br>- The <code>min</code> flag is set AND <br>- The <code>min</code> flag of the locally cached user entry is set. <br>Changes to this flag (if the above conditions are respected) should invalidate the local <ahref="/constructor/userFull">userFull</a> cache for this user ID.</td>
<td>ID of the maximum read <ahref="/api/stories">story</a>. <br>When updating the <ahref="/api/peers">local peer database</a>, do not apply changes to this field if the <code>min</code> flag of the incoming constructor is set.</td>
<p>Many constructors in the API need to be stored in a local database upon reception and should only ever be updated reactively (passively) when received via updates or by other means (as specified in the documentation), to avoid overloading the server by continuously requesting changes for the same unchanged information.</p>
<p>When updating the <ahref="/api/peers">local peer database »</a>, all fields from the newly received constructor take priority over the old constructor cached locally (including by removing fields that aren't set in the new constructor).</p>
<h4><aclass="anchor"href="#bot-attachment-menu-and-side-menu-entries"id="bot-attachment-menu-and-side-menu-entries"name="bot-attachment-menu-and-side-menu-entries"><iclass="anchor-icon"></i></a><ahref="/api/bots/attach">Bot attachment menu and side menu entries</a></h4>
<p>Bots can install attachment menu and side menu entries, offering conveniently accessible, versatile web apps.</p>
<p>Telegram Premium is an optional subscription service that unlocks additional exclusive client-side and API-side features, while helping support the development of the app.</p>
<p>Unless specified otherwise, when updating the <ahref="/api/peers">local peer database</a>, all fields from the newly received constructor take priority over the old constructor cached locally (including by removing fields that aren't set in the new constructor).</p>
<p>See <ahref="https://github.com/tdlib/td/blob/cb164927417f22811c74cd8678ed4a5ab7cb80ba/td/telegram/UserManager.cpp#L2267">here »</a> for an implementation of the logic to use when updating the <ahref="/api/peers">local user peer database</a>.</p>
<p>Check whether we can write to the specified user (this method can only be called by non-<ahref="/api/premium">Premium</a> users), see <ahref="/api/privacy#require-premium-for-new-non-contact-users">here »</a> for more info on the full flow.</p>
<p>Users can turn their Telegram account into a business account, gaining access to business features such as opening hours, location, quick replies, automated messages, custom start pages, chatbot support, and more.</p>
<h4><aclass="anchor"href="#mini-apps-on-telegram"id="mini-apps-on-telegram"name="mini-apps-on-telegram"><iclass="anchor-icon"></i></a><ahref="/api/bots/webapps">Mini Apps on Telegram</a></h4>
<p>Bots can offer users interactive HTML5 web apps to completely replace any website.</p>
<p>Location of profile photo of channel/group/supergroup/user</p>
<h4><aclass="anchor"href="#uploading-and-downloading-files"id="uploading-and-downloading-files"name="uploading-and-downloading-files"><iclass="anchor-icon"></i></a><ahref="/api/files">Uploading and Downloading Files</a></h4>
<p>How to transfer large data batches correctly.</p>