Skip to content

User Account Creation API

Resetting user password using a four-step process: enable password reset mode, create verification session request via sms or whatsapp channel, update the verification state and finally, create a new password for the user up with a phone number and client ID, and then completing the registration with additional user details.

Getting Started

Before you start, make sure you have the following requirements:

  1. A Client ID: Request a client id (API key) from our support team or sign up for a developer account on our website.
  2. A Valid Phone Number: For completing the verification process via sms or whatsapp.

Headers

  • Content-Type: application/json
  • Authorization: Bearer YOUR_API_KEY

Replace YOUR_API_KEY with the API key you received.

Step 1: Create a password reset process

To enable password reset mode, send a POST request to the /api/v1/auth/password-reset endpoint with the required payload.

Endpoint

POST https://api.stretch.com/api/v1/auth/password-reset

Payload

The request payload should include the following fields:

Parameter Description Type Required Example
grant_type Type of action to perform String No reset
client_id Client's unique identifier String Yes 2f9445b3-5266-45cd-8a85-d5c3fff69781
phone User's phone number String Yes +971509746509

Response

If the account is created successfully, you will receive a JSON response containing the user's information:

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmNDc3OTc0MTcxYmQ0ZTg3OGRlY2NiZjU2NTUyYWM1MSIsInJvbGUiOiJjb2FjaCIsInR5cGUiOiJyZXNldCIsImV4cCI6MTY3OTY0MDI0NCwiaWF0IjoxNjc5NjM4NDQ0fQ.RcsUoQwI82woooCy2fvgc3XX56er0i1zsQ2_0S_8yktMputiNkwqYdvdACVvNSZteiN3Fn4OB-7A0JdPJwVmMVx3zg-0-QvuX0RQrka3hlFm4NOAWAexH_cMyvJKX1NEtlw-dEfyNUPPGezd00L-JLhaJeQhoziPcPaQAU0y0PfWgsgIs44_wb09Upf9JXvoeQDh7jJCu9ItnfK2yuo5L8fn33bxrpDGupu-w8ufQOi8tnMOni_DlF160GpqkUX7njVEZ-MIt-LodfxSnjf9OzhaXmX7QS4COftGYSjfCeD42cw5z-HItw7GufP6Ay4buQBrHI-FtLyNrb_lCGXfSA",
  "refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmNDc3OTc0MTcxYmQ0ZTg3OGRlY2NiZjU2NTUyYWM1MSIsInJvbGUiOiJjb2FjaCIsInR5cGUiOiJyZWZyZXNoIiwiZXhwIjoxNjk3NjM4NDQ0LCJpYXQiOjE2Nzk2Mzg0NDR9.dtvAZfz3hCDCKr7C3LDew3Ts8Qk_Yjmn1_wIx4j_lPCEyL0YbNsIfgglc2GSDrHJlkLqeSpZEuwAxGXDd9ae7XDgwwzSznGq73ufwG1LEYUS3OND6HAmUEjrxLT28yPd2hNz6tp8CiFBvBBeA5HUZ47Q04gB7cBuaUyHDTWxksdUtSUrhIDKRPRpzHYSq8Al3zd1aJyi1sCeuZKUc-X7sToqxnLFviNtK474vHMkzAzYmWkstHVwu5n42bJnITNJSHHwAh-rxymS6Px5U2HVHc-5xRKsvJecH-Q71V8fIU_OAZ3UU7vJtWh8zd8t5nKMN7PKARCUOmtksa3BRAIkqg",
  "token_type": "bearer",
  "access_expire": 1800,
  "refresh_expire": 28800,
  "session": "rp:ceb909e96ff24208914484760ddceca4"
}

Step 2: Create Verification Session Request

To start a verification session, send a POST request to the /api/v1/auth/verify/phone endpoint passing the session obtained from the previous API response.

Endpoint

POST https://api.stretch.com/api/v1/auth/verify/phone

Payload

The request payload should include the following fields:

Parameter Description Type Required Example
session The session identifier String Yes string
channel The communication channel for verification String Yes sms

Response

If the verification session is created successfully, you will receive a JSON response containing the user's information:

{
  "status": "success"
}

Step 3: Update Verification Session Status

To update a verification session, send a PUT request to the /api/v1/auth/verify/phone endpoint with the code input by the user.

Endpoint

PUT https://api.stretch.com/api/v1/auth/verify/phone

Payload

The request payload should include the following fields:

Parameter Description Type Required Example
sid Verification session identifier String Yes string
code Verification code received by user String Yes 0000

Response

If the verification process is successfully completed, you will receive a JSON response containing the user's information:

{
  "status": "success"
}

Step 4: Completing password reset for user

To complete a user registration, send a PUT request to the /api/v1/auth/password-reset endpoint passing the new password if received a successful response.

Endpoint

PUT https://api.stretch.com/api/v1/auth/password-reset

Payload

The request payload should include the following fields:

Parameter Description Type Required Example
password User's new password String Yes 123456

Response

If you receive a successful response, you will receive a JSON response containing the user's credentials:

{
  "access_token": "string",
  "refresh_token": "string",
  "token_type": "bearer",
  "access_expire": 0,
  "refresh_expire": 0,
  "scopes": "string"
}