Sell from Claude Code

Create a listing, upload a file, attach it as a deliverable, and publish — all from a Python script.

A user says “sell my ebook for $19.” The agent needs to create a listing, upload the file, attach it as a deliverable, and publish — four API calls in sequence.

Full script

1import os
2from listbee import ListBee
3
4client = ListBee(api_key=os.environ["LISTBEE_API_KEY"])
5
6# 1. Create a draft listing
7listing = client.listings.create(
8 name="Python Automation Handbook",
9 price=1900, # $19.00
10 content_type="static", # ListBee delivers the file automatically after payment
11 description="A practical guide to automating repetitive tasks with Python.",
12)
13
14print(f"Listing created: {listing.id}")
15print(f"Status: {listing.status}") # draft
16print(f"Sellable: {listing.readiness.sellable}") # False — no deliverable yet
17
18# 2. Upload the file
19with open("handbook.pdf", "rb") as f:
20 file = client.files.upload(file=f, filename="handbook.pdf")
21
22print(f"File uploaded: {file.token}")
23
24# 3. Attach the file as a deliverable
25client.listings.add_deliverable(
26 listing_id=listing.id,
27 type="file",
28 token=file.token,
29)
30
31print("Deliverable attached")
32
33# 4. Publish the listing
34published = client.listings.publish(listing_id=listing.id)
35
36print(f"Status: {published.status}") # published
37print(f"Product page: {published.url}") # https://buy.listbee.so/python-automation-handbook
38print(f"Sellable: {published.readiness.sellable}") # True

What happens

Step 1 — Create listing. content_type="static" tells ListBee to deliver the file automatically after payment. The listing is created in draft status. The readiness object in the response includes a no_deliverable action pointing to the next call.

Step 2 — Upload file. POST /v1/files uploads the file to Bunny CDN and returns a token. The token is a reference — it doesn’t contain the file content.

Step 3 — Attach deliverable. POST /v1/listings/{id}/deliverables links the uploaded file to the listing. Buyers receive a signed download link valid for 48 hours and up to 10 downloads after payment.

Step 4 — Publish. POST /v1/listings/{id}/publish makes the listing live. The product page is immediately accessible. readiness.sellable becomes true.

Reading the readiness object

After step 1, the response looks like:

1{
2 "object": "listing",
3 "id": "lst_abc123",
4 "status": "draft",
5 "readiness": {
6 "sellable": false,
7 "actions": [
8 {
9 "code": "no_deliverable",
10 "kind": "api",
11 "message": "Attach a deliverable so buyers receive content after payment.",
12 "resolve": {
13 "method": "POST",
14 "endpoint": "/v1/listings/lst_abc123/deliverables",
15 "params": null
16 }
17 }
18 ],
19 "next": "no_deliverable"
20 }
21}

readiness.next is the action code the agent should resolve first. After attaching a deliverable, next becomes not_published. After publishing, next becomes null and sellable becomes true.

Agents can follow this chain without any hardcoded logic about what comes next.

Variations

URL deliverable instead of file upload — skip steps 2 and 3, use type="url" with a value:

1client.listings.add_deliverable(
2 listing_id=listing.id,
3 type="url",
4 value="https://example.com/download/handbook",
5)

Text deliverable — deliver a license key, access code, or any short text:

1client.listings.add_deliverable(
2 listing_id=listing.id,
3 type="text",
4 value="Your license key: XXXX-XXXX-XXXX-XXXX",
5)

AI-generated content — use content_type="generated" instead of static. ListBee holds the order in processing status until the agent calls fulfill_order with the generated content. See Fulfillment for details.