Short Links API

Create and retrieve hashb.ink short links programmatically using your HashBack API key. Links redirect instantly and track click counts automatically.

Base URL

https://api.hashback.co.ke

All API requests are HTTPS-only. Pass your API key as the X-API-Key header or as a api_key body field.


Create a Short Link

POST /shortlink/create

Shortens a URL and returns the compact hashb.ink link. Deducts 1 credit per new creation. If the same URL was previously shortened with your key the existing code is returned at no extra cost.

Accepts application/json or application/x-www-form-urlencoded. Rate limit: 10 requests / minute per API key.

ParameterTypeRequiredDescription
api_keystringYesYour HashBack developer API key
urlstringYesThe long URL to shorten (must be a valid URL, max 2048 chars)

Example request

curl -X POST https://api.hashback.co.ke/shortlink/create \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "url": "https://yourwebsite.co.ke/very/long/path?ref=campaign" }'

Success response 200

{ "success": true, "code": "xk3p2f", "short_url": "https://hashb.ink/xk3p2f", "url": "https://yourwebsite.co.ke/very/long/path?ref=campaign" }

Get Link Info

GET /shortlink/info

Returns the original URL and click count for a given short code.

ParameterTypeRequiredDescription
api_keystringYesYour HashBack developer API key
codestringYesThe short code (e.g. xk3p2f)

Example request

curl "https://api.hashback.co.ke/shortlink/info?api_key=YOUR_API_KEY&code=xk3p2f"

Success response 200

{ "success": true, "short_code": "xk3p2f", "url": "https://yourwebsite.co.ke/very/long/path?ref=campaign", "clicks": 142 }

Public Short Link Redirect

GET hashb.ink/{code}

No authentication needed. Visiting a short link:

OG tags served: og:title, og:description, og:image — populated from your Link Branding settings in the HashBack portal.


Error Codes

HTTPmessageMeaning
400Missing url parameterThe url field was empty or missing
400Invalid URLThe URL failed validation
400URL too longURL exceeds 2048 characters
401UnauthorizedMissing or invalid API key
402Insufficient creditsAccount has 0 credits remaining
404Link not foundNo short link exists for the given code
429Rate limit exceededToo many requests — max 10/min per API key
Set up Link Branding

Configure your business name, logo, and OG description in the HashBack portal so every short link preview shows your brand on WhatsApp, Slack, and iMessage.

Go to portal →