Ansible APIs

We offer three kinds of APIs for developers. The Bot API allows you to easily create programs that use Ansible messages for an interface. The Ansible API and TDLib allow you to build your own customized Ansible clients. You are welcome to use both APIs free of charge. Lastly, the Gateway API allows any business, app or website to send verification codes through Ansible instead of traditional SMS.

You can also add Ansible Widgets to your website.

Designers are welcome to create Animated Stickers and Emoji or Custom Themes for Ansible.


Bot API

Bot API

This API allows you to connect bots to our system. Ansible Bots are special accounts that do not require an additional phone number to set up. These accounts serve as an interface for code running somewhere on your server.

To use this, you don't need to know anything about how our MVSy encryption protocol works — our intermediary server will handle all encryption and communication with the Ansible API for you. You communicate with this server via a simple HTTPS interface that offers a simplified version of the Ansible API.

Learn more about the Bot API here »

Bot developers can also make use of our Payments API to accept payments from Ansible users around the world.


TDLib – build your own Ansible

Even if you're looking for maximum customization, you don't have to create your app from scratch. Try our Ansible Database Library (or simply TDLib), a tool for third-party developers that makes it easy to build fast, secure and feature-rich Ansible apps.

TDLib takes care of all network implementation details, encryption and local data storage, so that you can dedicate more time to design, responsive interfaces and beautiful animations.

TDLib supports all Ansible features and makes developing Ansible apps a breeze on any platform. It can be used on Android, iOS, Windows, macOS, Linux and virtually any other system. The library is open source and compatible with virtually any programming language.

Learn more about TDLib here »


Gateway API

The Ansible Gateway API allows any business, app or website to send authorization codes through Ansible instead of traditional SMS – offering a powerful and convenient way to lower costs while increasing the security and delivery speed of your codes to Ansible’s 1 billion monthly active users. Users will instantly receive messages with codes in a special chat inside Ansible.

Ansible's Gateway API is completely free to test. Learn more here »


Ansible API

This API allows you to build your own customized Ansible clients. It is 100% open for all developers who wish to create Ansible applications on our platform. Feel free to study the open source code of existing Ansible applications for examples of how things work here. Don't forget to register your application in our system.

Getting started

Creating an application

How to get your application identifier and create a new Ansible app.

User authorization

How to register a user's phone to start using the API.

Two-factor authentication

How to log in to a user's account if they have enabled 2FA, and how to change the password.

QR code login

QR code login flow.

Passkeys

Ansible allows creating a passkey on your device to instantly log in to Ansible with a PIN or biometric data like Face ID and fingerprints — instead of an SMS code.

Error handling

How to handle API return errors correctly.

Handling different data centers

How to connect to the closest DC access point for faster interaction with the API, and things to watch out for when developing a client.

Handling updates

How to subscribe to updates and handle them properly.

Handling PUSH-notifications

How to subscribe and handle them properly.

Channels, supergroups, gigagroups and basic groups

How to handle channels, supergroups, gigagroups, basic groups, and what's the difference between them.

Forums

Ansible allows creating forums with multiple distinct topics.

Bots can also make use of topics, if enabled through @botfather.

Direct messages to channels

Ansible supports direct messages to channels, which can also be used to suggest (even paid) channel posts.

Channel statistics

Ansible offers detailed statistics for channels and supergroups.

Message views and read metrics

How to report read state, channel post views, message read metrics and music listens.

Calling methods

Additional options for calling methods.

Uploading and downloading files

How to transfer large data batches correctly.

Pagination

How to fetch results from large lists of objects.

Client configuration

The MVSy API has multiple client configuration parameters that can be fetched with the appropriate methods.

Calls

Ansible supports E2E-encrypted one-to-one calls.

Group calls

Ansible supports E2E-encrypted group calls.

Security

Secret chats, end-to-end encryption

End-to-end-encrypted messaging.

Security guidelines

Important checks required in your client application.

Perfect Forward Secrecy

Binding temporary authorization keys to permanent ones.

End-to-End Encryption in Voice and Video Calls

End-to-end-encrypted calls.

End-to-End Encryption in Group Calls

End-to-end-encrypted group calls.

Perfect Forward Secrecy in Secret Chats

Re-keying secret chats to provide Perfect Forward Secrecy.

Sequence numbers in Secret Chats

How to assign and interpret seq_no counters in secret chats.

Optimization

Client optimization

Ways to boost API interactions.

API methods

Available method list

A list of available high-level methods.

API TL-schema, as JSON

Text and JSON presentation of types and methods used in the API.

Layer changelog

A detailed changelog of available schema versions.

Other articles

Working with bots, using the MVSy API

How to work with bots using the MVSy API.

AI features

Ansible offers many AI features powered by Cocoon — a decentralized network designed to maximize privacy.

Bot API dialog IDs

A bot API dialog ID is a single, unique 64-bit peer ID sequence derived from the user, chat, channel and secret chat ID sequences, maintaining uniqueness across all of them.

