1 creditOG Image API — social cards on demand
Branded 1200×630 cards from a template, a title and one HTTP call.
The OG Image API renders 1200×630 Open Graph social cards from a template and your text in one REST call. Pick basic, split or quote, pass title, subtitle, eyebrow and an optional logo, and the card comes back as a PNG — with the title font auto-shrunk when a long headline would overflow. One credit per image.
How does the OG Image API work?
One HTTP request from any language. Every ASHDOCS endpoint uses the same X-API-Key header.
curl -X POST https://www.ashdocs.com/api/v1/tools/og-image \
-H "X-API-Key: ash_live_..." \
-H "Content-Type: application/json" \
-d '{"template":"basic","fields":{"eyebrow":"GUIDE","title":"Static vs Dynamic QR Codes"}}'import requests
r = requests.post(
"https://www.ashdocs.com/api/v1/tools/og-image",
headers={"X-API-Key": "ash_live_..."},
json={
"template": "basic",
"fields": {
"eyebrow": "GUIDE",
"title": "Static vs Dynamic QR Codes"
}
},
)
job = r.json()
print(job["status"], job["output_files"][0]["url"])const res = await fetch("https://www.ashdocs.com/api/v1/tools/og-image", {
method: "POST",
headers: { "X-API-Key": "ash_live_...", "Content-Type": "application/json" },
body: JSON.stringify({"template":"basic","fields":{"eyebrow":"GUIDE","title":"Static vs Dynamic QR Codes"}}),
});
const job = await res.json();
console.log(job.status, job.output_files[0].url);using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "ash_live_...");
var body = new StringContent(
"{\"template\":\"basic\",\"fields\":{\"eyebrow\":\"GUIDE\",\"title\":\"Static vs Dynamic QR Codes\"}}",
Encoding.UTF8, "application/json");
var res = await client.PostAsync("https://www.ashdocs.com/api/v1/tools/og-image", body);
var job = await res.Content.ReadAsStringAsync();
Console.WriteLine(job);import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Sample {
public static void main(String[] args) throws Exception {
String json = "{\"template\":\"basic\",\"fields\":{\"eyebrow\":\"GUIDE\",\"title\":\"Static vs Dynamic QR Codes\"}}";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://www.ashdocs.com/api/v1/tools/og-image"))
.header("X-API-Key", "ash_live_...")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());
}
}#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "X-API-Key: ash_live_...");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"template\":\"basic\",\"fields\":{\"eyebrow\":\"GUIDE\",\"title\":\"Static vs Dynamic QR Codes\"}}");
curl_easy_setopt(curl, CURLOPT_URL, "https://www.ashdocs.com/api/v1/tools/og-image");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
CURLcode rc = curl_easy_perform(curl);
printf("\n");
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return rc == CURLE_OK ? 0 : 1;
}Common use cases
- →Per-post social cards for a blog or CMS
- →Product pages with dynamic share images
- →Docs pages that look intentional when shared
Frequently asked questions
What size are the generated images?+
1200×630 by default — the ~1.91:1 ratio most platforms crop toward. Width and height are overridable in options.
What happens with very long titles?+
The title font size shrinks automatically until the text fits the template, so your longest headline still renders as a clean card instead of overflowing.
Which templates are available?+
basic (eyebrow, title, subtitle, logo), split (text beside a colour panel) and quote (large quotation layout). All render server-side as PNG.
Can I generate a card for every blog post automatically?+
Yes — call the endpoint at publish time with the post title, or on demand behind a cache. Change the image URL when the title changes so platform caches refresh.