Skip to main content

Request registration code

Method#

/mobile/request-registration-code#

POST https://api.z-api.io/instances/YOUR_INSTANCE/token/YOUR_TOKEN/mobile/request-registration-code

Header#

KeyValue
Client-TokenACCOUNT SECURITY TOKEN

Concept#

Method used to request the confirmation code. To execute this method, it is necessary to verify if the number is available to be registered. Without making this verification first, it will not be possible to request the code.

Attention

Remember that the phone number you should send in this request is the same one you verified in the previous API. Because, remember, checking if the number is available is mandatory before requesting the confirmation code.


Attributes#

Required#

AttributesTypeDescription
ddistringDDI of the number
phonestringPhone number you want to register. Should include only the number with area code (E.g., 4499999999), without formatting or mask
methodstringDefines the code sending method. SMS, voice call, or pop-up in the WhatsApp application. (sms, voice, wa_old)

Request Body#

{
"ddi": "55",
"phone": "4499999999",
"method": "sms | voice | wa_old"
}

Response#

200#

AttributesTypeDescription
successbooleanReturns true if the code request was successfully sent. Check if you received the code and use it in the confirm code API
captchastringBase64 image with captcha code. In case of receiving this attribute, you need to confirm this code in the confirm captcha API for the code to be sent. After confirming the captcha, it is not necessary to request the code again, just wait for its receipt.
blockedbooleanDefines if the number is banned or not
retryAfterstringTime in seconds to wait for a new code request
smsWaitSecondsnumberTime to wait for sms request. If the value is 0, it means that the request can already be sent to this method
voiceWaitSecondsnumberTime to wait for voice call request. Same purpose as smsWaitSeconds
waOldWaitSecondsnumberTime to wait for pop-up in the cell phone app request. Same purpose as smsWaitSeconds. Attention: do not use this method if you do not have access to the cell phone where the number is currently linked. This method is useful to speed up the code confirmation process without waiting for SMS or voice call reception, but it requires you to have the device in hand and with the WhatsApp application open.
methodstringCode sending method

Example#

Success Case#

{
"success": true,
"retryAfter": 165,
"smsWaitSeconds": 125,
"voiceWaitSeconds": 125,
"waOldWaitSeconds": 125,
"method": "sms"
}

Banned Number Case#

{
"success": false,
"blocked": true
}

400#

Invalid request. Check if the data you are sending is in accordance with the documentation above.

405#

In this case, make sure you are correctly sending the method specification, i.e., check if you sent the POST or GET as specified at the beginning of this topic.

415#

If you receive a 415 error, make sure to add the "Content-Type" of the object you are sending to the headers of the request, mostly "application/json"

Code#