---
title: HTTP Clients
description: Call Pixmato with built-in fetch or generate a client from its OpenAPI contract.
icon: package
---

Pixmato exposes a JSON HTTP API. There is no maintained official SDK package in this release. Use your language’s HTTP client, or generate a client from the [OpenAPI document](/docs/api-reference/openapi).

The examples below run on the server with Node.js’s built-in `fetch`. Keep the API key in your server environment.

## Single render

```ts
const apiUrl = process.env.PIXMATO_API_URL ?? 'https://api.pixmato.com'
const apiKey = process.env.PIXMATO_API_KEY
if (!apiKey) throw new Error('PIXMATO_API_KEY is required')

const response = await fetch(`${apiUrl}/v1/renders`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    template: 'YOUR_TEMPLATE_ID',
    modifications: { headline: 'Version 2 is live' },
    output: { format: 'png', scale: 2 },
  }),
})

const render = await response.json()
if (!response.ok) throw new Error(render.error ?? `Render request failed: ${response.status}`)
console.log(render.output_url)
```

Replace `YOUR_TEMPLATE_ID` and the modification keys with the values in your template’s **API** tab.

## Asynchronous renders

Add `Prefer: respond-async` to return a durable job ID immediately. The server responds with `202` and `poll_url`:

```ts
const response = await fetch(`${apiUrl}/v1/renders`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
    Prefer: 'respond-async',
  },
  body: JSON.stringify({
    template: 'YOUR_TEMPLATE_ID',
    modifications: { headline: 'Version 2 is live' },
  }),
})

const job = await response.json()
if (!response.ok) throw new Error(job.error ?? `Render request failed: ${response.status}`)
console.log(job.id, job.poll_url)
```

Fetch `poll_url` against the same API origin, using the same bearer token, to read the job’s status. Space polling requests apart; do not immediately loop without a delay. A synchronous HTTP timeout also leaves the job running: inspect the supplied job ID before resubmitting.

## Upload an image

Send multipart form data to `POST /v1/assets`. Do not set a `Content-Type` header manually; `fetch` supplies the multipart boundary.

```ts
import { readFile } from 'node:fs/promises'

const form = new FormData()
form.append('file', new Blob([await readFile('hero.png')], { type: 'image/png' }), 'hero.png')

const response = await fetch(`${apiUrl}/v1/assets`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${apiKey}` },
  body: form,
})

const result = await response.json()
if (!response.ok) throw new Error(result.error ?? `Upload failed: ${response.status}`)
console.log(result.asset.url)
```

## Other languages and generated clients

The same HTTP requests work with Python, Ruby, PHP, Go, and other languages. Use the examples in the [API Reference](/docs/api-reference) with your language’s HTTP client.

For generated types or clients, use the deployed API’s OpenAPI document:

```txt
https://api.pixmato.com/v1/openapi.json
```

Generated clients are your integration code; Pixmato does not currently publish or maintain language-specific SDKs.
