Skip to content

URL Shortener API V3

The URL Shortener API enables applications to create shortened URLs and vanity links using URL shorteners configured for your Sprinklr environment. Use this API to:

  • Retrieve available URL shorteners.
  • Create standard shortened URLs.
  • Create vanity URLs using a custom link hash. To create a shortened URL, first retrieve the available shorteners and use the returned id as the urlShortenerId in the shorten request.

API Endpoints

OperationMethodPath
Fetch URL ShortenersGET/api/v3/link/shorteners
Shorten URLPOST/api/v3/link/shorten

Base URL

All API calls are sent to:

https://api3.sprinklr.com/{env}/api/v3

The URL Shortener resources are:

https://api3.sprinklr.com/{env}/api/v3/link/shorteners
https://api3.sprinklr.com/{env}/api/v3/link/shorten

Replace {env} with your assigned Sprinklr environment. See APIs | Sprinklr Developer Portal for the published environment list. For the production environment at app.sprinklr.com, omit the {env} segment from the URL.

Authentication & Headers

HeaderValuePurpose
AuthorizationBearer {{accessToken}}Bearer token used to authenticate the user with the server
Key{{apiKey}}API key that authenticates your application with the server
Content-Typeapplication/jsonRequired on POST /link/shorten
Acceptapplication/jsonAcceptable response type

Include Content-Type: application/json when sending a request body.

URL Shortener Operations

Fetch URL Shorterner

GET /link/shorteners

Retrieves the URL shorteners available for use. The response provides the shortener id required by the Shorten URL operation and indicates whether a shortener supports vanity links.

Example Request

curl --location --request GET \
'https://api3.sprinklr.com/{env}/api/v3/link/shorteners' \
--header 'Authorization: Bearer {access-token}' \
--header 'Key: {api-key}' \
--header 'Accept: application/json'

Example Response

{
  "data": [
    {
      "id": "0000000000000000000000a1",
      "name": "Corporate spr.ly",
      "provider": "SPRINKLR",
      "canUseForVanityLink": true
    },
    {
      "id": "0000000000000000000000b2",
      "name": "Marketing Bitly",
      "provider": "BITLY",
      "canUseForVanityLink": false
    }
  ],
  "errors": []
}

Response Parameters

FieldDescriptionType
idUnique identifier of the URL shortener. Use this value as urlShortenerId.String
nameName of the URL shortener.String
providerURL-shortening service provider.String
canUseForVanityLinkIndicates whether the shortener supports vanity links.Boolen

Shorten URL

POST /api/v3/link/shorten

Creates a shortened URL using the specified URL shortener.

Request Parameters

FieldTypeRequiredDescription
linkstringYesThe URL to be shortened. Provide a fully qualified URL including the scheme
urlShortenerIdstringYesThe URL shortener to use. Obtain this from GET /link/shorteners
namestringNoUnique name or URL hash. When supplied, it becomes the link hash, producing a vanity link
descriptionstringNoDescription of the URL being shortened

Obtain urlShortenerId from the Fetch URL Shorteners operation.

Example Request

curl --location --request POST \
  'https://api3.sprinklr.com/{env}/api/v3/link/shorten' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Key: {api-key}' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data '{
    "link": "https://www.example.com/spring-campaign-landing-page",
    "urlShortenerId": "0000000000000000000000a1"
  }'

Example Response

{
  "data": {
    "id": 600000000,
    "urlShortenerId": "0000000000000000000000a1",
    "linkHash": "6003ZAI5v",
    "originalLink": "https://www.example.com/spring-campaign-landing-page",
    "shortLink": "https://spr.ly/6003ZAI5v",
    "campaignId": -11
  },
  "errors": []
}

Use the returned shortLink as the shortened URL.

To create a vanity link, include name in the shorten request.

The selected URL shortener must return:

{
"canUseForVanityLink": true
}

Example Request:

curl --location --request POST \
  'https://api3.sprinklr.com/{env}/api/v3/link/shorten' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Key: {api-key}' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data '{
    "link": "https://www.example.com/spring-campaign-landing-page",
    "urlShortenerId": "0000000000000000000000a1",
    "name": "SpringSale"
  }'

Example Reponse

{
  "data": {
    "id": 600000001,
    "urlShortenerId": "0000000000000000000000a1",
    "linkHash": "SpringSale",
    "originalLink": "https://www.example.com/spring-campaign-landing-page",
    "shortLink": "https://spr.ly/SpringSale",
    "campaignId": -10,
    "domain": "spr.ly"
  },
  "errors": []
}
ParameterDescriptionType
idUnique identifier of the shortened link.Integer (int64)
urlShortenerIdIdentifier of the URL shortener used.String
linkHashHash associated with the shortened URL.String
originalLinkOriginal URL submitted for shortening.String
shortLinkGenerated shortened URL.String
campaignIdCampaign identifier associated with the shortened URL.Integer (int64)
descriptionDescription of the shortened URL.String
domainDomain used for the shortened URL.String
providerURL-shortening provider.String
createdTimeCreation timestamp.Integer (int64)
modifiedTimeLast modified timestamp.Integer (int64)
archivedIndicates whether the link is archived.Boolean

Response format and status codes

Response envelope

Every Sprinklr V3 response is wrapped in a standard envelope:

{
  "data": { },
  "errors": [ ]
}

GET /link/shorteners returns an array in data. POST /link/shorten returns a single object in data.

Each entry in errors contains:

FieldTypeDescription
idstringError identifier
codestringError code
messagestringHuman-readable message

Bind your client to this envelope, and inspect the errors array even when the HTTP status indicates success.

Status codes

