API Documentation
Integrate URL shortening into your apps with the Brk.Im REST API.
API Playground
Try the API live — no setup needed for public endpoints.
Quick Start
Base URL: https://brk.im/api/v1
All API responses are JSON. Authenticated endpoints require a Bearer token in the Authorization header.
Get your API token:
curl -X POST https://brk.im/api/v1/login \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com", "password": "yourpassword"}'
The token is valid for 90 days. Include it as: Authorization: Bearer YOUR_TOKEN
POST
/api/v1/shorten
Create a short URL
Request
{
"long_url": "https://example.com/very/long/page",
"custom_code": "my-link" // optional
}
Response (201 Created)
{
"code": "my-link",
"short_url": "https://brk.im/my-link"
}
Requires Bearer token. Returns 409 if custom code is already taken, 422 if long_url is missing.
GET
/api/v1/expand/{code}
Resolve a short URL to its long URL
Example
curl https://brk.im/api/v1/expand/my-link
Response (200 OK)
{
"code": "my-link",
"long_url": "https://example.com/very/long/page",
"created_at": "2025-08-07 12:34:56"
}
Public endpoint, no authentication required. Returns 404 if code not found.
GET
/api/v1/stats/{code}
Get click analytics
Example
curl https://brk.im/api/v1/stats/my-link
Response (200 OK)
{
"code": "my-link",
"target_url": "https://example.com/very/long/page",
"clicks": 142
}
Public endpoint, no authentication required.
DELETE
/api/v1/urls/{code}
Delete a short URL
Example
curl -X DELETE https://brk.im/api/v1/urls/my-link \ -H "Authorization: Bearer YOUR_TOKEN"
Response (200 OK)
{
"deleted": true
}
Requires Bearer token. You can only delete URLs belonging to your tenant.
POST
/api/v1/login
Authenticate and get API token
Request
{
"email": "you@example.com",
"password": "yourpassword"
}
Response (200 OK)
{
"token": "abc123...",
"tenant_id": 1,
"user_id": 5,
"role": "user"
}
Rate Limits
| Endpoint | Limit | Window |
|---|---|---|
| Guest shortening | 10 requests | 5 minutes |
| Authenticated API | Unlimited | — |
Try it in Postman
Import the full API collection with one click.
