---
title: "C#"
description: "Generate images with the Imejis.io API in C# / .NET using HttpClient. A tested example that POSTs dynamic field overrides to a design and saves the rendered image."
url: "https://www.imejis.io/apis/csharp"
published: "2026-07-25"
---

# C#

## C# / .NET

Generate an image from a template with a single POST request, using `HttpClient`. Imejis returns the finished image directly, so there are no webhooks and nothing to poll.

Set two environment variables first: `IMEJIS_API_KEY` (from your dashboard) and `IMEJIS_DESIGN_ID` (any design's ID). Then send the fields you want to change as `component.property` pairs, for example `headline.text`.

```csharp showLineNumbers title="C# (.NET, top-level statements)"
using System.Text;

var designId = Environment.GetEnvironmentVariable("IMEJIS_DESIGN_ID");
var apiKey = Environment.GetEnvironmentVariable("IMEJIS_API_KEY");
var json = "{\"headline.text\":\"Hello from C#\"}";

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("dma-api-key", apiKey);

var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync($"https://render.imejis.io/v1/{designId}", content);
var bytes = await response.Content.ReadAsByteArrayAsync();

await File.WriteAllBytesAsync("output.jpg", bytes);
Console.WriteLine($"status {(int)response.StatusCode} bytes {bytes.Length}");
```

**Override any field.** Each dynamic component exposes keys like `headline.text`, `title.color`, or `image.image`. Send only the ones you want to change. You can find a design's overridable fields in its Share / API panel.

The response is the raw image (`image/jpeg` by default). Save it to disk, stream it, or return it straight from your own endpoint.
