Skip to content

Invoke & Methods

Invoke — Call Any TL Method

The core command. Takes a TL method name and optional JSON parameters:

bash
# No params needed
mtgo-cli invoke help.getConfig

# With JSON params
mtgo-cli invoke users.getFullUser '{"id":{"_":"inputUserSelf"}}'

# Send a message
mtgo-cli invoke messages.sendMessage '{"peer":{"_":"inputPeerUser","user_id":123,"access_hash":456},"message":"Hello!","random_id":789}'

# Pretty JSON output
mtgo-cli invoke users.getFullUser '{"id":{"_":"inputUserSelf"}}' --format json

# Fast path — skip full TL decode for bulk operations
mtgo-cli invoke help.getConfig --fast

Discovering Methods and Parameters

bash
# List all TL methods
mtgo-cli methods

# Filter by prefix
mtgo-cli methods messages.
mtgo-cli methods users.get

# Machine-readable
mtgo-cli methods --format json

For parameter details, check:

JSON Constructor Format

TL interface fields need a "_" key to specify the constructor:

json
{
  "_": "inputPeerUser",
  "user_id": 123456,
  "access_hash": 789012345
}

Common constructors:

ConstructorFieldsUse For
inputPeerSelfnoneYourself
inputPeerUseruser_id, access_hashA specific user
inputPeerChatchat_idA basic group
inputPeerChannelchannel_id, access_hashA supergroup/channel
inputPeerEmptynoneEmpty placeholder
inputUserSelfnoneYour own user object
inputUseruser_id, access_hashAnother user

Output Format

bash
--format json    # machine-readable JSON (use with jq)
--no-color       # disable ANSI colors
--debug          # log full request/response to stderr (sensitive!)

Released under the Apache-2.0 License.