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

# Ruby

## Ruby

Generate an image from a template with a single POST request, using only the Ruby standard library. 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`.

```ruby showLineNumbers title="Ruby (Net::HTTP)"
require "net/http"
require "json"
require "uri"

design_id = ENV.fetch("IMEJIS_DESIGN_ID")
api_key = ENV.fetch("IMEJIS_API_KEY")

uri = URI("https://render.imejis.io/v1/#{design_id}")
request = Net::HTTP::Post.new(uri)
request["dma-api-key"] = api_key
request["Content-Type"] = "application/json"
request.body = { "headline.text" => "Hello from Ruby" }.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end
File.binwrite("output.jpg", response.body)
puts "status #{response.code} bytes #{response.body.bytesize}"
```

**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.
