API Documentation
Programmatically create short links from your applications.
Getting Started
To use the API, you need an API key. Create one by signing in and visiting the API Keys page.
Include your API key in the Authorization header as a Bearer token.
Create Short Link
POST
/api/external/shortenRequest Body
| Parameter | Type | Description |
|---|---|---|
| originalUrl | string | Required. The URL to shorten. |
| slug | string | Optional. Custom slug (4-20 chars, alphanumeric with - and _). |
Example Request
curl -X POST https://cory.to/api/external/shorten \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"originalUrl": "https://example.com/very-long-url"}'Response
{
"slug": "abc1",
"shortUrl": "https://cory.to/abc1",
"originalUrl": "https://example.com/very-long-url",
"createdAt": "2024-01-15T12:00:00Z"
}JavaScript Example
const response = await fetch('https://cory.to/api/external/shorten', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk_your_api_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
originalUrl: 'https://example.com/very-long-url',
slug: 'custom-slug' // optional
}),
});
const data = await response.json();
console.log(data.shortUrl); // https://cory.to/custom-slugError Codes
| Code | Description |
|---|---|
| 400 | Bad request - Missing or invalid parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 409 | Conflict - Slug already exists |
| 500 | Server error |
Ready to get started?
Create an account to generate your API key.