Links
(links)
Available Operations
- list - Retrieve a list of links
- create - Create a new link
- count - Retrieve the number of links
- get - Retrieve a link
- delete - Delete a link
- update - Update a link
- createMany - Bulk create links
- upsert - Upsert a link
list
Retrieve a list of links for the authenticated workspace. The list will be paginated and the provided query parameters allow filtering the returned links.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.list({});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetLinksRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<components.LinkSchema[]>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
create
Create a new link for the authenticated workspace.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.create({
url: "https://google/com",
});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateLinkRequestBody | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<components.LinkSchema>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
count
Retrieve the number of links for the authenticated workspace. The provided query parameters allow filtering the returned links.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.count({});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetLinksCountRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<number>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
get
Retrieve the info for a link.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.get({});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetLinkInfoRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<components.LinkSchema>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
delete
Delete a link for the authenticated workspace.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.delete("<value>");
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
linkId |
string | ✔️ | The id of the link to delete. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<operations.DeleteLinkResponseBody>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
update
Update a link for the authenticated workspace. If there's no change, returns it as it is.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.update("<value>", {
url: "https://google/com",
});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
linkId |
string | ✔️ | The id of the link to update. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_. |
requestBody |
operations.UpdateLinkRequestBody | ➖ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<components.LinkSchema>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
createMany
Bulk create up to 100 links for the authenticated workspace.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.createMany([
{
url: "https://google/com",
},
]);
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.RequestBody[] | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<components.LinkSchema[]>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
upsert
Upsert a link for the authenticated workspace by its URL. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created.
Example Usage
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
workspaceId: "<value>",
});
async function run() {
const result = await dub.links.upsert({
url: "https://google/com",
});
// Handle the result
console.log(result)
}
run();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpsertLinkRequestBody | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
Response
Promise<components.LinkSchema>
Errors
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.Conflict | 409 | application/json |
| errors.InviteExpired | 410 | application/json |
| errors.UnprocessableEntity | 422 | application/json |
| errors.RateLimitExceeded | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |