Create a Short Link with Custom Open Graph (OG) Tags

5 min

Before you start

1) Create the short link

# cURL
curl -X POST https://api.ogli.sh/link \
  -H "Authorization: Bearer $OGLI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "targetUrl": "https://example.com/product/123",
    "title": "SuperWidget 2.0",
    "description": "Ships today. Free returns.",
    "ogImage": "https://cdn.example.com/og/superwidget-1200x630.jpg?v=1",
    "ogImageAlt": "SuperWidget 2.0 product image",
    "twitterCard": "summary_large_image"
  }'
// Node (fetch)
await fetch("https://api.ogli.sh/link", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.OGLI_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    targetUrl: "https://example.com/product/123",
    title: "SuperWidget 2.0",
    description: "Ships today. Free returns.",
    ogImage: "https://cdn.example.com/og/superwidget-1200x630.jpg?v=1",
    ogImageAlt: "SuperWidget 2.0 product image",
    twitterCard: "summary_large_image"
  })
});

2) Share & verify the preview

Troubleshooting


← Back to all how-tos