---
title: "Action generate_barcode"
description: "Generates a barcode or QR code image from text and stores the URL in a constant."
---

# Action `generate_barcode`

> **System ID:** `action_generate_barcode`

## Description

Creates a PNG barcode (or QR) image from text data. The file link is stored in a user constant — you can send it to the client or use it later in the scenario.

## Events (scenario branches)

| Event | When it occurs |
|-------|----------------|
| **generated** | Barcode generated successfully, URL stored in a constant |
| **generation_error** | Missing `code`/`type`, generation error, or file save failure |

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `code` | string | yes | — | Text/data to encode. Supports placeholders |
| `type` | string | yes | — | Code type: `code128`, `ean13`, `qr`, `code39`, etc. Supports placeholders |
| `height` | number / string | no | `10` | Bar height in mm |
| `scale` | number / string | no | `3` | Image scale |
| `includetext` | boolean | no | `true` | Whether to show text under the barcode |
| `textxalign` | string | no | `"center"` | Text alignment: `left`, `center`, `right` |
| `set_to` | string | no | `null` | Constant name for the URL. If not set — `barcode` |

## Configuration example

```json
{
  "code": "{{order_id}}",
  "type": "code128",
  "height": 10,
  "scale": 3,
  "includetext": true,
  "textxalign": "center",
  "set_to": "barcode_url"
}
```

## Related docs

- [Actions reference](/en/actionjail/reference/actions-reference.md)
