Skip to content

Shorten links from your CRM

Create one link per message, apply a UTM template so attribution is consistent, and store short_url with the contact.

Create one link per message, apply a UTM template so attribution is consistent, and store short_url with the contact.

const template = await uc.utmTemplates.create({
  name: 'WhatsApp broadcast',
  utm: { source: 'whatsapp', medium: 'broadcast', campaign: '{{campaign}}', content: '{{slug}}' },
});

for (const contact of contacts) {
  const link = await uc.links.create(
    { destination_url: contact.offerUrl, domain: 'go.brand.in', utm_template_id: template.id, campaign_id: campaign.id,
      metadata: { crm_contact_id: contact.id } },
    { idempotencyKey: `crm-${campaign.id}-${contact.id}` },
  );
  await crm.saveShortLink(contact.id, link.short_url);
}

Tips: use metadata to store your own ids (up to 20 keys); check GET /v1/links/availability?domain=go.brand.in&slug=… before offering a vanity slug; a custom slug needs Starter or above (on Free, omit it to get a random 7-character code, or the request fails with 403 feature_not_in_plan, param: custom_slugs); on crop.sh random codes are never reused, and a custom slug released by a rename or permanent deletion (30 days after you delete the link) is held for 30 days if the link was live for at least 24 hours or got a click, during which only the workspace that released it can claim it again (available_after tells you when a hold ends; it is absent for random codes; test-mode links create no holds); watch for 403 plan_limit_reached with param: links_per_month.