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

# Custom Kitchen Ticket on a Star Cloud Printer

> Print a custom kitchen ticket with an allergen banner, big order code and station sections on a Star CloudPRNT printer driven by an order.created webhook.

storekit prints a fixed kitchen ticket. This recipe gives you a second ticket, laid out however you like, on a Star printer that your own app drives. storekit's printing and dashboard carry on exactly as before.

<Warning>
  There is no custom ticket template editor in the storekit dashboard, and the layout of storekit's own tickets cannot be changed. This recipe works around that with a printer that storekit does not know about. Read [What This Does Not Do](#what-this-does-not-do) before you buy hardware.
</Warning>

## How It Works

1. A guest places an order. storekit sends `order.created` to your app.
2. Your app turns the order into a ticket in your layout and puts it in a print queue.
3. A Star CloudPRNT printer, configured to point at your app instead of storekit, polls the queue every few seconds, prints the ticket and confirms it.

Everything in step 2 and 3 runs in the app the AI builder makes for you. Star's CloudPRNT protocol is public and simple — the printer asks "anything to print?" over HTTP, your app answers — so builders handle it well when given the rules below.

## What You Need

* Webhooks enabled on your storekit plan (**Settings** → **Developers**).
* A Star Micronics CloudPRNT printer that is **not** connected to storekit: a TSP100IV, mC-Print2, mC-Print3 or SP742 with the CloudPRNT firmware. If you already have one of these connected under **Direct Printing**, you need a second one — a printer can only poll one server.
* The printer's web configuration page, reached by its IP address on your network (see the printer's manual for how to print its network settings).
* A [Replit](https://replit.com) account. This recipe needs a public URL that stays up 24 hours a day plus a small database, which Replit provides. Lovable or Bolt work if you attach a backend; see [Choosing a Builder](/docs/guides/build/prompting-guide#choosing-a-builder).

## Step 1: Build the App

Paste the whole of the block below into the builder in a single message. Edit the section marked **MY TICKET LAYOUT** first — that is your layout, and the example is only a starting point.

<div className="sk-build-btns">
  <a className="sk-build-btn sk-build-btn--replit" href="https://replit.com/?stack=Build&prompt=JIAg7ghgdgLiEgM4FsIBs3gKYCMlYCcA3ASwGMsQYALCOABwJNkXhDIFdEYB7ZEANYkYZalihVyArHABmPAiCxFCATxAKAJoRCgCWCiRUaJ3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sF4sdA5+JEAxLxGNFCCxBWzgKKoI0Fso1HexjIWbEgMIh4DSQgTGIl6wRo1Q5EB-Qpjf1aY9MRmMzFZjsxESNgYcMs1WbrM7AmzbZg8n4nkFBRNBT5N2HbAC0hanyIITQVCE2AShfYMoQhLlrOQIeUPS6nfV-gpNaukxIQSI1SZbw0UXbHhHKSGoRh+AFYQELaX-AKBnqXwPJnWDjq1AmqBFVgCkH-FvhgoidcsJ3DSGhZQqGIRvgSDogwjuAPEbpkcKKSlh1SIMeAVPG6hvE9opHHRNi0vywjN6b9boZSGYbmAKK5oaYHUWa56s3agEr4EAA&referrer=docs.storekit.com" target="_blank" rel="noopener noreferrer" aria-label="Open in Replit">
    <img src="https://replit.com/badge?caption=Open%20in%20Replit" alt="Open in Replit" height="36" noZoom />
  </a>

  <a className="sk-build-btn sk-build-btn--lovable" href="https://lovable.dev/#prompt=I%20want%20a%20small%20web%20service%20that%20prints%20a%20custom%20kitchen%20ticket%20for%20every%20order%20I%20receive%20on%20storekit%2C%20on%20a%20Star%20CloudPRNT%20receipt%20printer%20that%20I%20own.%20It%20runs%20unattended%20in%20a%20restaurant%20kitchen%2C%20so%20it%20has%20to%20be%20reliable%20and%20boring%3A%20it%20must%20never%20print%20an%20order%20twice%2C%20never%20lose%20an%20order%20if%20it%20restarts%2C%20and%20never%20make%20storekit%20wait.%0A%0ATwo%20things%20talk%20to%20this%20service%3A%20storekit%20(sending%20me%20orders%20by%20webhook)%20and%20my%20Star%20printer%20(polling%20for%20jobs).%20Nobody%20else%20uses%20it%2C%20apart%20from%20me%20checking%20an%20admin%20page%20occasionally.%0A%0ABuild%20it%20with%20a%20database%20so%20the%20queue%20and%20the%20history%20survive%20restarts%20and%20redeploys.%20It%20needs%20an%20always-on%20public%20HTTPS%20URL.%0A%0ACONTEXT%20ABOUT%20STOREKIT%0A%0AI%20run%20a%20hospitality%20business%20on%20storekit%20(storekit.com)%2C%20an%20online%20ordering%20and%20payments%20platform%20for%20restaurants%2C%20caf%C3%A9s%20and%20bars.%20storekit%20can%20notify%20my%20own%20app%20about%20things%20that%20happen%20in%20my%20store%20by%20sending%20webhooks.%0A%0AHow%20storekit%20webhooks%20work%3A%0A-%20Each%20event%20is%20an%20HTTP%20POST%20with%20a%20JSON%20body%20to%20a%20URL%20I%20register%20in%20the%20storekit%20dashboard.%0A-%20The%20body%20always%20has%20the%20shape%20%7B%20%22event%22%3A%20%22%3Cevent%20type%3E%22%2C%20%22data%22%3A%20%7B%20...%20%7D%20%7D.%0A-%20Requests%20are%20signed%20with%20Svix.%20Every%20request%20carries%20the%20headers%20svix-id%2C%20svix-timestamp%20and%20svix-signature.%20Verify%20them%20with%20the%20official%20%60svix%60%20library%20for%20your%20language%2C%20using%20a%20secret%20I%20will%20provide%20in%20an%20environment%20variable%20called%20STOREKIT_WEBHOOK_SECRET.%20Reject%20anything%20that%20fails%20verification%20with%20HTTP%20400.%0A-%20My%20endpoint%20must%20respond%20with%20a%202xx%20status%20within%2015%20seconds.%20Save%20the%20event%20to%20the%20database%20first%2C%20respond%20200%2C%20then%20do%20the%20work%20from%20the%20saved%20copy.%0A-%20Once%20I%20have%20responded%20200%2C%20storekit%20will%20not%20send%20that%20event%20again%2C%20so%20the%20work%20must%20not%20be%20lost%3A%20store%20each%20event%20with%20a%20status%20(pending%2C%20done%2C%20failed)%20and%20only%20mark%20it%20done%20after%20the%20work%20has%20actually%20succeeded.%20On%20startup%20and%20on%20a%20timer%2C%20pick%20up%20anything%20still%20pending%20or%20failed%20and%20retry%20it.%20Never%20do%20the%20work%20only%20in%20memory%20after%20responding.%0A-%20The%20same%20event%20can%20occasionally%20be%20delivered%20more%20than%20once.%20Use%20the%20svix-id%20header%20as%20the%20unique%20key%20for%20the%20saved%20event%3A%20a%20repeat%20of%20an%20event%20already%20saved%20is%20ignored%2C%20whatever%20its%20status.%0A-%20Any%20page%20or%20endpoint%20protected%20by%20a%20password%20must%20be%20served%20over%20HTTPS%20only%3B%20redirect%20or%20refuse%20plain%20HTTP.%0A-%20Money%20fields%20(total%2C%20tip%2C%20deliveryFee%2C%20discountTotal%2C%20item%20price%2C%20modifier%20price)%20are%20integers%20in%20minor%20units%3A%202500%20means%20%C2%A325.00.%0A-%20orderType%20is%20one%20of%20Delivery%2C%20Pickup%2C%20InStore%2C%20Curbside%2C%20CateringDelivery%2C%20CateringPickup%20or%20Billpay.%0A-%20table%20and%20deliveryAddress%20can%20be%20null.%20notes%20can%20be%20null%20or%20empty.%0A%0AExample%20order.created%20payload%3A%0A%0A%7B%0A%20%20%22event%22%3A%20%22order.created%22%2C%0A%20%20%22data%22%3A%20%7B%0A%20%20%20%20%22id%22%3A%20%22ord_abc123%22%2C%0A%20%20%20%20%22code%22%3A%20%22A1B2%22%2C%0A%20%20%20%20%22asap%22%3A%20true%2C%0A%20%20%20%20%22total%22%3A%202500%2C%0A%20%20%20%20%22tip%22%3A%20250%2C%0A%20%20%20%20%22deliveryFee%22%3A%20299%2C%0A%20%20%20%20%22discountTotal%22%3A%200%2C%0A%20%20%20%20%22orderType%22%3A%20%22Pickup%22%2C%0A%20%20%20%20%22createdAt%22%3A%20%222024-01-15T10%3A30%3A00Z%22%2C%0A%20%20%20%20%22deliveryTime%22%3A%20%222024-01-15T11%3A00%3A00Z%22%2C%0A%20%20%20%20%22notes%22%3A%20%22Ring%20doorbell%22%2C%0A%20%20%20%20%22customer%22%3A%20%7B%0A%20%20%20%20%20%20%22firstName%22%3A%20%22John%22%2C%0A%20%20%20%20%20%20%22lastName%22%3A%20%22Doe%22%2C%0A%20%20%20%20%20%20%22email%22%3A%20%22john%40example.com%22%2C%0A%20%20%20%20%20%20%22phone%22%3A%20%22%2B44123456789%22%2C%0A%20%20%20%20%20%20%22marketingConsent%22%3A%20true%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22items%22%3A%20%5B%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22name%22%3A%20%22Margherita%20Pizza%22%2C%0A%20%20%20%20%20%20%20%20%22price%22%3A%201200%2C%0A%20%20%20%20%20%20%20%20%22quantity%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%22plu%22%3A%20null%2C%0A%20%20%20%20%20%20%20%20%22posId%22%3A%20null%2C%0A%20%20%20%20%20%20%20%20%22taxRate%22%3A%20null%2C%0A%20%20%20%20%20%20%20%20%22modifiers%22%3A%20%5B%5D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%2C%0A%20%20%20%20%22venue%22%3A%20%7B%0A%20%20%20%20%20%20%22id%22%3A%201234%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22My%20Restaurant%22%2C%0A%20%20%20%20%20%20%22slug%22%3A%20%22my-restaurant%22%2C%0A%20%20%20%20%20%20%22address%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22street1%22%3A%20%22123%20Main%20St%22%2C%0A%20%20%20%20%20%20%20%20%22street2%22%3A%20%22%22%2C%0A%20%20%20%20%20%20%20%20%22city%22%3A%20%22London%22%2C%0A%20%20%20%20%20%20%20%20%22postCode%22%3A%20%22W1A%201AA%22%2C%0A%20%20%20%20%20%20%20%20%22country%22%3A%20%22UK%22%2C%0A%20%20%20%20%20%20%20%20%22companyName%22%3A%20%22My%20Restaurant%20Ltd%22%2C%0A%20%20%20%20%20%20%20%20%22coordinates%22%3A%20%7B%20%22latitude%22%3A%2051.5074%2C%20%22longitude%22%3A%20-0.1278%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22table%22%3A%20%7B%0A%20%20%20%20%20%20%22id%22%3A%20%22tbl_123%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Table%205%22%2C%0A%20%20%20%20%20%20%22covers%22%3A%204%2C%0A%20%20%20%20%20%20%22posId%22%3A%20%22pos_tbl_5%22%2C%0A%20%20%20%20%20%20%22area%22%3A%20%7B%20%22id%22%3A%20%22area_1%22%2C%20%22name%22%3A%20%22Main%20Floor%22%2C%20%22posId%22%3A%20null%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22deliveryAddress%22%3A%20%7B%0A%20%20%20%20%20%20%22street1%22%3A%20%22456%20Oak%20Ave%22%2C%0A%20%20%20%20%20%20%22street2%22%3A%20%22Flat%202%22%2C%0A%20%20%20%20%20%20%22city%22%3A%20%22London%22%2C%0A%20%20%20%20%20%20%22postCode%22%3A%20%22E1%206AN%22%2C%0A%20%20%20%20%20%20%22country%22%3A%20%22UK%22%2C%0A%20%20%20%20%20%20%22coordinates%22%3A%20%7B%20%22latitude%22%3A%2051.5155%2C%20%22longitude%22%3A%20-0.0722%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0AThe%20full%20list%20of%20event%20types%20and%20payloads%20is%20at%20https%3A%2F%2Fstorekit.com%2Fdocs%2Fdevelopers%2Fwebhooks%2Fwebhook-events%0A%0ATHE%20PRINTER%3A%20STAR%20CLOUDPRNT%20PROTOCOL%0A%0AMy%20printer%20is%20a%20Star%20Micronics%20printer%20with%20CloudPRNT.%20I%20will%20type%20this%20service's%20URL%20into%20the%20printer's%20configuration%20page%2C%20and%20the%20printer%20will%20then%20poll%20it.%20Implement%20the%20server%20side%20of%20Star's%20CloudPRNT%20HTTP%20protocol%20at%20the%20path%20%2Fcloudprnt%2F%3CPRINTER_TOKEN%3E%2C%20where%20PRINTER_TOKEN%20is%20a%20long%20random%20secret%20from%20an%20environment%20variable.%20Tickets%20contain%20customer%20details%2C%20so%20any%20request%20to%20%2Fcloudprnt%20whose%20token%20segment%20does%20not%20match%20must%20get%20404%20and%20nothing%20else.%20Below%20I%20write%20%2Fcloudprnt%20for%20short%3B%20always%20include%20the%20token%20segment.%0A%0A-%20The%20printer%20POSTs%20a%20small%20JSON%20status%20object%20to%20%2Fcloudprnt%20every%20few%20seconds.%20Respond%20with%20JSON.%20When%20there%20is%20nothing%20queued%20respond%20%7B%20%22jobReady%22%3A%20false%20%7D.%20When%20there%20is%20a%20job%20respond%20%7B%20%22jobReady%22%3A%20true%2C%20%22mediaTypes%22%3A%20%5B%22text%2Fplain%22%5D%2C%20%22jobToken%22%3A%20%22%3Cid%20of%20the%20job%3E%22%2C%20%22deleteMethod%22%3A%20%22DELETE%22%20%7D%20%E2%80%94%20only%20ever%20hand%20out%20the%20job%20at%20the%20front%20of%20the%20queue.%0A-%20The%20printer%20then%20GETs%20%2Fcloudprnt%3Ftype%3Dtext%2Fplain%26token%3D%3CjobToken%3E%20(it%20may%20also%20send%20mac%20or%20uid%20query%20parameters%3B%20ignore%20them).%20Respond%20with%20the%20ticket%20body%20as%20plain%20text%2C%20Content-Type%20text%2Fplain.%20GET%20must%20be%20repeatable%3A%20return%20the%20same%20job%20again%20if%20asked%2C%20do%20not%20remove%20it%20from%20the%20queue.%0A-%20After%20printing%2C%20the%20printer%20sends%20DELETE%20%2Fcloudprnt%3Ftoken%3D%3CjobToken%3E%26code%3D%3Cresult%3E.%20The%20code%20is%20a%20URL-encoded%20result%3A%20%22200%20OK%22%20(or%20a%20code%20starting%20with%202)%20means%20it%20printed%20%E2%80%94%20mark%20the%20job%20printed%20and%20remove%20it%20from%20the%20queue.%20Any%20other%20code%20means%20the%20printer%20could%20not%20print%20it%20%E2%80%94%20mark%20the%20job%20%22failed%22%20with%20that%20code%2C%20remove%20it%20from%20the%20queue%20so%20the%20printer%20is%20not%20stuck%20on%20it%2C%20and%20leave%20it%20in%20the%20admin%20page%20so%20I%20can%20reprint%20it.%20DELETE%20must%20be%20idempotent%3A%20a%20repeat%20for%20a%20job%20already%20confirmed%20is%20fine%2C%20respond%20200.%0A-%20Never%20automatically%20re-queue%20a%20job%20the%20printer%20has%20fetched%20but%20not%20confirmed%3A%20the%20printer%20may%20have%20printed%20it%20and%20only%20lost%20the%20confirmation%2C%20and%20re-queueing%20would%20print%20it%20twice.%20Keep%20it%20in%20a%20%22printing%22%20state%20under%20its%20original%20token.%20If%20it%20has%20been%20in%20that%20state%20for%20more%20than%202%20minutes%2C%20show%20it%20as%20%22unconfirmed%22%20in%20the%20admin%20page%20with%20a%20Reprint%20button%2C%20and%20let%20me%20decide.%0A-%20Keep%20the%20whole%20poll%20cycle%20under%20a%20second%3B%20the%20printer%20polls%20constantly.%0A-%20Star%20publishes%20the%20protocol%20at%20https%3A%2F%2Fstar-m.jp%2Fproducts%2Fs_print%2Fsdk%2FStarCloudPRNT%2Fmanual%2Fen%2Fprotocol-reference%2Findex.html%20%E2%80%94%20follow%20it%20where%20it%20differs%20from%20my%20summary.%0A%0AUse%20plain%20text%20jobs.%20Take%20the%20line%20width%20from%20a%20COLUMNS%20environment%20variable%3A%2048%20for%20an%2080%20mm%20thermal%20printer%20(TSP100IV%2C%20mC-Print3)%2C%2042%20for%20an%20SP742%2C%20or%2032%20for%20a%2058%20mm%20printer%20(mC-Print2)%2C%20in%20the%20printer's%20default%20font.%20Every%20rule%20below%20that%20says%2048%20means%20COLUMNS.%20Use%20only%20ASCII%20characters.%20End%20every%20ticket%20with%20six%20blank%20lines%20so%20the%20paper%20feeds%20far%20enough%20to%20tear%20off.%0A%0AWHAT%20TO%20BUILD%0A%0A1.%20POST%20%2Fwebhooks%2Fstorekit%20%E2%80%94%20the%20storekit%20endpoint.%20Verify%20the%20Svix%20signature%20using%20the%20official%20svix%20library%20and%20the%20STOREKIT_WEBHOOK_SECRET%20environment%20variable%2C%20against%20the%20raw%20request%20body.%20Return%20400%20if%20verification%20fails.%20Return%20200%20immediately%20once%20the%20event%20is%20saved%2C%20before%20rendering%20or%20printing%20anything.%20Ignore%20any%20svix-id%20you%20have%20already%20saved.%20Handle%20the%20event%20type%20order.created%3B%20store%20and%20acknowledge%20any%20other%20event%20type%20but%20do%20nothing%20with%20it.%0A2.%20A%20renderer%20that%20turns%20an%20order.created%20payload%20into%20a%20ticket%20using%20MY%20TICKET%20LAYOUT%20below%2C%20and%20adds%20the%20ticket%20to%20the%20print%20queue.%0A3.%20The%20%2Fcloudprnt%20endpoints%20described%20above%2C%20backed%20by%20the%20queue%20in%20the%20database.%0A4.%20GET%20%2Fadmin%20%E2%80%94%20a%20single%20page%2C%20protected%20by%20HTTP%20basic%20auth%20using%20ADMIN_PASSWORD%2C%20listing%20the%20last%2050%20tickets%20with%20order%20code%2C%20time%2C%20status%20(queued%20%2F%20printing%20%2F%20unconfirmed%20%2F%20printed%20%2F%20failed%20with%20the%20printer's%20code)%20and%20a%20Reprint%20button%20that%20queues%20the%20same%20ticket%20again.%20At%20the%20top%2C%20show%20when%20the%20printer%20last%20polled%20and%20a%20green%2Fred%20indicator%3A%20red%20if%20it%20has%20not%20polled%20in%20the%20last%2060%20seconds.%20Also%20a%20Print%20test%20ticket%20button%20that%20queues%20a%20ticket%20with%20fake%20data%20so%20I%20can%20check%20the%20layout%20without%20a%20real%20order.%0A5.%20GET%20%2Fhealth%20that%20returns%20200%20and%20%7B%20%22ok%22%3A%20true%20%7D%20and%20nothing%20else%3B%20keep%20the%20queue%20length%20and%20last%20poll%20time%20on%20%2Fadmin%20only.%0A%0AMY%20TICKET%20LAYOUT%0A%0ARender%20every%20ticket%20exactly%20like%20this.%20Lines%20are%20COLUMNS%20characters%20wide%20(48%20in%20the%20examples).%20Centre%20text%20where%20shown.%20Use%20rows%20of%20%3D%20and%20-%20characters%20as%20separators.%20Where%20I%20write%20UPPER%20CASE%20below%20I%20mean%20print%20it%20in%20upper%20case.%0A%0A-%20Line%201%3A%20a%20full%20row%20of%20%3D%0A-%20Line%202%3A%20the%20order%20code%20(data.code)%20centred%2C%20printed%20on%20its%20own%20line%20and%20repeated%20on%20the%20next%20line%20so%20it%20stands%20out%20(my%20printer%20cannot%20do%20large%20fonts%20in%20plain%20text%2C%20so%20repetition%20is%20the%20emphasis).%0A-%20Line%203%3A%20the%20order%20type%2C%20centred%2C%20mapped%20exactly%20like%20this%3A%20Delivery%20-%3E%20%22DELIVERY%22%2C%20CateringDelivery%20-%3E%20%22CATERING%20DELIVERY%22%2C%20Pickup%20-%3E%20%22PICKUP%22%2C%20CateringPickup%20-%3E%20%22CATERING%20PICKUP%22%2C%20Curbside%20-%3E%20%22CURBSIDE%22%2C%20InStore%20-%3E%20table.name%20in%20upper%20case%20(e.g.%20%22TABLE%205%22)%20or%20%22IN%20STORE%22%20if%20table%20is%20null%2C%20Billpay%20-%3E%20%22BILL%20PAYMENT%22%2C%20anything%20else%20-%3E%20the%20raw%20value%20in%20upper%20case.%20For%20Delivery%20and%20CateringDelivery%2C%20then%20print%20on%20following%20lines%20the%20delivery%20address%20(deliveryAddress.street1%2C%20street2%20if%20not%20empty%2C%20postCode)%20and%20customer.phone.%0A-%20Line%204%3A%20%22Ordered%20%3CHH%3AMM%3E%22%20from%20createdAt%20in%20the%20venue's%20local%20time.%20If%20asap%20is%20false%2C%20add%20%22FOR%20%3CHH%3AMM%3E%22%20from%20deliveryTime%20on%20the%20same%20line%2C%20right-aligned.%20If%20asap%20is%20true%2C%20add%20%22ASAP%22%20instead.%0A-%20Line%205%3A%20a%20full%20row%20of%20-%0A-%20Then%20the%20items.%20For%20each%20item%3A%20quantity%2C%20space%2C%20item%20name%20in%20upper%20case%2C%20e.g.%20%222%20%20MARGHERITA%22.%20Underneath%2C%20each%20modifier%20indented%20by%20five%20spaces%20with%20a%20leading%20%22-%20%22%20e.g.%20%22%20%20%20%20%20-%20Extra%20basil%22.%20If%20an%20item%20has%20a%20notes%20field%20with%20text%20in%20it%2C%20print%20it%20indented%20under%20its%20modifiers%20prefixed%20with%20%22**%20%22.%20One%20blank%20line%20between%20items.%0A-%20Then%20a%20full%20row%20of%20-%0A-%20If%20data.notes%20or%20any%20item's%20notes%20contains%20the%20word%20%22allergy%22%20or%20%22allergic%22%20(any%20case)%2C%20print%20three%20lines%3A%20a%20row%20of%20!%2C%20then%20%22!!%20%20ALLERGY%20-%20SEE%20NOTES%20%20!!%22%20centred%2C%20then%20a%20row%20of%20!.%20Then%20print%20data.notes%20in%20full%20when%20present%2C%20wrapped%20to%2048%20characters.%20If%20data.notes%20is%20present%20but%20nothing%20mentions%20allergies%2C%20print%20%22Notes%3A%22%20followed%20by%20the%20wrapped%20notes.%20If%20there%20are%20no%20order%20notes%2C%20print%20nothing%20else%20here.%0A-%20Then%20a%20full%20row%20of%20-%0A-%20Then%20the%20customer's%20first%20name%20and%20last%20initial%20only%20(%22Jane%20D.%22)%2C%20the%20item%20count%20(%223%20items%22)%20and%20the%20total%20formatted%20from%20minor%20units%20with%20the%20currency%20code%20from%20a%20CURRENCY%20environment%20variable%20(%22Total%2025.00%20GBP%22).%20Do%20not%20guess%20a%20default%3A%20if%20CURRENCY%20or%20TIMEZONE%20is%20unset%2C%20refuse%20to%20start%20and%20log%20a%20clear%20message.%20No%20email%2C%20no%20full%20surname.%0A-%20Last%20line%3A%20a%20full%20row%20of%20%3D%2C%20then%20six%20blank%20lines.%0A%0ADEFINITION%20OF%20DONE%0A%0A-%20%5B%20%5D%20A%20signed%20order.created%20event%20queues%20exactly%20one%20ticket%2C%20and%20returns%20200%20in%20under%20one%20second.%0A-%20%5B%20%5D%20The%20same%20event%20sent%20twice%20queues%20one%20ticket%2C%20not%20two.%0A-%20%5B%20%5D%20A%20request%20with%20a%20bad%20signature%20returns%20400%20and%20queues%20nothing.%0A-%20%5B%20%5D%20%2Fcloudprnt%20returns%20jobReady%20false%20when%20the%20queue%20is%20empty%20and%20hands%20out%20one%20job%20at%20a%20time%20when%20it%20is%20not.%20A%20wrong%20PRINTER_TOKEN%20gets%20404.%0A-%20%5B%20%5D%20A%20DELETE%20with%20a%20non-success%20code%20marks%20the%20job%20failed%2C%20not%20printed%2C%20and%20it%20can%20be%20reprinted%20from%20%2Fadmin.%0A-%20%5B%20%5D%20A%20job%20fetched%20but%20never%20confirmed%20is%20shown%20as%20unconfirmed%2C%20and%20is%20not%20printed%20again%20unless%20I%20click%20Reprint.%0A-%20%5B%20%5D%20Restarting%20the%20service%20does%20not%20lose%20queued%20or%20historical%20tickets.%0A-%20%5B%20%5D%20%2Fadmin%20shows%20tickets%2C%20printer%20status%20and%20allows%20reprints%20and%20a%20test%20ticket.%0A-%20%5B%20%5D%20The%20example%20payload%20in%20the%20context%20renders%20with%20a%20PICKUP%20line%2C%20%221%20%20MARGHERITA%20PIZZA%22%2C%20%22Notes%3A%20Ring%20doorbell%22%2C%20%22John%20D.%22%20and%20%22Total%2025.00%20GBP%22%2C%20and%20no%20allergy%20banner.%0A-%20%5B%20%5D%20A%20payload%20whose%20notes%20read%20%22Severe%20nut%20allergy%22%20renders%20the%20allergy%20banner.%0A%0AWHAT%20TO%20GIVE%20ME%20WHEN%20YOU%20ARE%20DONE%0A%0A1.%20The%20public%20URL%20of%20the%20service%2C%20and%20the%20exact%20two%20URLs%20I%20will%20paste%3A%20the%20storekit%20webhook%20URL%20(%E2%80%A6%2Fwebhooks%2Fstorekit)%20and%20the%20printer%20URL%20(%E2%80%A6%2Fcloudprnt%2F%3CPRINTER_TOKEN%3E).%0A2.%20The%20environment%20variables%20I%20must%20set%20(STOREKIT_WEBHOOK_SECRET%2C%20ADMIN_PASSWORD%2C%20PRINTER_TOKEN%2C%20COLUMNS%2C%20CURRENCY%2C%20TIMEZONE%20for%20the%20venue's%20local%20time%2C%20and%20anything%20else%20you%20added)%20and%20where%20to%20set%20them%20on%20this%20platform.%0A3.%20How%20to%20confirm%20it%20is%20running%20always-on%2C%20not%20sleeping%20between%20requests.%0A4.%20A%20one-paragraph%20explanation%20of%20how%20to%20test%20it%20end%20to%20end%20before%20I%20connect%20the%20real%20printer.%0A" target="_blank" rel="noopener noreferrer" aria-label="Build with Lovable"><img src="https://mintcdn.com/storekit/IGeB_84apyho3Z6U/images/logos/lovable.svg?fit=max&auto=format&n=IGeB_84apyho3Z6U&q=85&s=cc21d11769d5e6b686fed56390a88f5e" alt="" width="20" height="20" noZoom data-path="images/logos/lovable.svg" /> Build with Lovable</a>
</div>

<p className="sk-build-btns__note">Either button opens the builder with the whole prompt below already filled in. Nothing starts until you press send, so read it through and edit the parts marked as yours first.</p>

<Accordion title="Full prompt (click to expand)">
  ```text theme={null}
  I want a small web service that prints a custom kitchen ticket for every order I receive on storekit, on a Star CloudPRNT receipt printer that I own. It runs unattended in a restaurant kitchen, so it has to be reliable and boring: it must never print an order twice, never lose an order if it restarts, and never make storekit wait.

  Two things talk to this service: storekit (sending me orders by webhook) and my Star printer (polling for jobs). Nobody else uses it, apart from me checking an admin page occasionally.

  Build it with a database so the queue and the history survive restarts and redeploys. It needs an always-on public HTTPS URL.

  ```

  ```text theme={null}
  CONTEXT ABOUT STOREKIT

  I run a hospitality business on storekit (storekit.com), an online ordering and payments platform for restaurants, cafés and bars. storekit can notify my own app about things that happen in my store by sending webhooks.

  How storekit webhooks work:
  - Each event is an HTTP POST with a JSON body to a URL I register in the storekit dashboard.
  - The body always has the shape { "event": "<event type>", "data": { ... } }.
  - Requests are signed with Svix. Every request carries the headers svix-id, svix-timestamp and svix-signature. Verify them with the official `svix` library for your language, using a secret I will provide in an environment variable called STOREKIT_WEBHOOK_SECRET. Reject anything that fails verification with HTTP 400.
  - My endpoint must respond with a 2xx status within 15 seconds. Save the event to the database first, respond 200, then do the work from the saved copy.
  - Once I have responded 200, storekit will not send that event again, so the work must not be lost: store each event with a status (pending, done, failed) and only mark it done after the work has actually succeeded. On startup and on a timer, pick up anything still pending or failed and retry it. Never do the work only in memory after responding.
  - The same event can occasionally be delivered more than once. Use the svix-id header as the unique key for the saved event: a repeat of an event already saved is ignored, whatever its status.
  - Any page or endpoint protected by a password must be served over HTTPS only; redirect or refuse plain HTTP.
  - Money fields (total, tip, deliveryFee, discountTotal, item price, modifier price) are integers in minor units: 2500 means £25.00.
  - orderType is one of Delivery, Pickup, InStore, Curbside, CateringDelivery, CateringPickup or Billpay.
  - table and deliveryAddress can be null. notes can be null or empty.

  Example order.created payload:

  {
    "event": "order.created",
    "data": {
      "id": "ord_abc123",
      "code": "A1B2",
      "asap": true,
      "total": 2500,
      "tip": 250,
      "deliveryFee": 299,
      "discountTotal": 0,
      "orderType": "Pickup",
      "createdAt": "2024-01-15T10:30:00Z",
      "deliveryTime": "2024-01-15T11:00:00Z",
      "notes": "Ring doorbell",
      "customer": {
        "firstName": "John",
        "lastName": "Doe",
        "email": "john@example.com",
        "phone": "+44123456789",
        "marketingConsent": true
      },
      "items": [
        {
          "name": "Margherita Pizza",
          "price": 1200,
          "quantity": 1,
          "plu": null,
          "posId": null,
          "taxRate": null,
          "modifiers": []
        }
      ],
      "venue": {
        "id": 1234,
        "name": "My Restaurant",
        "slug": "my-restaurant",
        "address": {
          "street1": "123 Main St",
          "street2": "",
          "city": "London",
          "postCode": "W1A 1AA",
          "country": "UK",
          "companyName": "My Restaurant Ltd",
          "coordinates": { "latitude": 51.5074, "longitude": -0.1278 }
        }
      },
      "table": {
        "id": "tbl_123",
        "name": "Table 5",
        "covers": 4,
        "posId": "pos_tbl_5",
        "area": { "id": "area_1", "name": "Main Floor", "posId": null }
      },
      "deliveryAddress": {
        "street1": "456 Oak Ave",
        "street2": "Flat 2",
        "city": "London",
        "postCode": "E1 6AN",
        "country": "UK",
        "coordinates": { "latitude": 51.5155, "longitude": -0.0722 }
      }
    }
  }

  The full list of event types and payloads is at https://storekit.com/docs/developers/webhooks/webhook-events
  ```

  ```text theme={null}
  THE PRINTER: STAR CLOUDPRNT PROTOCOL

  My printer is a Star Micronics printer with CloudPRNT. I will type this service's URL into the printer's configuration page, and the printer will then poll it. Implement the server side of Star's CloudPRNT HTTP protocol at the path /cloudprnt/<PRINTER_TOKEN>, where PRINTER_TOKEN is a long random secret from an environment variable. Tickets contain customer details, so any request to /cloudprnt whose token segment does not match must get 404 and nothing else. Below I write /cloudprnt for short; always include the token segment.

  - The printer POSTs a small JSON status object to /cloudprnt every few seconds. Respond with JSON. When there is nothing queued respond { "jobReady": false }. When there is a job respond { "jobReady": true, "mediaTypes": ["text/plain"], "jobToken": "<id of the job>", "deleteMethod": "DELETE" } — only ever hand out the job at the front of the queue.
  - The printer then GETs /cloudprnt?type=text/plain&token=<jobToken> (it may also send mac or uid query parameters; ignore them). Respond with the ticket body as plain text, Content-Type text/plain. GET must be repeatable: return the same job again if asked, do not remove it from the queue.
  - After printing, the printer sends DELETE /cloudprnt?token=<jobToken>&code=<result>. The code is a URL-encoded result: "200 OK" (or a code starting with 2) means it printed — mark the job printed and remove it from the queue. Any other code means the printer could not print it — mark the job "failed" with that code, remove it from the queue so the printer is not stuck on it, and leave it in the admin page so I can reprint it. DELETE must be idempotent: a repeat for a job already confirmed is fine, respond 200.
  - Never automatically re-queue a job the printer has fetched but not confirmed: the printer may have printed it and only lost the confirmation, and re-queueing would print it twice. Keep it in a "printing" state under its original token. If it has been in that state for more than 2 minutes, show it as "unconfirmed" in the admin page with a Reprint button, and let me decide.
  - Keep the whole poll cycle under a second; the printer polls constantly.
  - Star publishes the protocol at https://star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/protocol-reference/index.html — follow it where it differs from my summary.

  Use plain text jobs. Take the line width from a COLUMNS environment variable: 48 for an 80 mm thermal printer (TSP100IV, mC-Print3), 42 for an SP742, or 32 for a 58 mm printer (mC-Print2), in the printer's default font. Every rule below that says 48 means COLUMNS. Use only ASCII characters. End every ticket with six blank lines so the paper feeds far enough to tear off.

  WHAT TO BUILD

  1. POST /webhooks/storekit — the storekit endpoint. Verify the Svix signature using the official svix library and the STOREKIT_WEBHOOK_SECRET environment variable, against the raw request body. Return 400 if verification fails. Return 200 immediately once the event is saved, before rendering or printing anything. Ignore any svix-id you have already saved. Handle the event type order.created; store and acknowledge any other event type but do nothing with it.
  2. A renderer that turns an order.created payload into a ticket using MY TICKET LAYOUT below, and adds the ticket to the print queue.
  3. The /cloudprnt endpoints described above, backed by the queue in the database.
  4. GET /admin — a single page, protected by HTTP basic auth using ADMIN_PASSWORD, listing the last 50 tickets with order code, time, status (queued / printing / unconfirmed / printed / failed with the printer's code) and a Reprint button that queues the same ticket again. At the top, show when the printer last polled and a green/red indicator: red if it has not polled in the last 60 seconds. Also a Print test ticket button that queues a ticket with fake data so I can check the layout without a real order.
  5. GET /health that returns 200 and { "ok": true } and nothing else; keep the queue length and last poll time on /admin only.

  MY TICKET LAYOUT

  Render every ticket exactly like this. Lines are COLUMNS characters wide (48 in the examples). Centre text where shown. Use rows of = and - characters as separators. Where I write UPPER CASE below I mean print it in upper case.

  - Line 1: a full row of =
  - Line 2: the order code (data.code) centred, printed on its own line and repeated on the next line so it stands out (my printer cannot do large fonts in plain text, so repetition is the emphasis).
  - Line 3: the order type, centred, mapped exactly like this: Delivery -> "DELIVERY", CateringDelivery -> "CATERING DELIVERY", Pickup -> "PICKUP", CateringPickup -> "CATERING PICKUP", Curbside -> "CURBSIDE", InStore -> table.name in upper case (e.g. "TABLE 5") or "IN STORE" if table is null, Billpay -> "BILL PAYMENT", anything else -> the raw value in upper case. For Delivery and CateringDelivery, then print on following lines the delivery address (deliveryAddress.street1, street2 if not empty, postCode) and customer.phone.
  - Line 4: "Ordered <HH:MM>" from createdAt in the venue's local time. If asap is false, add "FOR <HH:MM>" from deliveryTime on the same line, right-aligned. If asap is true, add "ASAP" instead.
  - Line 5: a full row of -
  - Then the items. For each item: quantity, space, item name in upper case, e.g. "2  MARGHERITA". Underneath, each modifier indented by five spaces with a leading "- " e.g. "     - Extra basil". If an item has a notes field with text in it, print it indented under its modifiers prefixed with "** ". One blank line between items.
  - Then a full row of -
  - If data.notes or any item's notes contains the word "allergy" or "allergic" (any case), print three lines: a row of !, then "!!  ALLERGY - SEE NOTES  !!" centred, then a row of !. Then print data.notes in full when present, wrapped to 48 characters. If data.notes is present but nothing mentions allergies, print "Notes:" followed by the wrapped notes. If there are no order notes, print nothing else here.
  - Then a full row of -
  - Then the customer's first name and last initial only ("Jane D."), the item count ("3 items") and the total formatted from minor units with the currency code from a CURRENCY environment variable ("Total 25.00 GBP"). Do not guess a default: if CURRENCY or TIMEZONE is unset, refuse to start and log a clear message. No email, no full surname.
  - Last line: a full row of =, then six blank lines.

  DEFINITION OF DONE

  - [ ] A signed order.created event queues exactly one ticket, and returns 200 in under one second.
  - [ ] The same event sent twice queues one ticket, not two.
  - [ ] A request with a bad signature returns 400 and queues nothing.
  - [ ] /cloudprnt returns jobReady false when the queue is empty and hands out one job at a time when it is not. A wrong PRINTER_TOKEN gets 404.
  - [ ] A DELETE with a non-success code marks the job failed, not printed, and it can be reprinted from /admin.
  - [ ] A job fetched but never confirmed is shown as unconfirmed, and is not printed again unless I click Reprint.
  - [ ] Restarting the service does not lose queued or historical tickets.
  - [ ] /admin shows tickets, printer status and allows reprints and a test ticket.
  - [ ] The example payload in the context renders with a PICKUP line, "1  MARGHERITA PIZZA", "Notes: Ring doorbell", "John D." and "Total 25.00 GBP", and no allergy banner.
  - [ ] A payload whose notes read "Severe nut allergy" renders the allergy banner.

  WHAT TO GIVE ME WHEN YOU ARE DONE

  1. The public URL of the service, and the exact two URLs I will paste: the storekit webhook URL (…/webhooks/storekit) and the printer URL (…/cloudprnt/<PRINTER_TOKEN>).
  2. The environment variables I must set (STOREKIT_WEBHOOK_SECRET, ADMIN_PASSWORD, PRINTER_TOKEN, COLUMNS, CURRENCY, TIMEZONE for the venue's local time, and anything else you added) and where to set them on this platform.
  3. How to confirm it is running always-on, not sleeping between requests.
  4. A one-paragraph explanation of how to test it end to end before I connect the real printer.
  ```
</Accordion>

The builder will ask questions or hand back a working app. Fix problems by pasting the exact error, following [When the Builder Gets It Wrong](/docs/guides/build/prompting-guide#when-the-builder-gets-it-wrong). Before moving on, open `/admin`, click the test ticket button, and read the rendered ticket text in the queue — you can adjust the layout with follow-up messages now, before a printer is involved.

## Step 2: Connect storekit

<Steps>
  <Step title="Open the webhooks portal">
    In the dashboard sidebar, go to **Settings** → **Developers** and click **Manage Webhooks** (it reads **Enable Webhooks** the first time). Webhooks are a subscription feature — if you see **Upgrade to enable webhooks**, [contact support](/docs/getting-started/contact-support) first.
  </Step>

  <Step title="Add your app as an endpoint">
    In the embedded portal, add a new endpoint, paste the webhook URL your app builder gave you, and tick only the event types the recipe needs.
  </Step>

  <Step title="Copy the signing secret into your app">
    Open the endpoint you just created and copy its signing secret. In your app builder, save it as the environment variable `STOREKIT_WEBHOOK_SECRET` (builders call this "secrets" or "environment variables"). Redeploy if the builder asks you to.
  </Step>

  <Step title="Send a test event">
    Use the portal's test option on the endpoint to send a sample event. The delivery log shows the response code from your app. A `2xx` means your app accepted it; anything else, read the response body in the log — it is usually a missing secret.
  </Step>
</Steps>

Tick only `order.created` for this endpoint. The webhook URL is the one ending in `/webhooks/storekit`.

## Step 3: Point the Printer at Your App

<Steps>
  <Step title="Open the Star printer's own web page">
    Print the printer's network settings (the method varies by model — typically holding the feed button while powering on) and open the IP address shown in a browser on the same network.
  </Step>

  <Step title="Enter your app's URL">
    On the printer's web page (Star's interface, not the storekit dashboard) find the CloudPRNT settings and enable them. Enter the printer URL your builder gave you (the one containing `/cloudprnt/` followed by a long token — keep that token private, it is what stops anyone else reading your tickets) as the server URL, set a polling interval of a few seconds, and save. The exact field names vary by model and firmware; Star's manual for your printer is the reference.
  </Step>

  <Step title="Check the printer is polling">
    Reload `/admin`. The printer indicator turns green as soon as the first poll arrives. If it stays red, the printer cannot reach your URL — check that the URL is `https://`, that you saved the settings, and that the printer has internet access.
  </Step>

  <Step title="Print a test ticket">
    Click the test ticket button on `/admin`. The printer picks it up on its next poll.
  </Step>

  <Step title="Place a real order">
    Order something small on your own storefront. A ticket in your layout should print within a few seconds of the order confirmation.
  </Step>
</Steps>

## Ideas for Your Layout

Once the basic ticket prints, the layout is a follow-up message to the builder away:

* **Station sections**: group items by category into GRILL / COLD / DRINKS blocks, or queue a separate ticket per section.
* **Allergen matrix**: print a row of allergen abbreviations under each item from the item name or a lookup table you maintain in the admin page.
* **Course markers**: print a "---- MAINS ----" divider based on category.
* **Collection time countdown**: for pre-orders, print "READY IN 45 MIN" from the requested time.
* **Two copies**: queue the ticket twice — one for the pass, one for the driver.

## What This Does Not Do

* **It does not change storekit's ticket.** storekit prints to the printers under **Direct Printing** as before. If you want only your custom ticket, remove the printer from **Direct Printing** and point it at your app instead — but then storekit no longer knows the printer exists, so **Printers** status, `printer.status.offline` alerts and storekit's print log do not apply to it.
* **It is your service.** storekit support can confirm an `order.created` delivery reached your URL and what response it got; they cannot see or fix the app. If it stops printing, start at `/admin` and the delivery log in the webhooks portal.
* **Cancellations are not printed** unless you add them: `order.canceled` is a separate event, and a "CANCELLED" ticket is a natural next follow-up prompt.
* **Plain text only.** Logos, barcodes and large fonts need Star's binary formats, which the builder can add later if you ask for `application/vnd.star.starprnt` support.

## Related

<CardGroup cols={2}>
  <Card title="Writing a Prompt That Works" icon="wand-magic-sparkles" href="/docs/guides/build/prompting-guide">
    The structure behind this prompt, and what to say when the builder gets it wrong.
  </Card>

  <Card title="Printer Setup" icon="print" href="/docs/guides/printing/printer-setup">
    storekit's own printing, including how to connect a Star CloudPRNT printer to storekit.
  </Card>

  <Card title="order.created payload" icon="code" href="/docs/developers/webhooks/webhook-events#order-created">
    Every field available for your layout.
  </Card>

  <Card title="Verifying Signatures" icon="shield-check" href="/docs/developers/webhooks/verifying-signatures">
    What the builder is doing when it checks the Svix headers.
  </Card>
</CardGroup>


## Related topics

- [6. Connect a cloud receipt printer](/docs/getting-started/launch/connect-printing.md)
- [Set up a Star Micronics cloud printer](/docs/guides/printing/printer-setup.md)
- [Troubleshoot Star printer connectivity and order printing](/docs/guides/printing/troubleshooting.md)
- [Build Your Own Tools on storekit](/docs/guides/build/overview.md)
- [Order Batching](/docs/guides/orders/advanced/order-batching.md)
