Bind your own domain to U301 for shorten links. After creation, you should get domain details for DNS configuration.
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);Request
| Name | Location | Type | Required | Default | Description |
|---|---|---|---|---|---|
| Authorization | Header | string | Bearer token used for authentication. | ||
| workspaceId | Query | string | Workspace identifier for multi‑tenant routing. | ||
| domain | Body | string | u301.co | Domain for the short link. | |
| shortCodeLength | Body | number | 6 | Length of the random path segment. |
Response
Return { success: true } on success, or throw an error if the domain creation failed.
| Name | Type | Description |
|---|---|---|
| success | boolean | Whether the domain creation was successful. |
{
"success": true
}Last updated on