---
title: "Twitter Image API: Render 1200x675 Cards for X Posts"
description: "Use the Twitter image API to render share cards on demand. Send title, eyebrow, and author details as JSON, get back a 1200x675 PNG to attach to a post."
url: "https://html2img.com/templates/twitter-post/"
---

# Twitter/X Post Image: Twitter Image Generator API

Send title and metadata as JSON, get back a 1200x675 PNG ready to attach to an X post.

Marketing teams and content tools use the Twitter image API to ship share cards alongside posts that would otherwise rely on the default link unfurl. The 1200x675 ratio matches Twitter's summary_large_image card and works inline as media attached to a post. You post the title, eyebrow, optional author block, and brand inputs as JSON, and the response holds a PNG you can attach via the X API or schedule with your favorite tool.

## At a glance

- **Template slug:** `twitter-post`
- **Category:** social
- **Endpoint:** `POST https://app.html2img.com/api/v1/templates/twitter-post`
- **Authentication:** `X-API-Key` header
- **Cost:** one credit per render, PNG or PDF
- **Page:** https://html2img.com/templates/twitter-post/

## Fields

| Field | Type | Required | Example |
| --- | --- | --- | --- |
| `title` | string | Yes | We just shipped real-time collaboration |
| `subtitle` | string | No | Edit docs together with sub-100ms latency, on every plan. |
| `eyebrow` | string | No | PRODUCT UPDATE |
| `author_name` | string | No | Halberd Engineering |
| `author_handle` | string | No | @halberdeng |
| `author_avatar_url` | url | No | https://i.pravatar.cc/160?img=12 |
| `logo_url` | url | No |  |
| `background_color` | string | No | #0B1220 |
| `accent_color` | string | No | #1D9BF0 |

## Defaults

| Field | Default |
| --- | --- |
| `width` | 1200 |
| `height` | 675 |

## Example request

```bash
curl -X POST https://app.html2img.com/api/v1/templates/twitter-post \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"We just shipped real-time collaboration","subtitle":"Edit docs together with sub-100ms latency, on every plan.","eyebrow":"PRODUCT UPDATE","author_name":"Halberd Engineering","author_handle":"@halberdeng","author_avatar_url":"https://i.pravatar.cc/160?img=12","background_color":"#0B1220","accent_color":"#1D9BF0"}'
```

## In your language

### PHP

```php
<?php
$response = \Illuminate\Support\Facades\Http::withHeaders([
    'X-API-Key' => 'YOUR_API_KEY',
])->post('https://app.html2img.com/api/v1/templates/twitter-post', ['title' => 'We just shipped real-time collaboration', 'subtitle' => 'Edit docs together with sub-100ms latency, on every plan.', 'eyebrow' => 'PRODUCT UPDATE', 'author_name' => 'Halberd Engineering', 'author_handle' => '@halberdeng', 'author_avatar_url' => 'https://i.pravatar.cc/160?img=12', 'background_color' => '#0B1220', 'accent_color' => '#1D9BF0']);

$url = $response->json('url');
```

### Node.js

```javascript
const response = await fetch('https://app.html2img.com/api/v1/templates/twitter-post', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "title": "We just shipped real-time collaboration",
    "subtitle": "Edit docs together with sub-100ms latency, on every plan.",
    "eyebrow": "PRODUCT UPDATE",
    "author_name": "Halberd Engineering",
    "author_handle": "@halberdeng",
    "author_avatar_url": "https://i.pravatar.cc/160?img=12",
    "background_color": "#0B1220",
    "accent_color": "#1D9BF0"
}),
});

const { url } = await response.json();
```

### Python

```python
import requests

response = requests.post(
    'https://app.html2img.com/api/v1/templates/twitter-post',
    headers={'X-API-Key': 'YOUR_API_KEY'},
    json={'title': 'We just shipped real-time collaboration', 'subtitle': 'Edit docs together with sub-100ms latency, on every plan.', 'eyebrow': 'PRODUCT UPDATE', 'author_name': 'Halberd Engineering', 'author_handle': '@halberdeng', 'author_avatar_url': 'https://i.pravatar.cc/160?img=12', 'background_color': '#0B1220', 'accent_color': '#1D9BF0'},
)

url = response.json()['url']
```

## What it is for

### SaaS sharing release notes with branded artwork

Product launches benefit from a card that says "we shipped X" louder than the default link unfurl. Render once per release with the version, headline, and accent color, attach to the launch post, and the timeline shows your update with full-width artwork. Halberd Software ships 4 to 6 release-note posts per month through this template, and engagement on launch posts has roughly doubled since the rollout.

