> For the complete documentation index, see [llms.txt](https://painor.gitbook.io/gramjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://painor.gitbook.io/gramjs/registration-and-authorization/auth.signup.md).

# auth.signUp

Registers a validated phone number in the system.

## 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.auth.signUp({
        phoneNumber: 'random string here',
        phoneCodeHash: 'random string here',
        firstName: 'random string here',
        lastName: '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.Returns an auth.Authorization object with information about the new authorization. = await client.invoke(new Api.auth.signUp({
        phoneNumber: 'random string here',
        phoneCodeHash: 'random string here',
        firstName: 'random string here',
        lastName: 'random string here',
        }));
    console.log(result); // prints the result
})();
```

{% endtab %}
{% endtabs %}

## TL schema

```
auth.authorization#cd050916 flags:# tmp_sessions:flags.0?int user:User = auth.Authorization;
auth.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization;
---functions---
auth.signUp#80eee427 phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization;
```

## Parameters

|          Name         | Type                                            | Description                              |
| :-------------------: | ----------------------------------------------- | ---------------------------------------- |
|   **phone\_number**   | [string](https://core.telegram.org/type/string) | Phone number in the international format |
| **phone\_code\_hash** | [string](https://core.telegram.org/type/string) | SMS-message ID                           |
|    **first\_name**    | [string](https://core.telegram.org/type/string) | New user first name                      |
|     **last\_name**    | [string](https://core.telegram.org/type/string) | New user last name                       |

## Result

Returns an [auth.Authorization](https://core.telegram.org/type/auth.Authorization) object with information about the new authorization.

## Possible errors

| Code | Type                      | Description                            |
| :--: | ------------------------- | -------------------------------------- |
|  400 | FIRSTNAME\_INVALID        | Invalid first name                     |
|  400 | INPUT\_REQUEST\_TOO\_LONG | The request is too big                 |
|  400 | LASTNAME\_INVALID         | Invalid last name                      |
|  400 | PHONE\_CODE\_EMPTY        | **phone\_code** from a SMS is empty    |
|  400 | PHONE\_CODE\_EXPIRED      | SMS expired                            |
|  400 | PHONE\_CODE\_INVALID      | Invalid SMS code was sent              |
|  400 | PHONE\_NUMBER\_FLOOD      | You asked for the code too many times. |
|  400 | PHONE\_NUMBER\_INVALID    | Invalid phone number                   |
|  400 | PHONE\_NUMBER\_OCCUPIED   | The phone number is already in use     |

## Can bots use this methd ?

### yes

## Related pages
