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

# Build a BIP 321 payment URI

> Builds a single BIP 321 `bitcoin:` URI bundling multiple ways to receive the same payment, so one call prepares everything needed for an incoming payment. A fresh Ark address is always included. When `amount_sat` is given, a BOLT11 invoice for that amount is generated and the amount is embedded in the URI. When `onchain` is `true`, a fresh on-chain address is added (placed in the URI body on mainnet, as a `tb=` parameter on test networks). Set the `uppercase` query parameter to upper-case the `bip321` URI so QR encoders can use the compact alphanumeric mode; this fails if the URI carries case-sensitive data. The individual `ark`, `bolt11`, and `onchain` destinations are always returned in their natural case for direct use.



## OpenAPI

````yaml https://gitlab.com/ark-bitcoin/bark/-/raw/master/bark-rest/openapi.json post /api/v1/wallet/bip321
openapi: 3.1.0
info:
  title: barkd REST API
  description: >-
    A simple REST API for barkd, a wallet daemon for integrating bitcoin
    payments into your app over HTTP. Supports self-custodial Lightning, Ark,
    and on-chain out of the box.


    barkd is a long-running daemon best suited for always-on or
    high-connectivity environments like nodes, servers, desktops, and
    point-of-sale terminals.


    All endpoints return JSON. Amounts are denominated in satoshis.
  contact:
    name: Second Team
    email: hello@second.tech
  license:
    name: MIT
    identifier: MIT
  version: 0.4.0
servers: []
security:
  - bearer: []
tags:
  - name: boards
    description: Move on-chain bitcoin onto the Ark protocol.
  - name: exits
    description: Move bitcoin back on-chain without server cooperation.
  - name: fees
    description: Estimate fees for wallet operations before executing them.
  - name: history
    description: Inspect and annotate wallet movement history.
  - name: lightning
    description: Create Lightning invoices and track receives.
  - name: onchain
    description: Manage barkd's on-chain bitcoin wallet.
  - name: wallet
    description: Manage Ark balances and VTXOs, send payments via Ark, LN, and on-chain.
  - name: bitcoin
    description: Query bitcoin network data.
  - name: notifications
    description: Receive real-time notifications from barkd.
paths:
  /api/v1/wallet/bip321:
    post:
      tags:
        - wallet
      summary: Build a BIP 321 payment URI
      description: >-
        Builds a single BIP 321 `bitcoin:` URI bundling multiple ways to receive
        the same payment, so one call prepares everything needed for an incoming
        payment. A fresh Ark address is always included. When `amount_sat` is
        given, a BOLT11 invoice for that amount is generated and the amount is
        embedded in the URI. When `onchain` is `true`, a fresh on-chain address
        is added (placed in the URI body on mainnet, as a `tb=` parameter on
        test networks). Set the `uppercase` query parameter to upper-case the
        `bip321` URI so QR encoders can use the compact alphanumeric mode; this
        fails if the URI carries case-sensitive data. The individual `ark`,
        `bolt11`, and `onchain` destinations are always returned in their
        natural case for direct use.
      operationId: bip321_uri
      parameters:
        - name: uppercase
          in: query
          description: >-
            Upper-case the returned `bip321` URI for compact QR encoding.
            Defaults to false. Fails with 400 if the URI carries case-sensitive
            data (a label, message, or base58 address).
          required: false
          schema:
            type: boolean
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Bip321UriRequest'
        required: true
      responses:
        '200':
          description: Returns the BIP 321 URI and its destinations
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bip321UriResponse'
        '400':
          description: Requested an upper-case URI that carries case-sensitive data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
components:
  schemas:
    Bip321UriRequest:
      type: object
      description: >-
        Request to build a BIP 321 unified payment URI.


        An Ark address is always included. A BOLT11 invoice is only included
        when

        `amount_sat` is given (an amount is required to create one). An on-chain

        address is included only when `onchain` is `true`.
      properties:
        amount_sat:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            Optional amount (in satoshis) to request. When set, it is embedded
            in

            the URI and used to create the BOLT11 invoice. Any server-configured

            [LightningReceiveFees](crate::cli::fees::LightningReceiveFees) are

            deducted from the amount the client ultimately receives over
            Lightning.
          minimum: 0
        label:
          type:
            - string
            - 'null'
          description: >-
            Optional label describing the payment, recorded in the URI's
            `label`.
        message:
          type:
            - string
            - 'null'
          description: >-
            Optional message describing the payment, recorded in the URI's
            `message`.
        onchain:
          type:
            - boolean
            - 'null'
          description: >-
            Whether to include a fresh on-chain address as a payment
            destination.

            Defaults to `false`.
    Bip321UriResponse:
      type: object
      description: >-
        A BIP 321 unified payment URI together with its individual destinations.


        The `bip321` field is the combined `bitcoin:` URI; the other fields
        expose

        each generated destination separately for convenience. A field is `null`

        when that destination was not requested or could not be produced.
      required:
        - bip321
      properties:
        ark:
          type:
            - string
            - 'null'
          description: The generated Ark address, if any.
        bip321:
          type: string
          description: The combined BIP 321 `bitcoin:` URI.
        bolt11:
          type:
            - string
            - 'null'
          description: >-
            The generated BOLT11 invoice, included only when an amount was
            given.
        onchain:
          type:
            - string
            - 'null'
          description: >-
            The generated on-chain address, included only when `onchain` was
            set.
    BadRequestError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    InternalServerError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: AuthToken
      description: Base64url-encoded auth token

````