Create Custom Domain

POST /api/v1/custom-domain

Common errors include:

  • "400 Bad Request" if the domain already exists or the format is invalid.
  • "500 Internal Server Error" if the custom domain could not be created.

Adds a new custom domain to the user's account. This endpoint requires an available connected domain quota.

Request

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

URL Parameters Schema

domain string
Default: N/A
The base domain URL (for example, https://example.com)
subDomain string
Default: N/A
The subdomain (for example, app)
spare string
Default: N/A
Whether to use spare domain: Yes or No
LANGUAGE
REQUEST
 curl -X POST \
  'https://apis.divsly.com/api/v1/custom-domain' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
	"domain": "https://example.com",
	"subDomain": "app",
	"spare": "No"
  }'

API REQUEST
 const createCustomDomain = (domainData) => {
  return new Promise((resolve, reject) => {
	fetch('https://apis.divsly.com/api/v1/custom-domain', {
  	method: 'POST',
  	headers: {
    	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
    	'Content-Type': 'application/json'
  	},
  	body: JSON.stringify({
    	domain: domainData.domain,
    	subDomain: domainData.subDomain,
    	spare: domainData.spare
  	})
	})
  	.then(response => response.json())
  	.then(data => resolve(data))
  	.catch(error => reject(error));
  });
};

API REQUEST
 const axios = require('axios');

const createCustomDomain = (domainData) => {
  return new Promise((resolve, reject) => {
	axios({
  	method: 'post',
  	url: 'https://apis.divsly.com/api/v1/custom-domain',
  	headers: {
    	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
    	'Content-Type': 'application/json'
  	},
  	data: {
    	domain: domainData.domain,
    	subDomain: domainData.subDomain,
    	spare: domainData.spare
  	}
	})
  	.then(response => resolve(response.data))
  	.catch(error => reject(error.response.data));
  });
};
API REQUEST
 $data = array(
	'domain' => 'https://example.com',
	'subDomain' => 'app',
        'spare' => 'No'
    );

    $ch = curl_init('https://apis.divsly.com/api/v1/custom-domain');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    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/custom-domain'
  headers = {
	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
	'Content-Type': 'application/json' 
 }
  data = {
	'domain': 'https://example.com',
	'subDomain': 'app',
	'spare': 'No'
 }

 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
  {
  "status": 200,
  "message": "Custom Domain Added Successfully .",
  "data": {
	"id": 34,
	"userId": 89,
	"domain": "https://testdomain.com",
	"spare": "Yes",
	"subDomain": null,
	"domainUrl": "https://testdomain.com",
	"status": "Pending",
	"createdAt": "2025-04-02T03:47:37.430Z",
	"updatedAt": "2025-04-02T03:47:37.430Z"
  }
}
   
  {
	"message": "Unauthorized!"
}

   {
	"message": "Custom Domain Limit Exceeded for your current plan. Please upgrade!!"
}


   {
  "success": false,
  "error": “Error creating Custom domain”
}