1. Create an API key
In the dashboard go to Settings → Developers → API keys and click Create key. Give it a name, pick an expiration and choose its permissions. For this guide grant Products: read, Orders: read & write and Payment links: read & write.
The full key (mk_live_...) is shown once. Store it as an environment variable on your server:
export MALLA_API_KEY="mk_live_..."2. Install the SDK (optional)
Everything works with plain HTTP, but the TypeScript SDK gives you types, retries and pagination for free.
npm install @malla/businesspnpm add @malla/businessbun add @malla/business3. Find something to sell
List your active products and pick a variant id. Every product has at least one variant; that's what orders reference.
curl "https://api.malla.fun/products?status=active&limit=3" \
-H "Authorization: Bearer $MALLA_API_KEY"
# Then the product, with its variants:
curl "https://api.malla.fun/products/PRODUCT_ID" \
-H "Authorization: Bearer $MALLA_API_KEY"import { Malla } from '@malla/business'
const malla = new Malla()
const { data: products } = await malla.products.list({ status: 'active', limit: 3 })
const product = await malla.products.retrieve(products[0].id)
const variantId = product.variants[0].id4. Place an order
The customer is found by phone, or created. Stock is reserved right away and the order starts as pending.
curl -X POST "https://api.malla.fun/orders" \
-H "Authorization: Bearer $MALLA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer": { "phone": "+503 7000 0000", "name": "Ana López" },
"items": [{ "variantId": "VARIANT_ID", "quantity": 2 }]
}'const order = await malla.orders.create({
customer: { phone: '+503 7000 0000', name: 'Ana López' },
items: [{ variantId, quantity: 2 }],
})
console.log(`#${order.orderNumber}: ${order.totalCents / 100} ${order.currency}`)5. Get paid
Create a payment link for the order and send its url to the customer (by WhatsApp, email or on your site). When they pay, the order becomes paid and you receive an order.paid webhook.
curl -X POST "https://api.malla.fun/payment-links" \
-H "Authorization: Bearer $MALLA_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "orderId": "ORDER_ID" }'const link = await malla.paymentLinks.create({ orderId: order.id })
console.log(link.url) // send this to the customerNext steps
- Learn how permissions and errors work.
- Subscribe to webhooks instead of polling.
- Browse the API reference.