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
endimport { 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"
}
}Create a domain
Create a domain for the authenticated workspace.
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
endimport { 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
Default authentication mechanism
Body
Name of the domain.
1 - 190"acme.com"
Redirect users to a specific URL when any link under this domain has expired.
32000"https://acme.com/expired"
Redirect users to a specific URL when a link under this domain doesn't exist.
32000"https://acme.com/not-found"
Whether to archive this domain. false will unarchive a previously archived domain.
false
Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.
100"https://dub.co/help/article/what-is-dub"
The logo of the domain.
^data:image\/(png|jpeg|jpg|gif|webp);base64,assetLinks.json configuration file (for deep link support on Android).
apple-app-site-association configuration file (for deep link support on iOS).
Response
The domain was created.
The unique identifier of the domain.
The domain name.
"acme.com"
Whether the domain is verified.
Whether the domain is the primary domain for the workspace.
Whether the domain is archived.
Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.
"https://dub.co/help/article/what-is-dub"
The URL to redirect to when a link under this domain has expired.
"https://acme.com/expired"
The URL to redirect to when a link under this domain doesn't exist.
"https://acme.com/not-found"
The logo of the domain.
assetLinks.json configuration file (for deep link support on Android).
apple-app-site-association configuration file (for deep link support on iOS).
The date the domain was created.
The date the domain was last updated.
The registered domain record.
Show child attributes
Show child attributes