The SDK is currently in active development. For more details, see the U301 Postman docs.

Create a domain for your workspace

Bind your own domain to U301 for shorten links. After creation, you should get domain details for DNS configuration.

u301.domains.create
import { U301 } from 'u301';

const apiKey = '<YOUR_API_KEY>';
const workspaceId = '<YOUR_WORKSPACE_ID>';

const u301 = new U301({
  apiKey,
  workspaceId,
});
const domain = await u301.domains.create('t.example.com', { // [!code highlight]
    randomSlugLength: 6 // [!code highlight]
}); // [!code highlight]
console.log(domain);

the response

Request

NameLocationTypeRequiredDefaultDescription
AuthorizationHeaderstringBearer token used for authentication.
workspaceIdQuerystringWorkspace identifier for multi‑tenant routing.
domainBodystringu301.coDomain for the short link.
shortCodeLengthBodynumber6Length of the random path segment.

Response

Return { success: true } on success, or throw an error if the domain creation failed.

NameTypeDescription
successbooleanWhether the domain creation was successful.
response-example.json
{
  "success": true
}

Last updated on

On this page