---
title: "Generate QR / Aztec / Data Matrix / PDF417 codes from..."
method: POST
path: "/api/barcode/generate"
tags: ["barcode"]
---

# Generate QR / Aztec / Data Matrix / PDF417 codes from...

`POST /api/barcode/generate`

## Request

- Base URL: `https://2s.io`
- URL: `https://2s.io/api/barcode/generate`
- Auth: API key in header `PAYMENT-SIGNATURE`

Generate QR / Aztec / Data Matrix / PDF417 codes from structured payloads (url, wifi, vcard, vevent, email, sms, tel, geo, bitcoin, json, text). QR supports rounded or dotted modules, solid colors or linear/radial gradients, transparent backgrounds, configurable error correction, and a centered logo image (URL or data URI).

## Query parameters

- `trial` 1

## Request body

- object
  - `format` 'qr' | 'aztec' | 'datamatrix' | 'pdf417': Format.
  - `data` union, required: Data.
    - object
      - `type` 'text', required: Filter results by type.
      - `text` string, required: Text.
    - object
      - `type` 'url', required: Filter results by type.
      - `url` string, uri, required: URL to process.
    - object
      - `type` 'email', required: Filter results by type.
      - `to` string, email, required: End of the range.
      - `subject` string: Subject.
      - `body` string: Body.
    - object
      - `type` 'sms', required: Filter results by type.
      - `to` string, required: End of the range.
      - `body` string: Body.
    - object
      - `type` 'phone', required: Filter results by type.
      - `number` string, required: Item number or identifier.
    - object
      - `type` 'wifi', required: Filter results by type.
      - `ssid` string, required: Ssid.
      - `password` string: Password.
      - `security` 'WPA' | 'WEP' | 'none': Security.
      - `hidden` boolean: Hidden.
    - object
      - `type` 'vcard', required: Filter results by type.
      - `name` string, required: Name to search for.
      - `firstName` string: First name to filter by.
      - `lastName` string: Last name to filter by.
      - `phone` string: Phone.
      - `email` string, email: Email.
      - `org` string: Org.
      - `title` string: Title to search for.
      - `url` string, uri: URL to process.
      - `note` string: Note.
    - object
      - `type` 'geo', required: Filter results by type.
      - `lat` number, required: Latitude in decimal degrees (WGS84).
      - `lon` number, required: Longitude in decimal degrees (WGS84).
      - `altitude` number: Altitude.
    - object
      - `type` 'bitcoin', required: Filter results by type.
      - `address` string, required: Street address or full address string.
      - `amount` number: Amount.
      - `label` string: Label.
      - `message` string: Message.
    - object
      - `type` 'calendar', required: Filter results by type.
      - `title` string, required: Title to search for.
      - `start` string, date-time, required: Start.
      - `end` string, date-time, required: End.
      - `location` string: Location.
      - `description` string: Description.
    - object
      - `type` 'json', required: Filter results by type.
      - `value` unknown
  - `output` 'svg' | 'png' | 'dataurl': Output.
  - `size` integer: Size.
  - `margin` integer: Margin.
  - `errorCorrection` 'L' | 'M' | 'Q' | 'H': L=~7%, M=~15%, Q=~25%, H=~30% recoverable damage (QR only).
  - `style` object: Style.
    - `modules` 'square' | 'rounded' | 'dots': Modules.
    - `foreground` union: Foreground.
      - string
      - object
        - `type` 'linear' | 'radial', required: Gradient type.
        - `stops` object[], required: Stops.
          - `offset` number, required: Number of results to skip before returning (pagination offset).
          - `color` string, required: Color.
        - `rotation` number: Linear gradient rotation in degrees.
    - `background` string: CSS color or "transparent".
    - `logo` object: Logo.
      - `source` string, required: https:// URL or data: URI. QR only.
      - `sizePct` number: Size pct.
      - `padding` number: Padding.
      - `background` string: Background.
      - `cornerRadius` number: Corner radius.

## Response `200`

OK

## Other responses

- `400`: Invalid request — not charged. error.code: BAD_REQUEST or INVALID_PARAM (parameter validation; error.details.issues lists each problem), MALFORMED_JSON, or a request-specific code. Other client errors: 405 METHOD_NOT_ALLOWED (wrong verb; see the Allow header), 413 PAYLOAD_TOO_LARGE.
- `402`: Payment required. Body is the x402 PaymentRequirements envelope with a multi-network accepts array; the per-call price is in accepts[].amount (and on the operation as x-2s-price). Sign for whichever rail you hold USDC on (EIP-3009 for Base, partial SPL transfer for Solana) and retry with the PAYMENT-SIGNATURE header (X-PAYMENT also accepted for v1 clients). Also PAYMENT_SETTLE_FAILED (error envelope) when a verified payment failed to settle: error.details.chargeStatus is "not_charged" (retry with a fresh payment) or "unknown" (the authorization may still settle before its deadline — check it before retrying).
- `429`: Too many requests — RATE_LIMITED: our per-IP / per-payer limiter. Not charged; retry after Retry-After.
- `5XX`: Server-side failure. 500 INTERNAL: unexpected error; quote error.errorId (also the X-2s-Error-Id header). 502 UPSTREAM_UNAVAILABLE (or another UPSTREAM_* code): the data provider failed — composite endpoints refuse unbilled when every source fails. 503 SERVICE_PAUSED: endpoint paused by the operator kill switch, retry after Retry-After; 503 SPEND_CAP: daily upstream budget exhausted. 504 UPSTREAM_TIMEOUT. Not charged.

---

[API](https://skmtc.dev/2s-io/apis/2s-the-most-everything-api.md) · [All operations](https://skmtc.dev/2s-io/apis/2s-the-most-everything-api/llms.txt) · [OpenAPI document](https://skmtc.dev/2s-io/apis/2s-the-most-everything-api/revisions/da4c5caf686e?raw)
