Skip to main content

GenerateImageSignedURL

Generate a signed URL that can be used to generate images on-demand without making API calls. Perfect for dynamic content in emails, web pages, and more.
func (c *BannerifyClient) GenerateImageSignedURL(
    templateID string,
    opts *CreateImageOptions,
) (string, error)

Parameters

templateID
string
required
The template ID (e.g., ‘tpl_xxxxxxxxx’)
opts
*CreateImageOptions
Optional configuration

Returns

Returns a signed URL string or error.
string // e.g., "https://api.bannerify.co/v1/templates/signedurl?..."
error  // error if URL generation fails

Examples

Basic Signed URL

package main

import (
    "fmt"
    
    "github.com/bannerify/bannerify-go"
)

func main() {
    client := bannerify.NewBannerifyClient("your-api-key")
    
    signedURL, err := client.GenerateImageSignedURL("tpl_xxxxxxxxx", nil)
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("<img src='%s' alt='Generated Image' />", signedURL)
}

With Modifications

signedURL, err := client.GenerateImageSignedURL("tpl_xxxxxxxxx", &bannerify.CreateImageOptions{
    Modifications: []bannerify.Modification{
        {Name: "title", Text: "Dynamic Title"},
        {Name: "subtitle", Text: "Generated on the fly"},
    },
})

if err == nil {
    fmt.Printf("<img src='%s' alt='Dynamic Banner' />", signedURL)
}

SVG Format

signedURL, err := client.GenerateImageSignedURL("tpl_xxxxxxxxx", &bannerify.CreateImageOptions{
    Format: "svg",
    Modifications: []bannerify.Modification{
        {Name: "title", Text: "SVG Image"},
    },
})

Use Cases

Email Campaigns

Generate personalized images in emails:
recipients := []struct {
    Name  string
    Email string
}{
    {"Alice", "[email protected]"},
    {"Bob", "[email protected]"},
}

for _, recipient := range recipients {
    signedURL, _ := client.GenerateImageSignedURL("tpl_email_header", &bannerify.CreateImageOptions{
        Modifications: []bannerify.Modification{
            {Name: "name", Text: fmt.Sprintf("Hi, %s!", recipient.Name)},
        },
    })
    
    html := fmt.Sprintf("<img src='%s' alt='Personalized Header' />", signedURL)
    // Send email with html
}

Dynamic Open Graph Images

Generate OG images for social media sharing:
func GetOGImageURL(title, author string) string {
    client := bannerify.NewBannerifyClient("your-api-key")
    
    signedURL, err := client.GenerateImageSignedURL("tpl_og_image", &bannerify.CreateImageOptions{
        Modifications: []bannerify.Modification{
            {Name: "title", Text: title},
            {Name: "author", Text: author},
        },
    })
    
    if err != nil {
        return ""
    }
    
    return signedURL
}

// In your HTML template
ogImage := GetOGImageURL("My Blog Post", "John Doe")
// <meta property="og:image" content="{ogImage}" />

Real-time Analytics Badges

import "strconv"

stats := map[string]int{
    "views":  1234,
    "likes":  567,
    "shares": 89,
}

badgeURL, _ := client.GenerateImageSignedURL("tpl_stats_badge", &bannerify.CreateImageOptions{
    Modifications: []bannerify.Modification{
        {Name: "views", Text: strconv.Itoa(stats["views"])},
        {Name: "likes", Text: strconv.Itoa(stats["likes"])},
        {Name: "shares", Text: strconv.Itoa(stats["shares"])},
    },
})

fmt.Printf("[![Stats](%s)](https://example.com)", badgeURL)

User Profile Cards

func GenerateProfileCard(userID, name, avatar string) (string, error) {
    client := bannerify.NewBannerifyClient("your-api-key")
    
    return client.GenerateImageSignedURL("tpl_profile_card", &bannerify.CreateImageOptions{
        Modifications: []bannerify.Modification{
            {Name: "user_name", Text: name},
            {Name: "avatar", Src: avatar},
            {Name: "user_id", Text: userID},
        },
    })
}

profileURL, _ := GenerateProfileCard("123", "Jane Smith", "https://example.com/avatar.jpg")

Benefits

  1. No API Calls - Images are generated only when accessed
  2. CDN Caching - Subsequent requests are served from cache
  3. Security - URLs are signed and can’t be tampered with
  4. Flexibility - Perfect for emails, OG images, and dynamic content
  5. Cost Effective - Only generates when actually viewed