Skip to main content

fetchNewCommsUrl()

function fetchNewCommsUrl(args: FetchNewCommsUrlArgs, options?: MigrationOptions): Promise<string>;

Translates a Twist URL to its equivalent Comms URL using Twist's comms_migration/fetch_new_url endpoint.

Authenticates with a Twist token (external to the Comms SDK), so this is a standalone helper rather than a method on CommsApi.

Parameters

ParameterType
argsFetchNewCommsUrlArgs
options?MigrationOptions

Returns

Promise<string>

The equivalent Comms URL.

Example

const newUrl = await fetchNewCommsUrl({
oldUrl: 'https://twist.com/a/123/ch/456/t/789',
twistToken: process.env.TWIST_AUTH_TOKEN,
})

Throws

CommsRequestError If the request fails. URLs that cannot be migrated surface as a thrown error too: 400 with responseData.error.code of 'invalid_url', or 404 with 'not_imported'.