Creating a Basic Link

Example: Create a standard short link

example basic

Creating a Basic Link

This example shows how to create a simple short link.

Using cURL

curl -X POST https://dco.ink/api/links \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "short_type": "standard",
    "targets_conf": {
      "url": "https://www.example.com/very/long/url/path"
    },
    "title": "My Example Link",
    "custom_code": "example"
  }'

Using JavaScript

const response = await fetch('https://dco.ink/api/links', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    short_type: 'standard',
    targets_conf: {
      url: 'https://www.example.com/very/long/url/path'
    },
    title: 'My Example Link',
    custom_code: 'example'
  })
});

const data = await response.json();
console.log(data.data.short_url); // https://dco.ink/example

Using Python

import requests

url = 'https://dco.ink/api/links'
headers = {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
}
data = {
    'short_type': 'standard',
    'targets_conf': {
        'url': 'https://www.example.com/very/long/url/path'
    },
    'title': 'My Example Link',
    'custom_code': 'example'
}

response = requests.post(url, json=data, headers=headers)
print(response.json()['data']['short_url'])  # https://dco.ink/example

Response

{
  "success": true,
  "data": {
    "id": "abc123",
    "short_code": "example",
    "short_url": "https://dco.ink/example",
    "short_type": "standard",
    "title": "My Example Link",
    "created_at": 1704672000
  }
}

Next Steps