Examples
Authentication
Test API Key
curl -X GET https://relink.is/api/v1/validate \
-H "Authorization: Bearer rlk_your_api_key_here"Response:
{
"success": true,
"message": "API key is valid",
"data": null,
"timestamp": "2024-01-15T10:30:00.000Z"
}Creating Smartlinks
The API uses a GraphQL-like reactive body approach where the request body automatically adapts based on the smartlink type specified.
Create App Smartlink (Minimal)
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Test App",
"smartlinkType": "App"
}
}'Create App Smartlink (Full Configuration)
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Full App",
"smartlinkUrl": "fullapp",
"smartlinkType": "App",
"appStoreLink": "https://apps.apple.com/app/fullapp",
"googlePlayLink": "https://play.google.com/store/apps/details?id=fullapp",
"fallBackLink": "https://fullapp.com"
},
"openGraph": {
"title": "Full App",
"description": "A comprehensive test app",
"imageUrl": "https://fullapp.com/og.jpg"
}
}'Create URL Shortener
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Test URL",
"smartlinkUrl": "testurl",
"smartlinkType": "Url"
},
"shortener": {
"url": "https://google.com"
}
}'Create Landing Page
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Test Landing",
"smartlinkUrl": "testlanding",
"smartlinkType": "Landing"
},
"landing": {
"title": "My Landing Page",
"description": "Test landing page",
"themeColor": "#007bff"
},
"landingButtons": [
{
"title": "Button 1",
"link": "https://example.com"
}
]
}'Create QR Tag (Restaurant Menu Example)
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Restaurant QR Menu",
"smartlinkUrl": "menuqr",
"smartlinkType": "QRTag"
},
"qrTag": {
"title": "Our Menu",
"description": "Scan to view our delicious menu",
"logoLink": "https://restaurant.com/logo.png",
"themeColor": "#ff6b35"
},
"qrTagButtons": [
{
"title": "View Menu",
"link": "https://restaurant.com/menu",
"preset": "restaurant"
},
{
"title": "Order Online",
"link": "https://restaurant.com/order",
"preset": "delivery"
},
{
"title": "Call Us",
"link": "tel:+1234567890",
"preset": "phone"
},
{
"title": "Reserve Table",
"link": "https://restaurant.com/reservations",
"preset": "calendar"
}
],
"openGraph": {
"title": "Restaurant Menu",
"description": "Browse our menu and order online",
"imageUrl": "https://restaurant.com/menu-image.jpg"
}
}'Create Digital Card (Professional)
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Test DigiCard",
"smartlinkUrl": "testcard",
"smartlinkType": "DigiCard"
},
"digiCard": {
"title": "John Doe",
"jobTitle": "Developer",
"company": "Test Company"
},
"digiCardButtons": [
{
"title": "Contact",
"link": "mailto:[email protected]",
"preset": "email"
}
]
}'Create Text Bin (Code Snippet)
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Test TxtBin",
"smartlinkUrl": "testtxt",
"smartlinkType": "TxtBin"
},
"txtBin": {
"title": "Test Text",
"description": "Test text description",
"text": "This is a test text content"
}
}'Create QR Menu (with variants)
curl -X POST https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"smartlinkName": "Cafe Menu",
"smartlinkUrl": "cafemenu",
"smartlinkType": "QrMenu"
},
"qrMenu": {
"title": "Downtown Cafe",
"currency": "₼",
"layout": "List",
"theme": "Light",
"categories": [
{
"name": "Coffee",
"items": [
{
"name": "Latte",
"description": "Espresso with steamed milk",
"price": 5,
"variants": [
{ "label": "Small", "price": 5 },
{ "label": "Large", "price": 7 }
],
"badges": ["Popular"]
}
]
}
]
}
}'Partial Updates (PATCH)
The API supports GraphQL-like partial updates where only the fields you specify are updated. Zod validates and processes only the relevant fields.
Update Only App Store Link
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"configuration": {
"appStoreLink": "https://apps.apple.com/app/myapp"
}
}'Update Only Open Graph Data
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"openGraph": {
"title": "Updated App Title",
"description": "Updated app description"
}
}'Update Only Landing Buttons
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"landingButtons": [
{
"title": "New Button",
"link": "https://example.com/new",
"iconUrl": "https://example.com/icon.png"
}
]
}'Update Smartlink Name and URL
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"configuration": {
"smartlinkName": "Updated Name",
"smartlinkUrl": "updated-url"
}
}'Update QR Tag Buttons
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"qrTagButtons": [
{
"title": "Menu",
"link": "https://restaurant.com/menu",
"preset": "restaurant"
}
]
}'Update Digital Card Contact Info
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"digiCard": {
"jobTitle": "Lead Software Engineer",
"company": "New Tech Company Ltd.",
"ctaText": "Let'"'"'s Build Something Amazing!"
}
}'Update Text Bin Content
curl -X PATCH https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"id": "clp123abc456def",
"txtBin": {
"title": "Updated React Component",
"description": "Enhanced React component with TypeScript",
"text": "import React, { useState, useEffect } from '"'"'react'"'"';\n\ninterface MyComponentProps {\n initialCount?: number;\n title?: string;\n}\n\nfunction MyComponent({ initialCount = 0, title = '"'"'Counter'"'"' }: MyComponentProps) {\n const [count, setCount] = useState(initialCount);\n\n useEffect(() => {\n document.title = `${title}: ${count}`;\n }, [count, title]);\n\n return (\n <div>\n <h1>{title}: {count}</h1>\n <button onClick={() => setCount(count + 1)}>\n Increment\n </button>\n <button onClick={() => setCount(count - 1)}>\n Decrement\n </button>\n </div>\n );\n}\n\nexport default MyComponent;"
}
}'Retrieving Data
Get All Smartlinks
curl -X GET https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here"Get Specific Smartlink
curl -X GET "https://relink.is/api/v1/smartlink?id=clp123abc456def" \
-H "Authorization: Bearer rlk_your_api_key_here"Get Smartlink Analytics
curl -X GET "https://relink.is/api/v1/smartlink/analytics?id=clp123abc456def" \
-H "Authorization: Bearer rlk_your_api_key_here"Get Analytics Summary
curl -X GET https://relink.is/api/v1/analytics/summary \
-H "Authorization: Bearer rlk_your_api_key_here"Delete Smartlink
Soft Delete
curl -X DELETE https://relink.is/api/v1/smartlink \
-H "Authorization: Bearer rlk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"smartlinkId": "clp123abc456def"
}'JavaScript Examples
Using Fetch API
// Create App Smartlink
async function createAppSmartlink() {
const response = await fetch('https://relink.is/api/v1/smartlink', {
method: 'POST',
headers: {
'Authorization': 'Bearer rlk_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
configuration: {
smartlinkName: "My App",
smartlinkUrl: "myapp",
smartlinkType: "App",
appStoreLink: "https://apps.apple.com/app/myapp",
googlePlayLink: "https://play.google.com/store/apps/details?id=myapp",
fallBackLink: "https://myapp.com"
},
openGraph: {
title: "My Awesome App",
description: "Download my awesome app now!",
imageUrl: "https://myapp.com/og-image.jpg"
}
})
});
const result = await response.json();
console.log(result);
}
// Partial Update
async function updateAppStoreLink(smartlinkId, newAppStoreLink) {
const response = await fetch('https://relink.is/api/v1/smartlink', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer rlk_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: smartlinkId,
configuration: {
appStoreLink: newAppStoreLink
}
})
});
const result = await response.json();
console.log(result);
}
// Get Analytics
async function getAnalytics(smartlinkId) {
const response = await fetch(`https://relink.is/api/v1/smartlink/analytics?id=${smartlinkId}`, {
headers: {
'Authorization': 'Bearer rlk_your_api_key_here'
}
});
const result = await response.json();
console.log(result);
}Using Axios
import axios from 'axios';
const api = axios.create({
baseURL: 'https://relink.is/api/v1',
headers: {
'Authorization': 'Bearer rlk_your_api_key_here',
'Content-Type': 'application/json'
}
});
// Create Landing Page
async function createLandingPage() {
try {
const response = await api.post('/smartlink', {
configuration: {
smartlinkName: "My Landing Page",
smartlinkUrl: "mylanding",
smartlinkType: "Landing"
},
landing: {
title: "Welcome to My Landing Page",
description: "This is an awesome landing page",
themeColor: "#007bff"
},
landingButtons: [
{
title: "Visit Website",
link: "https://example.com"
},
{
title: "Contact Us",
link: "mailto:[email protected]"
}
]
});
console.log(response.data);
} catch (error) {
console.error(error.response.data);
}
}
// Update only specific fields
async function updateOnlyOpenGraph(smartlinkId) {
try {
const response = await api.patch('/smartlink', {
id: smartlinkId,
openGraph: {
title: "Updated Title",
description: "Updated description"
}
});
console.log(response.data);
} catch (error) {
console.error(error.response.data);
}
}Python Examples
import requests
import json
API_KEY = "rlk_your_api_key_here"
BASE_URL = "https://relink.is/api/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Create QR Tag
def create_qr_tag():
data = {
"configuration": {
"smartlinkName": "Restaurant QR Menu",
"smartlinkUrl": "menuqr",
"smartlinkType": "QRTag"
},
"qrTag": {
"title": "Our Menu",
"description": "Scan to view our delicious menu",
"logoLink": "https://restaurant.com/logo.png",
"themeColor": "#ff6b35"
},
"qrTagButtons": [
{
"title": "View Menu",
"link": "https://restaurant.com/menu",
"preset": "restaurant"
},
{
"title": "Order Online",
"link": "https://restaurant.com/order",
"preset": "delivery"
}
]
}
response = requests.post(f"{BASE_URL}/smartlink", headers=headers, json=data)
return response.json()
# Partial update
def update_qr_buttons(smartlink_id):
data = {
"id": smartlink_id,
"qrTagButtons": [
{
"title": "Updated Menu",
"link": "https://restaurant.com/new-menu",
"preset": "restaurant"
}
]
}
response = requests.patch(f"{BASE_URL}/smartlink", headers=headers, json=data)
return response.json()
# Get analytics
def get_analytics_summary():
response = requests.get(f"{BASE_URL}/analytics/summary", headers=headers)
return response.json()Error Handling Examples
Validation Error Response
{
"success": false,
"error": {
"code": "VALIDATION_FAILED",
"message": "Request validation failed",
"details": [
{
"path": "openGraph.imageUrl",
"message": "Invalid URL format"
}
]
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Subscription Limit Error
{
"success": false,
"error": {
"code": "SUBSCRIPTION_LIMIT_REACHED",
"message": "Subscription limit reached"
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Not Found Error
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Smartlink not found"
},
"timestamp": "2024-01-15T10:30:00.000Z"
}