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

# Render 2D barcode

> Render one validated code definition as SVG.

Render one code as an SVG file. Send a single code definition, not a `codes` array.
The same GS1 validation used by [`POST /codes`](/api-reference/endpoints/generate-codes) applies.
This operation requires `write:codes` and does not save a generated-code record or a file.

## Barcode modes

| `mode`                            | Encoded data                                                     |
| --------------------------------- | ---------------------------------------------------------------- |
| `GS1_DATAMATRIX`                  | GS1 element string with FNC1, Data Matrix ECC 200.               |
| `DATAMATRIX_GS1_DIGITAL_LINK_URI` | GS1 Digital Link URI in Data Matrix. Requires `digitalLinkStem`. |
| `GS1_QR`                          | GS1 element string with FNC1 in QR Code.                         |
| `QR_GS1_DIGITAL_LINK_URI`         | GS1 Digital Link URI in QR Code. Requires `digitalLinkStem`.     |

For QR modes, optional `errorCorrectionLevel` accepts `L`, `M`, `Q` or `H`.
Omitting it or sending `null` selects `L`. The requested level is used without automatic upgrading.
Data Matrix uses fixed ECC 200: omit `errorCorrectionLevel` or send `null`; any other value is rejected.

`ais` and `extensionParameters` may be omitted or `null` for empty lists.
`linkType` and `context` are optional. Each response is a single file.

## Download an SVG

```bash theme={null}
curl --fail-with-body -X POST 'https://api.thingidentity.com/codes/render' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/vnd.thingidentity.public.v1+json' \
  -H 'Accept: image/svg+xml' \
  --data '{
    "mode": "QR_GS1_DIGITAL_LINK_URI",
    "digitalLinkStem": "https://gtin.at",
    "primaryKey": { "key": "01", "value": "09521234543213" },
    "ais": [{ "key": "10", "value": "LOT42" }]
  }' \
  --output code.svg
```

Success returns `200 OK` with `Content-Type: image/svg+xml`.

Example response body, shown as SVG source:

```xml theme={null}
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><metadata xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:creator>Thing Identity</dc:creator><dc:source>https://thingidentity.com</dc:source></metadata><rect width="18" height="18" fill="#FFFFFF"/><path fill="#000000" d="M1,1h1v1h-1zM3,1h1v1h-1zM5,1h1v1h-1zM7,1h1v1h-1zM9,1h1v1h-1zM11,1h1v1h-1zM13,1h1v1h-1zM15,1h1v1h-1zM1,2h2v1h-2zM5,2h4v1h-4zM10,2h2v1h-2zM15,2h2v1h-2zM1,3h1v2h-1zM5,3h1v1h-1zM7,3h2v2h-2zM12,3h1v1h-1zM3,4h2v1h-2zM10,4h1v1h-1zM12,4h2v1h-2zM16,4h1v1h-1zM1,5h3v1h-3zM5,5h2v1h-2zM9,5h1v1h-1zM12,5h4v1h-4zM1,6h1v2h-1zM3,6h1v2h-1zM6,6h2v1h-2zM9,6h2v1h-2zM12,6h5v1h-5zM6,7h3v1h-3zM11,7h1v1h-1zM14,7h1v1h-1zM1,8h4v1h-4zM7,8h5v1h-5zM16,8h1v1h-1zM1,9h1v1h-1zM9,9h1v1h-1zM11,9h1v1h-1zM13,9h3v1h-3zM1,10h2v1h-2zM6,10h2v1h-2zM10,10h1v2h-1zM13,10h4v1h-4zM1,11h1v1h-1zM4,11h1v1h-1zM8,11h1v1h-1zM14,11h1v1h-1zM1,12h5v1h-5zM7,12h1v1h-1zM9,12h1v1h-1zM11,12h2v1h-2zM15,12h2v1h-2zM1,13h2v1h-2zM5,13h3v1h-3zM9,13h2v1h-2zM14,13h1v1h-1zM1,14h1v1h-1zM4,14h3v1h-3zM10,14h5v1h-5zM16,14h1v1h-1zM1,15h2v1h-2zM8,15h2v1h-2zM12,15h1v1h-1zM15,15h1v1h-1zM1,16h16v1h-16z"/></svg>
```

The SVG is black on white, with quiet zones of four modules for QR and one for Data Matrix.
It contains no printed human-readable label.

Invalid requests or codes that cannot be rendered return `400 Bad Request` with an empty body.
For GS1 validation details in JSON, submit the code definition to
[`POST /codes`](/api-reference/endpoints/generate-codes), wrapped in a `codes` array.


## OpenAPI

````yaml openapi.json POST /codes/render
openapi: 3.1.0
info:
  title: Thing Identity Public API
  version: 1.0.0
  description: >-
    Machine-to-machine API for Thing Identity. Authenticate with client
    credentials, then call the endpoints below with the resulting bearer token.
servers:
  - url: https://api.thingidentity.com
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Exchange client credentials for an access token.
  - name: Codes
    description: Generate GS1 barcode payloads and GS1 Digital Link URIs.
