Invite Users

POST /api/v1/create-user

Common errors include:

  • "401 Unauthorized" if the bearer token is missing or invalid.
  • "403 Forbidden" if the current account cannot invite users.
  • "409 Conflict" if the account already exists or the invitation is no longer valid.

Invites a new user to the current account and sends an invitation email to the provided address.

Request

Method : POST
Content-Type : Application/json
Authentication : Bearer Token
Base URL : https://apis.divsly.com/api/v1

Request Parameters Schema

email string Required
Email address of the user to invite
userType string Required
Role to assign to the invited user
authorization bearer token Required
Bearer token for the authenticated account sending the invitation
LANGUAGE
REQUEST
  curl -X POST \
  'https://apis.divsly.com/api/v1/create-user' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
	"email": "newuser@example.com",
       “userType”: “user”, 

  }'

API REQUEST
 const createUser = (userData) => {
  return new Promise((resolve, reject) => {
	fetch('https://apis.divsly.com/api/v1/create-user', {
  	method: 'POST',
  	headers: {
    	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
    	'Content-Type': 'application/json'
  	},
  	body: JSON.stringify({
    	email: userData.email,
    	userType: userData.userType
  	})
	})
  	.then(response => response.json())
  	.then(data => resolve(data))
  	.catch(error => reject(error));
  });
};
API REQUEST
 const axios = require('axios');

const createUser = (userData) => {
  return new Promise((resolve, reject) => {
	axios({
  	method: 'post',
  	url: 'https://apis.divsly.com/api/v1/create-user',
  	headers: {
    	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
    	'Content-Type': 'application/json'
  	},
  	data: {
    	email: userData.email,
    	userType: userData.userType
  	}
	})
  	.then(response => resolve(response.data))
  	.catch(error => reject(error.response.data));
  });
};

API REQUEST
 $data = array(
        'email' => 'newuser@example.com',
        'userType' => 'user'
    );

    $ch = curl_init('https://apis.divsly.com/api/v1/create-user');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: Bearer YOUR_JWT_TOKEN_HERE',
        'Content-Type: application/json'
    ));

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    $result = json_decode($response, true);
    print_r($result);
API REQUEST
 import requests
import json

url = 'https://apis.divsly.com/api/v1/create-user'
headers = {
	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
	'Content-Type': 'application/json'
}
data = {
	'email': 'newuser@example.com',
	'userType':'user'
}

try:
	response = requests.post(
    	url,
    	headers=headers,
    	json=data
	)
	response.raise_for_status()
	print(response.json())
except requests.exceptions.RequestException as e:
	print(f"Error: {e}")

RESPONSE
 {
   "success":true,"data":{"id":120,"userType":"user","isAdmin":false,"avatar":"data:image/png;base64,iVBORw","password":"","username":null,"email":"test@test.com","firstName":"test","lastName":"","company":null,"companySize":null,"industry":null,"jobTitle":null,"onboardingStatus":"NOT_STARTED","vatId":null,"mobile":null,"token":null,"country":"IN","profileImage":null,"parentUser":89,"lastLogin":null,"ip":"183.83.160.128","edit":0,"stripeCustomerId":null,"subscriptionId":null,"subscriptionItemId":null,"plan":"yearly-super","planStart":null,"planStatus":null,"paymentStatus":null,"subStartDate":"2025-03-17T15:51:37.000Z","subEndDate":"2054-03-16T18:30:00.000Z","demoTour1":false,"demoTour2":false,"demoTour3":false,"method":"Manual","isActive":true,"passwordUpdated":false,"isVerified":true,"isDelete":false,"createdAt":"2025-04-02T03:33:05.492Z","updatedAt":"2025-04-02T03:33:05.492Z","isadminblocked":false,"useracceptedterms":false,"userEvents":{},"qrCodes":[]},"message":"Invitation email sent to user!"}
    
  {
  "data": {
	"message": "Unauthorized",
  }
}


  {
  "data": {
	"message": "Forbidden Access!",
  }
}


    
 {
  "data": {
	"message": "Account already exists",
	"type": "ACCOUNT_NOT_EXIST| Invitation has been expired | Admin account is not exist!"
  }
}