CodeMeaningHandling
200SuccessReturned by GET /link/shorteners
201CreatedReturned by POST /link/shorten on success
400Bad requestA required field is missing, the URL is malformed, or the vanity name was rejected
401UnauthorizedExpired token, wrong environment, or a missing authentication header
403ForbiddenYour user lacks permission for the shortener, or the partner is not entitled
404Not foundTypically an unrecognised urlShortenerId

Accept both 200 and 201 as success on POST /link/shorten, or check for any 2xx.

Rate limiting is applied at the Sprinklr API gateway across the platform. Implement retry with exponential backoff for 429 and 5xx responses, and honour the Retry-After header when it is present. Because shortening is not idempotent, retry only on network-level failures and on 429, and be aware that retrying after a timeout may create a second link.

About error messages

Validation errors for shortening are surfaced from the external shortening provider rather than generated by Sprinklr. This has three practical consequences:

  • Error message text and codes are not stable across providers. A partner using Bitly and a partner using spr.ly can receive different error bodies for the same mistake.
  • Branch your error handling on the HTTP status code rather than on the message text.
  • Log the full errors array and surface the message to an operator rather than attempting to parse it.

Migrating from V2

The short version

Change v2 to v3 in the path. For most integrations, that is the entire migration.

V2V3
ShortenPOST /{env}/api/v2/link/shortenPOST /{env}/api/v3/link/shorten
List shortenersGET /{env}/api/v2/link/shortenersGET /{env}/api/v3/link/shorteners
Request fieldslink, urlShortenerId, nameUnchanged
Required fieldslink, urlShortenerIdUnchanged
Response envelope{data, errors}Unchanged
Authentication headersAuthorization, KeyUnchanged
Success status on shorten200201

The two things that genuinely differ

Success status code. V2 returned 200 on shortening. V3 returns 201 Created. A client written as if (status === 200) will treat a successful V3 creation as a failure. This is the most likely cause of a broken migration. Widen the check to accept 200 and 201, or accept any 2xx.

Link hash format for standard links. In V2, the standard-link linkHash was the decimal string form of the numeric id, for example id: 101612830 with linkHash: "101612830". In V3, standard links return an alphanumeric token unrelated to the id. If any code derives one value from the other, or validates that linkHash is numeric, update it to read linkHash and shortLink directly from the response.

Vanity links are unaffected, because their hash has always been the name you supply.

What did not change

Request field names and semantics, the required field set, the {data, errors} envelope, the campaignId sentinels (-10 for vanity, -11 for standard), authentication, and the vanity-capability rule are all identical. Error responses are also unchanged, because validation errors originate from the external shortening provider in both versions.

Common Use Cases

Shorten a link for a scheduled campaign post

Fetch the shortener list once at start-up and cache it. For each URL, call POST /link/shorten with link and the cached urlShortenerId, then publish data.shortLink. Store data.id and data.linkHash alongside your campaign record so reporting can be correlated later.

Select a shortener where canUseForVanityLink is true, then post with name set to the hash you want. Confirm success by checking that data.linkHash equals the name you sent and that campaignId is -10. If the hash comes back different, you did not receive the vanity link you requested, so do not publish it as one.

Expose a thin wrapper over POST /link/shorten and maintain your own mapping from original URL to short link. Check your mapping first and call Sprinklr only on a miss. This keeps your short-link inventory stable and avoids creating a new link each time the same URL is submitted.

Choose between multiple configured shorteners

GET /link/shorteners returns name and provider for each entry. Use name for human-facing selection and provider when behaviour depends on the underlying service. Keep the choice configurable so the same code works across environments and partners.


Best practices

  • Cache the shorteners list. It changes only when an administrator adds or removes a shortener. Fetch it at start-up rather than before every shortening call.
  • Persist the creation response. Store id, linkHash, and shortLink when the link is created. These values are returned at creation time.
  • Accept 200 and 201 as success on shortening.
  • Null-check optional fields. Depend only on id, urlShortenerId, linkHash, originalLink, shortLink, and campaignId.
  • Read the scheme from shortLink. Embed the returned string as-is rather than reconstructing the URL from domain and linkHash.
  • Deduplicate before retrying. Shortening is not idempotent, so a retry after a timeout can create a duplicate link.
  • Check canUseForVanityLink before requesting a vanity link, and treat a missing value as false.
  • Do not look up campaignId values of -10 or -11. These are sentinel values indicating a vanity or standard link, not references to a real campaign.
  • Keep shortener IDs in configuration, not in code, because they differ across environments and partners.

Firebase shorteners. Google deprecated its Firebase URL shortener, and Firebase shorteners are no longer supported in Sprinklr effective 25 August 2025. If your integration selects a shortener by provider, ensure it does not target Firebase.


Troubleshooting

SymptomLikely causeResolution
401 on every callWrong {env}, expired access token, or a missing Key headerConfirm the environment, refresh the token, and send both authentication headers
400 with an unclear messageA required field is missing, or the provider rejected the requestConfirm link and urlShortenerId are both present and that link includes a scheme
404 on shorteningurlShortenerId does not exist or is not visible to your userRe-fetch GET /link/shorteners and use an id from that response
Vanity name ignored, standard hash returnedThe shortener does not support vanity linksCheck canUseForVanityLink and select a different shortener
Vanity request rejectedThe hash is already claimed on that domainRetry with a different name
Client fails to deserialize the responseClient bound to the inner object rather than the envelopeBind to {data, errors} and read the payload from data
Duplicate short links after a retryShortening is not idempotentDeduplicate against your own mapping before retrying
Success status but nothing usable in dataAn error was returned alongside a success statusInspect the errors array on every response

Product documentation