Create Custom Domain

GET /api/v1/custom-domain

Common errors include:

  • "Bad Request" if body parameters are not passed
  • "DNS_CONFIGURATION_ERROR" if custom domain DNS is misconfigured.

This endpoint is for creating a custom domain

Request

Method : GET
Content-Type : Application/json

URL Parameters Schema

domain string
Default: N/A
The main domain (e.g., "example.com")
subDomain string
Default: N/A
Subdomain prefix (e.g., "blog" for "blog.example.com")
Space string
Default: N/A
Must be either “Yes” or “No”
LANGUAGE
REQUEST
 curl -X POST \
  'https://divsly-backend.vercel.app/api/v1/custom-domain' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
	"domain": "example.com",
	"subDomain": "blog",
	"spare": "No"
  }'

API REQUEST
 const createCustomDomain = (domainData) => {
  return new Promise((resolve, reject) => {
	fetch('https://divsly-backend.vercel.app/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://divsly-backend.vercel.app/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' => 'example.com',
	'subDomain' => 'blog',
        'spare' => 'No'
    );

    $ch = curl_init('https://divsly-backend.vercel.app/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://divsly-backend.vercel.app/api/v1/custom-domain'
  headers = {
	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
	'Content-Type': 'application/json' 
 }
  data = {
	'domain': 'example.com',
	'subDomain': 'blog',
	'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”
}