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
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"
}
}Domains
Create a domain
Create a domain for the authenticated workspace.
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
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"
}
}Body
application/json
Response
The domain was created.