Skip to main content
POST
/
domains
PHP
declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

$sdk = Dub\Dub::builder()
    ->setSecurity(
        'DUB_API_KEY'
    )
    ->build();

$request = new Operations\CreateDomainRequestBody(
    slug: 'acme.com',
    expiredUrl: 'https://acme.com/expired',
    notFoundUrl: 'https://acme.com/not-found',
    placeholder: 'https://dub.co/help/article/what-is-dub',
);

$response = $sdk->domains->create(
    request: $request
);

if ($response->domainSchema !== null) {
    // handle response
}
{
  "id": "<string>",
  "slug": "acme.com",
  "verified": false,
  "primary": false,
  "archived": false,
  "placeholder": "https://dub.co/help/article/what-is-dub",
  "expiredUrl": "https://acme.com/expired",
  "notFoundUrl": "https://acme.com/not-found",
  "logo": "<string>",
  "assetLinks": null,
  "appleAppSiteAssociation": null,
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "registeredDomain": {
    "id": "<string>",
    "autoRenewalDisabledAt": "<string>",
    "createdAt": "<string>",
    "expiresAt": "<string>",
    "renewalFee": 123
  }
}

Authorizations

Authorization
string
header
required

Body

application/json
slug
string
required
Required string length: 1 - 190
Example:
expiredUrl
string | null
Maximum length: 32000
Example:
notFoundUrl
string | null
Maximum length: 32000
Example:
archived
boolean
default:false
Example:
placeholder
string | null
Maximum length: 100
Example:
appleAppSiteAssociation
string | null

Response

id
string
required
slug
string
required
Example:
verified
boolean
default:false
required
primary
boolean
default:false
required
archived
boolean
default:false
required
placeholder
string | null
required
Example:
expiredUrl
string | null
required
Example:
notFoundUrl
string | null
required
Example:
appleAppSiteAssociation
string | null
required
createdAt
string
required
updatedAt
string
required
registeredDomain
object | null
required