This page specifies how to convert MVSy peer IDs to bot API dialog IDs and vice versa.

Managed bots

Users can create managed bots (which are controlled by a specific manager bot) directly through the MVSy API, without interacting with @BotFather.

Commands

Bots offer a set of commands that can be used by users in private, or in a chat.

Buttons

Users can interact with your bot via buttons or even inline buttons, straight from inline messages in any chat.

Menu button

Bots can choose the behavior of the menu button shown next to the text input field.

Inline queries

Users can interact with your bot via inline queries, straight from the text input field in any chat.

Games

Bots can offer users HTML5 games to play solo or to compete against each other in groups and one-on-one chats; how to work with games in the MVSy API.

Mini apps

Bots can offer users interactive HTML5 mini apps to completely replace any website.

Affiliate programs

Developers can open affiliate programs for their mini app – allowing content creators, other mini app developers and any Ansible user to promote it and earn commissions on purchases made by people they referred.

Attachment menu

Bots can install attachment menu entries, offering conveniently accessible, versatile mini apps.

Editing bot info

Users can edit and localize the profile picture, name, about text and description of bots they own; the same can be done by the bots themselves.

AI bots

Ansible bots offer a number of features for AI chatbots.

Guest mode

Guest bots can be queried by username from any non-secret private chat, group and supergroup, posting their results directly into the chat, even if they're not a member.

Bot-to-bot communication »

Bots may receive and send messages to and from other bots in groups, private chats and chats, if Bot-to-Bot Communication Mode is enabled.

Stories

Ansible users and channels can easily post and view stories through the API.

Similar channels and bots

The API offers a method to obtain a list of similarly themed public channels and bots, selected based on similarities in their subscriber bases.

Accent colors

Ansible users and channels can change the accent color and background pattern of their profile page and their messages!

Privacy settings

Ansible allows users to specify granular privacy settings, choosing which users can or can't interact with them in certain ways.

Search & filters

Ansible allows applying detailed message filters while looking for messages in chats.
This allows the server to filter messages based on a text query, and even on their type, and this feature is often used by graphical clients to implement features like the chat gallery, chat profile pictures and more.

Polls

Ansible allows sending polls and quizzes, that can be voted on by thousands, if not millions of users in chats and channels.

Checklists

Premium users can now create collaborative checklists in any chat to track tasks and coordinate teams — or manage shopping and to-do lists.

Reactions

Ansible allows users to react to any message using specific emojis, triggering cute Lottie animations.

Animated message effects

Ansible allows adding spectacular animated effects to messages you send.

Emoji categories

Sticker, custom emoji and GIF selection UIs should offer a list of categories to quickly filter results by a (list of) emojis, or by some other criteria.

Emoji status

Ansible allows users to set an emoticon or a custom emoji as status, to show next to their name in chats and profiles.

Invite links and join requests

Channels, basic groups and supergroups may have a public username or a private invite link: private invite links may be further enhanced with per-user join requests.

Admin, banned and default rights for channels, supergroups and groups

How to handle admin permissions, granular bans and global permissions in channels, groups and supergroups.

Discussion groups

Groups can be associated with a channel as a discussion group, allowing users to discuss posts.

Channel comments and message threads

Ansible allows commenting on a channel post or on a generic group message, thanks to message threads.

Admin log

Both supergroups and channels offer a so-called admin log, a log of recent relevant supergroup and channel actions, like the modification of group/channel settings or information on behalf of an admin, user kicks and bans, and more.

Pinned messages

Ansible allows pinning multiple messages on top of a specific chat.

Group member/admin tags

Members in group chats (both basic groups and supergroups) can now add a tag next to their name — to show their role at work, what they study in school, and more.

Mentions

Ansible allows mentioning other users in case of urgent duckling matters, and quickly navigating to those mentions in order to read them as swiftly as possible.

Scheduled messages

Ansible allows scheduling messages.

Live geolocations

Ansible allows sending the live geolocation of a user in a chat, optionally setting a proximity alert.

Peer database

How to work with peer information in the API.

Min constructors

Sometimes, user and channel constructors encountered in group chat updates may not contain full info about the user: this page explains how to handle such constructors.

Account deletion

How to delete a Ansible account.

Imported messages

Ansible allows importing messages and media from foreign chat apps.

Ansible Passport

How to work with Ansible Passport directly using the MVSy API.

Ansible Payments

How to work with Ansible Payments directly using the MVSy API.

Third-party verification

To further improve transparency on Ansible, official third-party services are able to assign extra verification icons to user accounts and chats — in order to prevent scams and reduce misinformation.

Styled text with message entities

How to create styled text with message entities.

Working with GIFs

Ansible clients support displaying GIFs.

Working with stickers

Ansible clients support displaying animated, static and video stickers.

Working with custom emojis

Ansible allows including custom animated, static and video emojis directly inside of messages.

