Skip to main content

contacts.addContact

Add an existing telegram user as contact. Use contacts.importContacts to add contacts by phone number, without knowing their Telegram ID.

func (c *Client) ContactsAddContact(ctx context.Context, request *ContactsAddContactRequest) (UpdatesClass, error)

Calling this method​

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.ContactsAddContact(ctx, &tg.ContactsAddContactRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // UpdatesClass
return nil
})

Parameters​

NameTypeRequiredDescription
AddPhonePrivacyExceptionbool—Allow the other user to see our phone number?
IDInputUserClassyesTelegram ID of the other user
FirstNamestringyesFirst name
LastNamestringyesLast name
PhonestringyesUser's phone number, may be omitted to simply add the user to the contact list, without a phone number.
NoteTextWithEntities—A private note for this contact, only visible to us; see here » for more info on contact notes.

Returns​

UpdatesClass

Possible errors​

CodeTypeDescription
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400CONTACT_ID_INVALIDThe provided contact ID is invalid.
400CONTACT_NAME_EMPTYContact name empty.
400MSG_ID_INVALIDInvalid message ID provided.

References​