Skip to main content
POST
/
domains
Python
from dub import Dub


with Dub(
    token="DUB_API_KEY",
) as d_client:

    res = d_client.domains.create(request={
        "slug": "acme.com",
        "expired_url": "https://acme.com/expired",
        "not_found_url": "https://acme.com/not-found",
        "placeholder": "https://dub.co/help/article/what-is-dub",
    })

    # Handle response
    print(res)
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
}
package main

import(
"context"
dubgo "github.com/dubinc/dub-go"
"github.com/dubinc/dub-go/models/operations"
"log"
)

func main() {
ctx := context.Background()

s := dubgo.New(
dubgo.WithSecurity("DUB_API_KEY"),
)

res, err := s.Domains.Create(ctx, &operations.CreateDomainRequestBody{
Slug: "acme.com",
ExpiredURL: dubgo.Pointer("https://acme.com/expired"),
NotFoundURL: dubgo.Pointer("https://acme.com/not-found"),
Placeholder: dubgo.Pointer("https://dub.co/help/article/what-is-dub"),
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
require 'dub'

Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
security: Models::Shared::Security.new(
token: 'DUB_API_KEY',
),
)

req = Models::Operations::CreateDomainRequestBody.new(
slug: 'acme.com',
expired_url: 'https://acme.com/expired',
not_found_url: 'https://acme.com/not-found',
placeholder: 'https://dub.co/help/article/what-is-dub',
)

res = s.domains.create(request: req)

unless res.nil?
# handle response
end
import { Dub } from "dub";

const dub = new Dub({
token: "DUB_API_KEY",
});

async function run() {
const result = await dub.domains.create();

console.log(result);
}

run();
curl --request POST \
--url https://api.dub.co/domains \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"slug": "acme.com",
"expiredUrl": "https://acme.com/expired",
"notFoundUrl": "https://acme.com/not-found",
"archived": false,
"placeholder": "https://dub.co/help/article/what-is-dub",
"logo": "<string>",
"assetLinks": "<string>",
"appleAppSiteAssociation": "<string>"
}
'
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
slug: 'acme.com',
expiredUrl: 'https://acme.com/expired',
notFoundUrl: 'https://acme.com/not-found',
archived: false,
placeholder: 'https://dub.co/help/article/what-is-dub',
logo: '<string>',
assetLinks: '<string>',
appleAppSiteAssociation: '<string>'
})
};

fetch('https://api.dub.co/domains', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
HttpResponse<String> response = Unirest.post("https://api.dub.co/domains")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"slug\": \"acme.com\",\n \"expiredUrl\": \"https://acme.com/expired\",\n \"notFoundUrl\": \"https://acme.com/not-found\",\n \"archived\": false,\n \"placeholder\": \"https://dub.co/help/article/what-is-dub\",\n \"logo\": \"<string>\",\n \"assetLinks\": \"<string>\",\n \"appleAppSiteAssociation\": \"<string>\"\n}")
.asString();
{
  "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
  }
}
{
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#bad-request"
}
}
{
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#unauthorized"
}
}
{
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#forbidden"
}
}
{
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#not-found"
}
}
{
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#conflict"
}
}
{
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#invite-expired"
}
}
{
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#unprocessable-entity"
}
}
{
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#rate-limit_exceeded"
}
}
{
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://dub.co/docs/api-reference/errors#internal-server_error"
}
}

Authorizations

Authorization
string
header
required

Default authentication mechanism

Body

application/json
slug
string
required

Name of the domain.

Required string length: 1 - 190
Example:

"acme.com"

expiredUrl
string | null

Redirect users to a specific URL when any link under this domain has expired.

Maximum string length: 32000
Example:

"https://acme.com/expired"

notFoundUrl
string | null

Redirect users to a specific URL when a link under this domain doesn't exist.

Maximum string length: 32000
Example:

"https://acme.com/not-found"

archived
boolean
default:false

Whether to archive this domain. false will unarchive a previously archived domain.

Example:

false

placeholder
string | null

Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.

Maximum string length: 100
Example:

"https://dub.co/help/article/what-is-dub"

logo

The logo of the domain.

Pattern: ^data:image\/(png|jpeg|jpg|gif|webp);base64,

assetLinks.json configuration file (for deep link support on Android).

appleAppSiteAssociation
string | null

apple-app-site-association configuration file (for deep link support on iOS).

Response

The domain was created.

id
string
required

The unique identifier of the domain.

slug
string
required

The domain name.

Example:

"acme.com"

verified
boolean
default:false
required

Whether the domain is verified.

primary
boolean
default:false
required

Whether the domain is the primary domain for the workspace.

archived
boolean
default:false
required

Whether the domain is archived.

placeholder
string | null
required

Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.

Example:

"https://dub.co/help/article/what-is-dub"

expiredUrl
string | null
required

The URL to redirect to when a link under this domain has expired.

Example:

"https://acme.com/expired"

notFoundUrl
string | null
required

The URL to redirect to when a link under this domain doesn't exist.

Example:

"https://acme.com/not-found"

logo
string | null
required

The logo of the domain.

assetLinks.json configuration file (for deep link support on Android).

appleAppSiteAssociation
string | null
required

apple-app-site-association configuration file (for deep link support on iOS).

createdAt
string
required

The date the domain was created.

updatedAt
string
required

The date the domain was last updated.

registeredDomain
object | null
required

The registered domain record.