Bag Docs
Guides

Create a Payment Link

Create a reusable payment link for your product and share it with customers.

Create a Payment Link

A payment link is a reusable checkout URL. You create one for each product, plan, or price point you sell. Bag gives you a hosted checkout page your customers can pay through — no frontend work required.


Before you start

You'll need:


import { Bag } from "@getbagsapp/sdk";

const bag = new Bag({
  apiKey: process.env.BAG_API_KEY!,
});

const link = await bag.paymentLinks.create({
  name: "Pro Plan",
  description: "Monthly subscription to the Pro plan",
  amount: 29.99,
  network: "base_sepolia",
});

console.log(`Checkout URL: https://justusebag.xyz/pay/${link._id}`);
import os
import requests

API_KEY = os.environ["BAG_API_KEY"]

response = requests.post(
    "https://justusebag.xyz/api/payment-links",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    },
    json={
        "name": "Pro Plan",
        "description": "Monthly subscription to the Pro plan",
        "amount": 29.99,
        "network": "base_sepolia",
    },
)

link = response.json()["data"]
print(f"Checkout URL: https://justusebag.xyz/pay/{link['_id']}")
curl -X POST https://justusebag.xyz/api/payment-links \
  -H "Authorization: Bearer $BAG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pro Plan",
    "description": "Monthly subscription to the Pro plan",
    "amount": 29.99,
    "network": "base_sepolia"
  }'

Response

{
  "status": "success",
  "data": {
    "_id": "665f1a2b3c4d5e6f7a8b9c0d",
    "name": "Pro Plan",
    "description": "Monthly subscription to the Pro plan",
    "amount": 29.99,
    "currency": "USD",
    "network": "base_sepolia",
    "token": "USDC",
    "active": true,
    "merchantWalletAddress": "0xYourWalletAddress",
    "totalCollected": 0,
    "totalTransactions": 0,
    "createdAt": "2026-03-01T12:00:00.000Z",
    "updatedAt": "2026-03-01T12:00:00.000Z"
  }
}

Your checkout page is live at https://justusebag.xyz/pay/{_id}. Share this URL with customers, embed it in your app, or redirect to it after a "Buy" button click.


Parameters

FieldTypeRequiredDescription
namestringYesDisplay name shown on the checkout page
amountnumberYesPrice in USD
networkstringYesPrimary blockchain network
descriptionstringNoDescription shown on checkout
currencystringNoDefaults to USD
tokenstringNoDefaults to USDC
networksstring[]NoAllow payment on multiple chains
merchantWalletAddressstringNoOverride the default receiving wallet
merchantWalletAddressesobjectNoPer-network wallet addresses

Supported networks

NetworkValueEnvironment
BasebaseProduction
EthereumethereumProduction
PolygonpolygonProduction
SolanasolanaProduction
Base Sepoliabase_sepoliaSandbox
Ethereum Sepoliaeth_sepoliaSandbox
Solana Devnetsolana_devnetSandbox

Change the name, amount, or deactivate a link:

const updated = await bag.paymentLinks.update("665f1a2b3c4d5e6f7a8b9c0d", {
  amount: 39.99,
  name: "Pro Plan (Annual)",
});
curl -X PATCH https://justusebag.xyz/api/payment-links/665f1a2b3c4d5e6f7a8b9c0d \
  -H "Authorization: Bearer $BAG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 39.99, "name": "Pro Plan (Annual)"}'

Deactivating a link prevents new payments. Existing transactions are unaffected.

await bag.paymentLinks.update("665f1a2b3c4d5e6f7a8b9c0d", {
  active: false,
});

await bag.paymentLinks.delete("665f1a2b3c4d5e6f7a8b9c0d");

Deleting is permanent. If you might want to re-enable the link later, deactivate it instead.


const links = await bag.paymentLinks.list();

for (const link of links) {
  console.log(`${link.name}: $${link.amount} — ${link.totalTransactions} payments`);
}

To let customers pay on any supported chain, pass the networks array and per-network wallet addresses:

const link = await bag.paymentLinks.create({
  name: "Pro Plan",
  amount: 29.99,
  network: "base",
  networks: ["base", "ethereum", "polygon", "solana"],
  merchantWalletAddresses: {
    base: "0xYourBaseWallet",
    ethereum: "0xYourEthWallet",
    polygon: "0xYourPolygonWallet",
    solana: "YourSolanaWalletAddress",
  },
});

The checkout page will show a network selector so the customer can choose where to pay. See Accept Payments on Multiple Chains for details.


What's next

On this page