paths:
  /codes/render:
    post:
      tags:
        - Codes
      summary: Render 2D barcode
      description: Render one validated code definition as SVG.
      operationId: renderCode
      requestBody:
        required: true
        content:
          application/vnd.thingidentity.public.v1+json:
            schema:
              $ref: '#/components/schemas/RenderCodeRequest'
            example:
              mode: QR_GS1_DIGITAL_LINK_URI
              digitalLinkStem: https://gtin.at
              primaryKey:
                key: '01'
                value: '09521234543213'
              ais:
                - key: '10'
                  value: LOT42
          application/json:
            schema:
              $ref: '#/components/schemas/RenderCodeRequest'
            example:
              mode: QR_GS1_DIGITAL_LINK_URI
              digitalLinkStem: https://gtin.at
              primaryKey:
                key: '01'
                value: '09521234543213'
              ais:
                - key: '10'
                  value: LOT42
      responses:
        '200':
          description: SVG barcode image.
          content:
            image/svg+xml:
              schema:
                type: string
              example: >-
                <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"
                viewBox="0 0 18 18"><metadata
                xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:creator>Thing
                Identity</dc:creator><dc:source>https://thingidentity.com</dc:source></metadata><rect
                width="18" height="18" fill="#FFFFFF"/><path fill="#000000"
                d="M1,1h1v1h-1zM3,1h1v1h-1zM5,1h1v1h-1zM7,1h1v1h-1zM9,1h1v1h-1zM11,1h1v1h-1zM13,1h1v1h-1zM15,1h1v1h-1zM1,2h2v1h-2zM5,2h4v1h-4zM10,2h2v1h-2zM15,2h2v1h-2zM1,3h1v2h-1zM5,3h1v1h-1zM7,3h2v2h-2zM12,3h1v1h-1zM3,4h2v1h-2zM10,4h1v1h-1zM12,4h2v1h-2zM16,4h1v1h-1zM1,5h3v1h-3zM5,5h2v1h-2zM9,5h1v1h-1zM12,5h4v1h-4zM1,6h1v2h-1zM3,6h1v2h-1zM6,6h2v1h-2zM9,6h2v1h-2zM12,6h5v1h-5zM6,7h3v1h-3zM11,7h1v1h-1zM14,7h1v1h-1zM1,8h4v1h-4zM7,8h5v1h-5zM16,8h1v1h-1zM1,9h1v1h-1zM9,9h1v1h-1zM11,9h1v1h-1zM13,9h3v1h-3zM1,10h2v1h-2zM6,10h2v1h-2zM10,10h1v2h-1zM13,10h4v1h-4zM1,11h1v1h-1zM4,11h1v1h-1zM8,11h1v1h-1zM14,11h1v1h-1zM1,12h5v1h-5zM7,12h1v1h-1zM9,12h1v1h-1zM11,12h2v1h-2zM15,12h2v1h-2zM1,13h2v1h-2zM5,13h3v1h-3zM9,13h2v1h-2zM14,13h1v1h-1zM1,14h1v1h-1zM4,14h3v1h-3zM10,14h5v1h-5zM16,14h1v1h-1zM1,15h2v1h-2zM8,15h2v1h-2zM12,15h1v1h-1zM15,15h1v1h-1zM1,16h16v1h-16z"/></svg>
        '400':
          description: >-
            Invalid request, code definition, mode, correction level or
            unrenderable data. Empty response body.
        '401':
          description: Missing or invalid bearer token.
        '403':
          description: Token lacks write:codes or API access.
        '406':
          description: Accept does not allow image/svg+xml.
components:
  schemas:
    RenderCodeRequest:
      example:
        mode: QR_GS1_DIGITAL_LINK_URI
        digitalLinkStem: https://gtin.at
        primaryKey:
          key: '01'
          value: '09521234543213'
        ais:
          - key: '10'
            value: LOT42
      type: object
      required:
        - mode
        - primaryKey
      properties:
        mode:
          type: string
          enum:
            - GS1_DATAMATRIX
            - DATAMATRIX_GS1_DIGITAL_LINK_URI
            - GS1_QR
            - QR_GS1_DIGITAL_LINK_URI
          example: QR_GS1_DIGITAL_LINK_URI
          description: Barcode type. Digital Link modes require digitalLinkStem.
        errorCorrectionLevel:
          type:
            - string
            - 'null'
          enum:
            - L
            - M
            - Q
            - H
            - null
          description: >-
            QR only: L, M, Q or H. Omitted or null selects L for QR. For Data
            Matrix omit or send null.
        primaryKey: 5b5f18e0-4792-4aa7-a871-12cf92cdf5ac
        ais: 48607265-a799-4ae4-8234-730c8524b8e0
        extensionParameters: 510686b0-509a-43a2-888a-a04b3677def6
        digitalLinkStem: ecedb463-ce30-4ae5-95e1-e0183aff5709
        linkType: 07369bee-8235-470d-a069-16104625187b
        context: e820522b-5a1d-4d84-aed9-d3cbeb39d854
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: The `access_token` from `POST /oauth/token`.

````