> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pictify.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Generation

> Generate images from HTML, URLs, or templates

# Image Generation

Generate PNG, JPEG, or WebP images from HTML content, URLs, or saved templates. You can also render FabricJS canvas data directly.

<Note>
  One of `html`, `url`, or `template` is required. See each endpoint page for full request/response details.
</Note>

## Endpoints

| Method | Endpoint        | Description                                                                            |
| ------ | --------------- | -------------------------------------------------------------------------------------- |
| `POST` | `/image`        | [Generate image](/api-reference/endpoints/images/generate) from HTML, URL, or template |
| `GET`  | `/image`        | [List images](/api-reference/endpoints/images/list)                                    |
| `GET`  | `/image/{uid}`  | [Get image](/api-reference/endpoints/images/get)                                       |
| `POST` | `/image/canvas` | [Canvas render](/api-reference/endpoints/images/canvas) from FabricJS data             |

## Input Sources

| Source   | Parameter      | Description                              |
| -------- | -------------- | ---------------------------------------- |
| HTML     | `html`         | Render raw HTML/CSS content              |
| URL      | `url`          | Screenshot a publicly accessible URL     |
| Template | `template`     | Render a saved template with `variables` |
| Canvas   | `fabricJSData` | Render FabricJS canvas JSON export       |

## Output Formats

| Format | Extension      | Best For                                 |
| ------ | -------------- | ---------------------------------------- |
| PNG    | `png`          | Default, lossless, supports transparency |
| JPEG   | `jpg` / `jpeg` | Smaller file size, photos                |
| WebP   | `webp`         | Modern format, best compression          |

Use the `fileExtension` parameter to change the output format.

## Key Parameters

| Parameter       | Type    | Default | Description                                |
| --------------- | ------- | ------- | ------------------------------------------ |
| `width`         | integer | 1200    | Output width in pixels (1-4000)            |
| `height`        | integer | 630     | Output height in pixels (1-4000)           |
| `selector`      | string  | -       | CSS selector to capture a specific element |
| `fileExtension` | string  | `png`   | Output format                              |

<Note>
  The `userStorageUrl` response field is only included if you have configured custom storage in your account settings.
</Note>


## OpenAPI

````yaml post /image
openapi: 3.1.0
info:
  title: Pictify API
  version: 1.0.0
  description: |
    Generate images, GIFs, and PDFs from HTML templates programmatically.

    ## Authentication
    All API requests require a Bearer token in the Authorization header:
    ```
    Authorization: Bearer pk_live_your_api_key
    ```

    ## Rate Limits
    - Free: 60 requests/minute
    - Pro: 300 requests/minute
    - Business: 1,000 requests/minute

    Rate limit headers are included in all responses.
  contact:
    email: support@pictify.io
    url: https://pictify.io
  license:
    name: MIT
servers:
  - url: https://api.pictify.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Images
    description: Image generation endpoints
  - name: GIFs
    description: GIF generation and capture
  - name: PDFs
    description: PDF generation
  - name: Templates
    description: Template management
  - name: Batch
    description: Batch rendering operations
  - name: Experiments
    description: A/B testing, smart links, and scheduled variant experiments
  - name: Webhooks
    description: Webhook subscription management
  - name: Bindings
    description: Data binding for auto-rendering
paths:
  /image:
    post:
      tags:
        - Images
      summary: Generate an image
      description: Generate an image from HTML, URL, or template
      operationId: createImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageRequest'
      responses:
        '200':
          description: Image generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ImageRequest:
      type: object
      properties:
        html:
          type: string
          description: HTML content to render
        url:
          type: string
          format: uri
          description: URL to screenshot (mutually exclusive with html)
        template:
          type: string
          description: Template UID to render
        variables:
          type: object
          additionalProperties: true
          description: Variables to populate in the template
        width:
          type: integer
          minimum: 1
          maximum: 4000
          default: 1200
          description: Output width in pixels
        height:
          type: integer
          minimum: 1
          maximum: 4000
          default: 630
          description: Output height in pixels
        selector:
          type: string
          description: CSS selector to capture specific element
        fileExtension:
          type: string
          enum:
            - png
            - jpg
            - jpeg
            - webp
          default: png
          description: Output image format
    ImageResponse:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: URL of the generated image
          example: https://cdn.pictify.io/renders/abc123.png
        userStorageUrl:
          type: string
          format: uri
          description: URL in user's configured storage (if configured)
        id:
          type: string
          description: Unique image identifier
          example: img_abc123
        createdAt:
          type: string
          format: date-time
          description: Timestamp when image was created
    Error:
      type: object
      required:
        - type
        - title
        - status
      properties:
        type:
          type: string
          format: uri
          description: Link to error documentation
          example: https://docs.pictify.io/errors/invalid-api-key
        title:
          type: string
          description: Short error title
          example: Invalid API Key
        status:
          type: integer
          description: HTTP status code
          example: 401
        detail:
          type: string
          description: Detailed error message
          example: The provided API key is invalid or has been revoked.
        instance:
          type: string
          description: Request path that caused the error
          example: /image
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key obtained from the Pictify dashboard

````