Skip to main content
POST
/
links
/
bulk
PHP
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\RequestBody(
        url: 'https://google.com',
        externalId: '123456',
        tagIds: [
            'clux0rgak00011...',
        ],
        testVariants: [
            new Operations\BulkCreateLinksTestVariants(
                url: 'https://example.com/variant-1',
                percentage: 50,
            ),
            new Operations\BulkCreateLinksTestVariants(
                url: 'https://example.com/variant-2',
                percentage: 50,
            ),
        ],
    ),
];

$response = $sdk->links->createMany(
    request: $request
);

if ($response->responseBodies !== null) {
    // handle response
}
[
  {
    "id": "<string>",
    "domain": "<string>",
    "key": "<string>",
    "url": "<string>",
    "trackConversion": false,
    "externalId": "<string>",
    "tenantId": "<string>",
    "programId": "<string>",
    "partnerId": "<string>",
    "archived": false,
    "expiresAt": "<string>",
    "expiredUrl": "<string>",
    "disabledAt": "<string>",
    "password": "<string>",
    "proxy": false,
    "title": "<string>",
    "description": "<string>",
    "image": "<string>",
    "video": "<string>",
    "rewrite": false,
    "doIndex": false,
    "ios": "<string>",
    "android": "<string>",
    "geo": {},
    "publicStats": false,
    "tags": [
      {
        "id": "<string>",
        "name": "<string>",
        "color": "red"
      }
    ],
    "folderId": "<string>",
    "webhookIds": [
      "<string>"
    ],
    "comments": "<string>",
    "shortLink": "<string>",
    "qrCode": "<string>",
    "utm_source": "<string>",
    "utm_medium": "<string>",
    "utm_campaign": "<string>",
    "utm_term": "<string>",
    "utm_content": "<string>",
    "testVariants": [
      {
        "url": "https://example.com/variant-1",
        "percentage": 50
      },
      {
        "url": "https://example.com/variant-2",
        "percentage": 50
      }
    ],
    "testStartedAt": "<string>",
    "testCompletedAt": "<string>",
    "userId": "<string>",
    "workspaceId": "<string>",
    "clicks": 0,
    "leads": 0,
    "conversions": 0,
    "sales": 0,
    "saleAmount": 0,
    "lastClicked": "<string>",
    "createdAt": "<string>",
    "updatedAt": "<string>",
    "tagId": "<string>",
    "projectId": "<string>"
  }
]
We currently do not send webhook events for bulk link creation.

Authorizations

Authorization
string
header
required

Body

application/json · object[]
url
string
required
Maximum length: 32000
Example:
domain
string
Maximum length: 190
key
string
Maximum length: 190
keyLength
number
Required range: 3 <= x <= 190
externalId
string | null
Required string length: 1 - 255
Example:
tenantId
string | null
Maximum length: 255
programId
string | null
partnerId
string | null
prefix
string
trackConversion
boolean
archived
boolean
tagIds
Example:
tagNames
folderId
string | null
comments
string | null
expiresAt
string | null
expiredUrl
string | null
Maximum length: 32000
password
string | null
proxy
boolean
title
string | null
description
string | null
image
string | null
video
string | null
rewrite
boolean
ios
string | null
Maximum length: 32000
android
string | null
Maximum length: 32000
geo
object | null
doIndex
boolean
utm_source
string | null
utm_medium
string | null
utm_campaign
string | null
utm_term
string | null
utm_content
string | null
ref
string | null
webhookIds
string[] | null
testVariants
object[] | null
Required array length: 2 - 4 elements
Example:
testStartedAt
string | null
testCompletedAt
string | null
publicStats
boolean
deprecated
tagId
string | null
deprecated

Response

id
string
required
domain
string
required
key
string
required
url
string<uri>
required
trackConversion
boolean
default:false
required
externalId
string | null
required
tenantId
string | null
required
programId
string | null
required
partnerId
string | null
required
archived
boolean
default:false
required
expiresAt
string | null
required
expiredUrl
string<uri> | null
required
disabledAt
string | null
required
password
string | null
required
proxy
boolean
default:false
required
title
string | null
required
description
string | null
required
image
string | null
required
video
string | null
required
rewrite
boolean
default:false
required
doIndex
boolean
default:false
required
ios
string | null
required
android
string | null
required
geo
object | null
required
publicStats
boolean
default:false
required
tags
LinkTag · object[] | null
required
folderId
string | null
required
webhookIds
string[]
required
comments
string | null
required
qrCode
string<uri>
required
utm_source
string | null
required
utm_medium
string | null
required
utm_campaign
string | null
required
utm_term
string | null
required
utm_content
string | null
required
userId
string | null
required
workspaceId
string
required
clicks
number
default:0
required
leads
number
default:0
required
conversions
number
default:0
required
sales
number
default:0
required
saleAmount
number
default:0
required
lastClicked
string | null
required
createdAt
string
required
updatedAt
string
required
tagId
string | null
required
deprecated
projectId
string
required
deprecated
testVariants
object[] | null
Required array length: 2 - 4 elements
Example:
testStartedAt
string | null
testCompletedAt
string | null