### Newsletter publishers attaching share cards to issues

Newsletter operators who post on X benefit from a fresh card per issue rather than reusing one stock graphic. Render with the issue number, headline topic, and a CTA to subscribe, attach to the announcement post, and the post stands out in followers' timelines. Wren Analytics generates a card every Tuesday for the digest, and subscriber growth from X climbed 28 percent compared to the previous quarter.

### Content tools posting AI-generated insights

AI-driven content platforms can attach a card to each piece of public output to give the share visual identity. Render with the user's topic and a short hook, post via the X API, and the share carries authorship rather than reading as a raw link. Linden & Co's briefing platform uses this for every shareable insight, and the resulting posts get reshared at 3x the rate of plain text.

### Podcasts promoting episodes

Podcasts with an X presence benefit from per-episode promo cards in addition to the show-cover artwork. Render with the episode number, title, and a hook line from the show notes, attach to the launch-day post, and listeners click through more than they would on a generic graphic. The format pairs with the dedicated podcast-episode-card template for cross-channel reuse.

### Conferences sharing schedule cards

Event organizers post daily speaker and session announcements in the lead-up to the conference. Render one card per session with the speaker name, time slot, and venue, schedule across the campaign window, and the timeline reads as a structured feed rather than a stream of unrelated posts. The Type Conference posts 28 schedule cards in the 6 weeks before the event.

## Output

- **Dimensions:** 1200x675
- **Colour space:** sRGB
- **Transparency:** Not supported
- **Typical file size:** 60 KB to 200 KB
- **Platform specification:** [X summary_large_image card guidelines](https://developer.x.com/en/docs/x-for-websites/cards/overview/summary-card-with-large-image)

## Common mistakes

### Inline post images crop to a different ratio than feed cards

Posts attached as media render at 16:9 in the feed but X may crop to 1.91:1 in some contexts. Keep the focal area centered so any crop variant still shows the headline and brand mark. Test on iOS and Android before going live.

### Alt text omitted from the post itself

The rendered PNG does not carry alt text, and X requires it on the post side for accessibility. Set descriptive alt text via the X API when posting, so screen-reader users get a usable description of the card content.

### Very high-DPI renders exceed the 5MB cap

X caps post images at 5 MB. Default-DPI renders stay well below the cap, but a 3x DPI render with a photographic background can climb fast. Stick with default DPI unless you specifically need a Retina-clean version, and check file size before posting.

## Questions

### What size should a Twitter or X share image be?

Use 1200x675 (16:9) for summary_large_image cards and inline post images. The 1200x600 size also works for inline posts. This template renders 1200x675 by default to match the most common card variant.

### What is the difference between summary and summary_large_image?

summary_large_image renders the image full-width below the post text. summary renders a small thumbnail next to the text. summary_large_image gets more engagement, so use it for posts where the visual is the hook.

### Will it work after the X rebrand?

Yes, the spec is unchanged. X kept the Twitter Cards API live under the developer docs, and the meta tag names (twitter:card, twitter:image) still apply. Existing OG tags work as a fallback if Twitter-specific tags are missing.

### Do I need to add alt text?

Yes, set descriptive alt text via the X API when posting. The rendered PNG itself does not carry alt, so the responsibility falls on the posting layer. Alt text both helps screen-reader users and improves discoverability for hearing-loss accessibility audits.

### What is the file size limit?

X caps post images at 5 MB. Default-DPI renders from this template stay between 60 KB and 200 KB, well below the cap. Higher DPI versions for Retina displays can climb to 1 to 2 MB with photographic backgrounds. A campaign archive can also pull format: "pdf" copies as A4 documents; the upload to X stays a PNG.

### Can I use a GIF?

No, this endpoint produces a static PNG. For animated content, render the frames separately and stitch them with a tool like ImageMagick or ffmpeg, then upload the resulting GIF or video to X via its media endpoints.

## Preview

![Twitter/X Post Image: Twitter Image Generator API example render](https://i.html2img.com/image-1777560092534-821811.png)

## Related templates

- [instagram-square-post](https://html2img.com/templates/instagram-square-post/)
- [open-graph-image](https://html2img.com/templates/open-graph-image/)
- [youtube-thumbnail](https://html2img.com/templates/youtube-thumbnail/)

## See also

- [Every template](https://html2img.com/templates/)
- [Templates API reference](https://html2img.com/docs/templates/)
- [OpenAPI specification](https://html2img.com/openapi.json)
