You can list all short links in your workspace using the u301.links.list method.
Here's a minimal example to demonstrate how to list links.
import { U301 } from 'u301';
const apiKey = '<YOUR_API_KEY>';
const workspaceId = '<YOUR_WORKSPACE_ID>';
const u301 = new U301({
apiKey,
workspaceId,
});
const links = await u301.links.list(); // [!code highlight]
console.log(links);Request
| Name | Location | Type | Required | Default | Description |
|---|---|---|---|---|---|
Authorization | Header | string | Bearer token used for authentication. | ||
workspaceId | Query | string | Workspace identifier for multi‑tenant routing. | ||
page | Query | number | Page number for pagination. | ||
perPage | Query | number | 10 | Number of items per page. |
Response
| Name | Type | Description |
|---|---|---|
links | array | Array of link objects. |
links[].id | string | Unique identifier of the link. |
links[].domainName | string | Domain used for the short link. |
links[].slug | string | Path segment of the short link. |
links[].isCustomSlug | boolean | Whether the slug was provided by the user. |
links[].shortUrl | string | Fully qualified short link ({domainName}/{slug}). |
links[].originalUrl | string | Original destination URL. |
links[].allowSearchEngineIndexing | boolean | Whether the link is indexable by search engines. |
links[].archived | boolean | Whether the link is archived. |
links[].suspended | boolean | Whether the link is suspended. |
links[].statsClicks | number | Total number of clicks. |
links[].expiresAt | string | Expiration timestamp; null if no expiry. |
links[].userId | string | Identifier of the link owner. |
links[].workspaceId | string | Workspace identifier. |
links[].comment | string | Optional note attached to the link. |
links[].createdAt | string | Timestamp of link creation. |
links[].updatedAt | string | Timestamp of last update; null if never updated. |
metadata | object | Pagination metadata. |
metadata.total | number | Total number of links. |
metadata.perPage | number | Number of items per page. |
metadata.page | number | Current page number. |
{
"links": [
{
"id": "019a8869-1700-7333-901b-0bfbc06eae6c",
"domainName": "u301.co",
"slug": "CWbEhQ",
"isCustomSlug": false,
"shortUrl": "u301.co/CWbEhQ",
"originalUrl": "https://nextjs.org/docs/app/guides/upgrading/version-16",
"allowSearchEngineIndexing": false,
"archived": false,
"suspended": false,
"statsClicks": 0,
"expiresAt": null,
"userId": "0196684a-3b57-7001-bd58-8c9bb1fcff27",
"workspaceId": "0196684a-3b57-7000-805b-88c32c3c5dc7",
"comment": "",
"createdAt": "2025-11-15T16:46:19.904Z",
"updatedAt": null
},
{
"id": "019a7dbe-a9ce-7d44-8bb6-2b6ed03aa48a",
"domainName": "u301.co",
"slug": "4jnB",
"isCustomSlug": false,
"shortUrl": "u301.co/4jnB",
"originalUrl": "https://example.com",
"allowSearchEngineIndexing": false,
"archived": false,
"suspended": false,
"statsClicks": 1,
"expiresAt": null,
"userId": "0196684a-3b57-7001-bd58-8c9bb1fcff27",
"workspaceId": "0196684a-3b57-7000-805b-88c32c3c5dc7",
"comment": "",
"createdAt": "2025-11-13T15:03:58.670Z",
"updatedAt": null
},
//...
],
"metadata": {
"total": 48,
"perPage": 20,
"page": 1
}
}Last updated on