← Back to blog

Free URL Shortener API: Create Short Links with curl or Python

August 23, 2026 · Eric · 6 min read

Long URLs are the worst part of working with links — in a Discord message, a log line, a tweet, or an agent's output, a 300-character tracking URL buries the actual destination. Short links fix that, and most URL shortener APIs want you to sign up for a developer account, hand over a card, and manage an API key before you can shorten a single link.

Agent Media Tools has a free URL shortener API that does the job in one request: POST /api/shorten. No API key, no signup, no OAuth dance. You send a URL, you get back a short link that 301-redirects to your target. It supports custom slugs, counts clicks, works over HTTPS from any language, and is also exposed as an MCP tool for agents.

What the API does

The shortener is part of the free sharing tools on agentmediatools.com, sitting alongside the pastebin, burn notes, dead drops, and webhook inboxes. Under the hood each short URL is stored with its target, and hitting the short path performs a permanent 301 redirect while incrementing a click counter.

EndpointMethodAuthWhat it does
/api/shortenPOSTNone requiredCreate a short link (optional custom slug)
/s/{slug}GETNone301 redirect to the target URL
/api/urlsGETLogged-in sessionList your links with click counts

Shorten a URL with curl

This is the entire API. One POST request with a JSON body:

curl -s -X POST https://agentmediatools.com/api/shorten \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/a/very/long/path?utm_source=agent&utm_medium=blog"}'

Response:

{"success":true,"slug":"xK3mPq","url":"https://agentmediatools.com/s/xK3mPq","short_url":"https://agentmediatools.com/s/xK3mPq"}

Take the url (or short_url) field and you're done. The generated slug is 6 characters, which keeps links comfortably short. Treat it as public, not as a secret.

Custom slugs

Want a readable, branded link instead of a random one? Pass custom_slug in the same request:

curl -s -X POST https://agentmediatools.com/api/shorten \
  -H "Content-Type: application/json" \
  -d '{"url": "https://agentmediatools.com/docs", "custom_slug": "amt-docs"}'
{"success":true,"slug":"amt-docs","url":"https://agentmediatools.com/s/amt-docs","short_url":"https://agentmediatools.com/s/amt-docs"}

If the slug is already taken, you get a 409 Conflict response instead of an overwrite:

{"error":"Slug already taken"}

That's a nice safety property for automation: you can generate a custom slug deterministically (say, from a job ID) and detect collisions without accidentally hijacking an existing link. The API only accepts http:// and https:// targets and returns a 400 for anything else, so you can't create links to javascript: or other schemes.

Shorten a URL with Python

The same call in Python with the standard requests library:

import requests

resp = requests.post(
    "https://agentmediatools.com/api/shorten",
    json={"url": "https://example.com/some/really/long/path?ref=agent"},
)
resp.raise_for_status()
data = resp.json()
print(data["short_url"])
# https://agentmediatools.com/s/Ab3xYz

To verify the redirect works (and prove the link is live), follow it and check the status code:

import requests

short = "https://agentmediatools.com/s/Ab3xYz"
r = requests.get(short, allow_redirects=False)
print(r.status_code)   # 301
print(r.headers["Location"])  # your original target URL

Because the redirect is a standard 301, it also passes link-expansion checks — good for making sure the short link you put in an email or a changelog actually points where you think it does.

Track clicks on your links

Every short URL records how many times it was hit. If you create links while logged in, you can list your own links with their click counts:

curl -s https://agentmediatools.com/api/urls -b cookies.txt
{"urls":[
  {"slug":"amt-docs","target_url":"https://agentmediatools.com/docs","clicks":42,"created_at":"2026-08-23T10:00:00.000Z"},
  {"slug":"Ab3xYz","target_url":"https://example.com/some/long/path","clicks":7,"created_at":"2026-08-23T09:30:00.000Z"}
]}

Anonymous visitors can shorten without an account, while the listing endpoint is available only to a signed-in browser session and only includes links created in that session. Bearer-key requests can create links, but they do not gain access to /api/urls.

Use it from an MCP agent

The same feature is exposed to MCP clients as the create_short_url tool. If your agent (Claude, or any MCP-capable assistant) is connected to the Agent Media Tools MCP server, it can shorten links natively:

create_short_url(url="https://example.com/very/long/tracking/link?campaign=launch")

That makes short links a natural step inside agent workflows — after an agent generates a paste or a chart, it can shorten the result before posting it to a channel, so the link it hands back is clean and shareable. Combined with the existing create_paste tool, you get a tidy two-step pattern: paste the long content, then shorten the paste URL.

A real agent workflow

Here's a complete mini-pipeline: an agent builds a report, uploads it as a paste, then shortens the paste URL for delivery.

import requests

# 1. Create a paste with the content
paste = requests.post(
    "https://agentmediatools.com/api/paste",
    json={"content": "Weekly report: all systems nominal", "title": "report-week-34"},
).json()

# 2. Shorten the paste URL so it fits anywhere
short = requests.post(
    "https://agentmediatools.com/api/shorten",
    json={"url": paste["url"], "custom_slug": "report-w34"},
).json()

print(short["short_url"])

One paste, one short link, zero accounts. That pattern is useful for any agent that produces URLs meant for humans: status updates, support handoffs, deployment notes, or shared artifacts.

Limits and rate considerations

The shortener is free to use without an API key, subject to the platform's daily free-tool allowance and an anonymous burst limit of 60 requests per minute. Logged-in sessions and requests carrying an agent API key skip the anonymous burst cap but retain their applicable daily allowance. Keep custom slugs meaningful but not secret — short URLs are obfuscation, not security.

Why use a hosted shortener instead of rolling your own?

Next time your agent needs to hand someone a link, shorten it first.

Try it in the Toolbox

Shorten links in the browser, or call the API from your agent with a free key. The Short URL tool is one click away in the sharing section.

Open toolbox