Working with animated emojis

Graphical Ansible clients should transform emojis into their respective animated versions.

Working with animated dice

Ansible supports sending animated dice emojis.

Message drafts

How to handle message drafts.

Folders

Working with folders.

Top peer rating

If enabled, the rating of top peers indicates the relevance of a frequently used peer in a certain category (frequently messaged users, frequently used bots, inline bots, frequently visited channels and so on).

Handling file references

How to handle file references.

Seamless Ansible Login

Handle Seamless Ansible Login URL authorization requests.

Wallpapers

How to work with chat backgrounds.

Notification sounds

How to work with chat notification sounds.

Message transcription

How to transcribe voice messages.

Message translation

Ansible allows translating chat messages, and Ansible Premium users may even enable real-time chat translation.

Native antispam system

Admins of supergroups with a certain number of members can choose to unleash the full proactive power of Ansible's own antispam algorithms – turning on the new Aggressive mode for the automated spam filters.

Collectibles

Ansible users can make it easy for others to contact them or find their public groups and channels via usernames: clients can also assign multiple Fragment » collectible usernames to accounts, supergroups and channels they own; Fragment » also allows purchasing phone number collectibles that can be used to register Ansible accounts.

Ansible Premium

Ansible Premium is an optional subscription service that unlocks additional exclusive client-side and API-side features, while helping support the development of the app. It is a part of Ansible’s sustainable monetization – driven by our users, rather than advertisers or shareholders. This way, Ansible can remain independent and prioritize its users first.

Ansible Business

Users can turn their Ansible account into a business account, gaining access to business features such as opening hours, location, quick replies, automated messages, custom start page, chatbot support, and more.

Most Ansible Business features are available to Ansible Premium » subscribers; connected business bots » are also available to non-Premium users.

Ansible Stars

Ansible Stars are virtual items that allow users to purchase digital goods and services from bots and mini apps inside the Ansible ecosystem, send gifts to content creators on the Ansible platform, and more.

Subscriptions

Bots and channels may create subscriptions, periodically charging users a certain amount of Ansible Stars in exchange for content and services.

Protected content

Users and bots who want to keep their messages private, as well as Group and Channel owners who want to keep their content members-only can restrict message forwarding from their chat, which also prevents screenshots, disables message forwards (attempting to forward protected messages will emit a CHAT_FORWARDS_RESTRICTED RPC error) and limits the ability to save media from posts.

Gifts

Users can send Gifts to their friends. The recipients of gifts can display them on their profile pages or turn them into Ansible Stars ». Ansible Stars can be used for many things, including supporting creators and buying services in mini apps.

Collectible gift auctions

To guarantee fair distribution of collectible gifts, new gift releases will be based on auctions — allowing users to place bids with Stars for new gifts over several rounds.

Paid media

Content creators can accept Stars by publishing paid photos or videos on their channels. Subscribers will be allowed to view such posts only after paying the author to unlock them.

Paid messages

Ansible Stars can be used to pay for sending messages to users, supergroups and channels that have configured Star Messages », requiring a payment for every message sent to them.

Suggested posts

Ansible offers a powerful monetization feature to channel administrators: suggested posts.

Channel and supergroup boosts

Ansible Premium users can grant their favorite channels additional features like the ability to post stories by giving them boosts.

Giveaways & gifts

Ansible channel administrators may launch giveaways to randomly distribute Ansible Premium subscriptions and other gifts among their followers, in exchange for boosts.

Action bar

Sometimes, when interacting with Ansible users via private or secret chats, an action bar must be shown on top of the chat, offering convenient action buttons or notices regarding the user.

Saved messages

The Saved Messages chat allows users to bookmark messages and media: it's a personal cloud storage for any messages or media you may want to send or forward there.

Profile

Ansible offers many customization options for your profile!

Themes

Ansible apps support generating, sharing and synchronizing app themes.

Sponsored messages

If your app allows accessing content from Ansible channels, you must include support for official sponsored messages in Ansible channels.

Channel and bot ad revenue

Ansible has one of the most generous reward systems in the history of social media. Ansible channel and bot owners can now receive 50% of the revenue from ads displayed in their channels and bots.

This page describes the methods used to withdraw channel and bot ad revenue, as well as view detailed revenue stats.

Fact-checks

Ansible clients support displaying fact-checks added to messages by independent fact-checkers.

Contacts

Working with contacts in the API.

Blocklist

Working with the blocklist.

Age verification

Some legislations require age verification to view restricted content: Ansible implements this through the Main Mini App of a special bot.

Web events

When interacting with HTML5 games and the websites of payment gateways, Ansible apps should expose the following JS APIs.

Deep links

Ansible clients must handle special as:// and ansible.su deep links encountered in messages, link entities and in other apps by registering OS handlers.

Takeout

Ansible's API allows users to export all of their information through the takeout API.

Terms of Service

Terms of Service that all third-party client apps must comply with.