# account.confirmPhone

Confirm a phone number to cancel account deletion, for more info [click here »](https://core.telegram.org/api/account-deletion)

## Example

{% tabs %}
{% tab title="Javascript" %}

```javascript
const {Api, TelegramClient} = require('telegram');
const {StringSession} = require('telegram/sessions');

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result = await client.invoke(new Api.account.confirmPhone({
        phoneCodeHash: 'random string here',
        phoneCode: 'random string here',
        }));
    console.log(result); // prints the result
})();
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import {Api, TelegramClient} from 'telegram';
import {StringSession} from 'telegram/sessions';

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result: Api.Bool = await client.invoke(new Api.account.confirmPhone({
        phoneCodeHash: 'random string here',
        phoneCode: 'random string here',
        }));
    console.log(result); // prints the result
})();
```

{% endtab %}
{% endtabs %}

## TL schema

```
boolFalse#bc799737 = Bool;
boolTrue#997275b5 = Bool;
---functions---
account.confirmPhone#5f2178c3 phone_code_hash:string phone_code:string = Bool;
```

## Parameters

|          Name         | Type                                            | Description                                                                                   |
| :-------------------: | ----------------------------------------------- | --------------------------------------------------------------------------------------------- |
| **phone\_code\_hash** | [string](https://core.telegram.org/type/string) | Phone code hash, for more info [click here »](https://core.telegram.org/api/account-deletion) |
|    **phone\_code**    | [string](https://core.telegram.org/type/string) | SMS code, for more info [click here »](https://core.telegram.org/api/account-deletion)        |

## Result

[Bool](https://core.telegram.org/type/Bool)

## Possible errors

| Code | Type                | Description            |
| :--: | ------------------- | ---------------------- |
|  400 | CODE\_HASH\_INVALID | Code hash invalid      |
|  400 | PHONE\_CODE\_EMPTY  | phone\_code is missing |

## Can bots use this methd ?

### yes

## Related pages

### [Account deletion](https://core.telegram.org/api/account-deletion)

How to reset an account if the 2FA password was forgotten.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://painor.gitbook.io/gramjs/working-with-the-users-account/account.confirmphone.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
