← Back to blog

A URL shortener with an API: the TinyX API and webhooks

· TinyX · 5 min read

A URL shortener with an API: the TinyX API and webhooks

Every Monday someone on your team creates the same 30 short links for the week's newsletter, campaign and social posts. Every Friday someone else copies the click counts into a spreadsheet. Neither job needs a person.

If links, files and forms are part of a process you run every week, a URL shortener API and a few webhooks can take the copying and pasting out of it.

What a URL shortener with an API is for

A dashboard is fine for ten links. It is slow for a hundred, and it can't react to something happening in another system.

An API lets your own code do what you would otherwise click through: create a link when a blog post is published, attach an expiry date to every file your CRM sends, or pull access logs into a weekly report. Webhooks work the other way round. Instead of you asking TinyX what happened, TinyX tells your system as soon as it does.

Use the API to make things, and webhooks to hear about them. Most automations need both.

What the TinyX REST API covers

The API lives at /api/v1 and is described in an OpenAPI document you can read at tinyx.co/api/v1/docs. It covers links, files, webhooks and your account's keys.

With it you can list, create, read and delete links, including file links, upload links and questionnaires. You can upload and download files, read a link's access logs, and fetch questionnaire responses as CSV or JSON. You can also create, test and delete webhooks.

The REST API is on Pro and Max only. Free has no API keys. Pro includes 5 keys and Max 20, as listed on the pricing page.

Giving each script only the access it needs

You create API keys in the dashboard while signed in. Each request then sends the key as a bearer token in the Authorization header.

Each key carries scopes, so you can limit what it can do. Links, files and webhooks each have separate read and write scopes. A script that only creates links for your CMS needs links:write and nothing else. If that key ever leaks, it can't delete your files.

Keep keys out of front-end code and public repositories, and give each integration its own key so you can revoke one without breaking the rest.

Creating a link from your own code

Creating a link is a single POST to /api/v1/links. This example creates a short link with a password, an expiry date and a note:

curl -X POST https://tinyx.co/api/v1/links \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "target": "https://example.com/launch",
    "password": "spring-launch",
    "expiresAt": "2026-12-31T23:59:00Z",
    "notes": "Newsletter, week 49"
  }'

The response includes the new link's short code and URL. The same endpoint creates upload links and questionnaires with the matching fields, which are listed in the API docs.

End-to-end encrypted links can't be created through the API yet either. Use the dashboard for those. Galleries and folder links are dashboard-only too.

Webhooks: hearing about events as they happen

A webhook is an HTTP request TinyX sends to a URL you choose when something happens on a link. The URL can be a Slack or Discord incoming webhook, an automation tool such as n8n, Make or Zapier, or your own server.

Webhooks are on every plan, Free included (1 on Free, 5 on Pro, 20 on Max). You attach a webhook to a link, and it receives every event on that link. You can't pick events, so filter on the event type at the receiving end.

The events are link.visited, link.redirected, link.viewed, link.downloaded, encrypted.downloaded, link.uploaded, questionnaire.response, link.created and link.deleted. Each request carries a JSON payload saying what happened and on which link.

Three automations worth building

The first is a Slack message when a client uploads. Attach a webhook to an upload link, filter for link.uploaded, and post the file name to your team channel. Upload links: a file inbox anyone can send to covers the link side.

The second is form responses straight into your CRM. Filter for questionnaire.response and pass the answers on. By default, those answers carry the respondent's IP address and location until you delete them. On Pro and Max, you can choose to encrypt questionnaire answers in the respondent's browser, using a password you set when you create the questionnaire. Only the answers are encrypted, not the questions, and if the password is lost the answers can't be recovered. Encrypted questionnaires keep the respondent's country, but not their IP address or city. Encrypted questionnaires are set up in the dashboard; the API creates standard questionnaires.

The third is a weekly click report. Use the API to read each campaign link's access logs and write the counts to a sheet. Access logs are kept for 7, 90 or 365 days depending on plan, so schedule the job well inside your plan's window. Campaign links for brands and agencies shows how to structure the links first.

Frequently asked questions

Is the TinyX API free?

No. Webhooks are on every plan; the API needs a paid key (see pricing).

Can I choose which events a webhook receives?

No. A webhook receives every event on the link it is attached to. Filter by event type when you receive it.

Can I export questionnaire responses through the API?

Yes, as CSV or JSON. The dashboard export gives you CSV on every plan.

Automating your first link job this week

If you are on Free, start with a webhook on one link and send its events to a Slack channel. If you are on Pro or Max, create one scoped key, read the API docs, and automate the one link job your team repeats every week.