# 0cean as a channel: for cross-listing and multichannel tools

You make a tool that lists a seller's products in many places at once: a cross-lister (Crosslist, Vendoo, List
Perfectly, Nifty), a dealer's inventory tool (Ronati, Uploadify), multichannel software or a feed tool. This page is
how to add 0cean as one more place.

What your sellers get: **no fee**, ever. Buyers pay by card on 0cean's own page, straight into the seller's own
Stripe account (a direct charge, no application fee, the network never holds the money). AI shopping assistants ask
0cean directly, so the seller's products are found where people now shop by asking.

What you get: a few REST calls, the seller's own codes (SKU) as the key, pieces counted, and a webhook the moment a
piece sells here, so your delist works both ways. No partnership, no contract, no review queue.

All addresses below are on the network's public address (`https://get0cean.com`). Every answer is JSON. Errors are
`{"error": "<code>", "message": "<a sentence to show the seller>"}` with the HTTP status that fits. The whole API is
also an OpenAPI 3.1 document: `GET /v1/openapi.json`.

| You are | Start at |
|-|-|
| A cross-lister or multichannel tool | 1 (your key), 2 (OAuth 2.0 or the connect page), 3 (cards by SKU), 4 (events) |
| An order or shipping tool | 5 (orders: where each goes, shipments, refunds) |
| A ShipStation user | 6 (Custom Store: no code at all) |
| A feed tool | 8 (the door reads your feed) |

## 1. Your tool's own key

Write to the network (the address on `/terms`) with your tool's name, the host your users come back to after the
connect page, and an address for us to write to. You get a key, `int_...`, free, shown once. Send it with every call:

```
X-Integrator-Key: int_...
```

With it your calls are counted as your tool, apart from everyone else: 300 doors an hour and 3,000 a day, 1,200
changes a minute over all your sellers (a batch is one change), 200 files an hour. Write if you need more. Every card
you put in is marked with your tool's name (`via`), so the seller sees who put what in. The key buys nothing in the
order of offers: one open formula orders every card, whoever put it in.

Without the key everything below still works, at the limits of one person.

## 2. A seller's door

A seller's products live in their **door**: `https://get0cean.com/s/<door>`. A door has its own key, `door_...`,
shown once when it is opened. There are two ways to get a key to a seller's door.

### The connect page (recommended)

Send the seller to:

```
https://get0cean.com/connect-door?tool=<your id>&return_url=<an https address on your host>&state=<your own value>
```

The page tells the seller what 0cean is and what your tool will do. The seller opens a new door there (a name and
what they sell), or names the door they already have with its key. Then they are sent back to `return_url` with
`?code=cc_...&state=<yours>`. Trade the code, from your server, within ten minutes:

```
POST /v1/integrators/connect
X-Integrator-Key: int_...
{"code": "cc_..."}

→ 200 {"door": "hall-antiques", "key": "door_...", "seller": {...}}
```

That key is **your tool's own key to the door**. With it you add, change and remove cards, read the door's events and
name webhooks. You cannot close the door or let other tools in. The seller keeps the door's own key, sees your tool
on `/door-tools` and can take your key back at any time; then your calls answer 401.

`return_url` must be on a host named when your key was made. `state` is yours: up to 200 of `A-Z a-z 0-9 . _ ~ -`.

### OAuth 2.0

The same connect page under the names an OAuth client expects:

```
GET  /oauth/authorize?response_type=code&client_id=<your id>&redirect_uri=<https on your host>&state=<yours>
POST /oauth/token   grant_type=authorization_code&code=cc_...&client_id=<your id>&client_secret=int_...
     (form or JSON; the client may also authenticate with HTTP Basic)

→ 200 {"access_token": "door_...", "token_type": "Bearer", "scope": "door", "door": "hall-antiques"}
```

The token is your tool's own key to the door, as above. It does not run out, so there is no refresh token: the
seller takes it back on their page and your calls then answer 401.

### Open the door yourself

```
POST /v1/sellers
X-Integrator-Key: int_...
{"name": "Hall Antiques", "categories": ["furniture", "home-decor"], "about": "Mid-century lighting and furniture, London."}

→ 201 {"handle": "hall-antiques", "key": "door_...", ...}
```

This key is the door's own. Give it to the seller (it is theirs) and keep it as they allow. `categories`: one to
five of `GET /v1/categories`.

### Card payments

A door takes cards once the seller has a Stripe account of their own, connected through the network:

```
POST /v1/sellers/<door>/stripe
Authorization: Bearer door_...
X-Integrator-Key: int_...
{"country": "GB", "ships_to": ["GB", "US", "FR"], "return_url": "https://app.yourtool.com/0cean/done"}

→ 200 {"card_payments": "pending", "url": "https://connect.stripe.com/..."}
```

Send the seller to `url`: it is Stripe's own onboarding, it works once and runs out in a few minutes (ask again for a
new one). When they finish, Stripe sends them to 0cean, which shows a button back to your `return_url`. `GET` on the
same address says `"card_payments": "ready"` once Stripe lets the account take payments. `ships_to`: the countries
the seller sends to; the payment page asks the buyer's address only there, and buyers elsewhere are not shown the
card. Until cards are ready, a card may carry the seller's own payment link (`pay_url`) instead.

## 3. Cards, by your codes

A card is found by the seller's own code for the product (`sku`), unique in the door.

```
PUT /v1/sellers/<door>/items/<sku>        add the card with this code, or change it (only the fields sent change)
GET /v1/sellers/<door>/items/<sku>        the card
DELETE /v1/sellers/<door>/items/<sku>     remove it
```

Write the code in the address as a URL writes it (`CHAIR%2F01`). Every call takes
`Authorization: Bearer door_...` and your `X-Integrator-Key`.

```
PUT /v1/sellers/hall-antiques/items/LAMP-0042
{
  "title": "Brass Floor Lamp by Stilnovo, 1960s",
  "description": "Original brass, rewired 2024. Linen shade.",
  "price": 1200, "currency": "GBP",
  "quantity": 1,
  "image_url": "https://img.yourtool.com/lamp-1.jpg",
  "images": ["https://img.yourtool.com/lamp-2.jpg", "https://img.yourtool.com/lamp-3.jpg"],
  "condition": "vintage",
  "brand": "Stilnovo", "period": "1960s", "materials": "Brass, linen",
  "dimensions": "42 x 42 x 160 cm", "weight": "9 kg",
  "product_type": "Home & Garden > Lighting > Floor Lamps",
  "elsewhere": [{"where": "chairish", "price": 1450}, {"where": "1stdibs", "price": 1600}]
}

→ 201 (added) or 200 (changed): the card, with "id", "page", "pay_url", "via"
```

| Field | What it means |
|-|-|
| `title` | Needed for a new card. 3 to 140 characters, in the words a buyer searches with. |
| `price`, `currency` | Needed for a new card. A number; three letters, `USD` when left out. |
| `quantity` | Pieces on hand, a whole number. **A one-of-a-kind piece is 1.** Counted, a paid order takes its pieces off and at 0 the card is sold out. `null`: not counted, and `in_stock` is your word alone. |
| `in_stock` | Only for a card whose pieces are not counted. With `quantity`, stock follows the pieces. |
| `image_url`, `images` | https pictures: the first, then up to 9 more. Or send the first picture itself: `PUT /v1/sellers/<door>/products/<id>/image`, JPEG, PNG or WebP, at most 2 MB. |
| `condition` | `new`, `like_new`, `used`, `refurbished`, `vintage` or `antique`. |
| `brand`, `period`, `materials`, `dimensions`, `weight`, `product_type` | The seller's words, shown on the product's page. |
| `elsewhere` | The seller's own prices on marketplaces: `amazon`, `etsy`, `ebay`, `walmart`, `tiktok`, `chairish`, `1stdibs`, `rubylane`, `poshmark`, `mercari`, `facebook`, `vinted`, `depop`, `grailed`, `shopify`. When the price here is lower, the buyer is shown the dearest one and how much less it is here. It plays no part in the order of offers. |
| `pay_url` | The seller's own payment link, for a door without card payments. |
| `description` | Plain text, up to 2,000 characters. |
| `gtin` | The barcode: UPC (12 digits), EAN (13), GTIN-14 or EAN-8, spaces and dashes left out. A wrong check digit is refused. The same product at other stores is found by it. |

A door holds 5,000 cards. Every card is read against the short public list of what may not be sold (`GET /v1/rules`);
a card that breaks it is refused with the rule named.

### Variants: sizes, colours, every option with its own code

A card in more than one option carries `options` (the names, up to three) and `variants` (up to 100), each with its own
code, price, pieces, barcode and picture. The card's own price, pieces and stock then follow its variants: in stock
while one is, the lowest price in stock, every piece counted together.

```
PUT /v1/sellers/hall-tees/items/TEE
{"title": "Organic cotton tee", "options": ["Size", "Color"], "variants": [
  {"options": {"Size": "M", "Color": "White"}, "sku": "TEE-M-W", "price": 24, "quantity": 5, "gtin": "036000291452"},
  {"options": {"Size": "L", "Color": "Black"}, "sku": "TEE-L-B", "price": 26, "quantity": 2, "image_url": "https://..."}
]}
```

Each variant is then its own code, as tools name it:

```
PUT    /v1/sellers/<door>/items/TEE-M-W   {"quantity": 3, "price": 22}                  change that variant
PUT    /v1/sellers/<door>/items/TEE-XL-W  {"parent_sku": "TEE", "options": {"Size": "XL", "Color": "White"}, "price": 26}   add one
GET    /v1/sellers/<door>/items/TEE-M-W   the card, with "variant": the one this code names
DELETE /v1/sellers/<door>/items/TEE-M-W   remove that variant
```

A batch takes the same: `{"sku": "TEE-M-W", "quantity": 0}`, `{"op": "delete", "sku": "TEE-M-W"}`. `variants` sent with
the card is the whole list: a variant left out is removed; one is kept by its `id` or its `sku`. A card with variants
does not take a price or pieces of its own (400): they are its variants'. An order's line names the variant paid for
by its own `sku`, with `parent_sku` and its `options`; `order.paid`, `item.sold_out` and `order.shipped` name the
variant's code too.

### Many at once

```
POST /v1/sellers/<door>/batch
{"items": [
  {"op": "put", "sku": "LAMP-0042", "price": 1150},
  {"op": "put", "sku": "TABLE-7", "title": "Oak Side Table, Victorian", "price": 410, "quantity": 1, "condition": "antique"},
  {"op": "delete", "sku": "VASE-3"}
]}

→ 200 {"done": 3, "refused": 0, "results": [{"i": 0, "ok": true, "id": "...", "sku": "LAMP-0042", "done": "changed"}, ...]}
```

Up to 500 changes a call, each on its own: one that is refused (`"ok": false, "error", "message"`) does not stop the
others. A new card in a batch needs its `sku`.

## 4. When something happens: events and webhooks

The door keeps a log of what happened that your tool did not do itself: a paid order, a refund, a card sold out or
back in stock, a card or the door taken down by a rule, the door's feed read, a buyer's review.

```
GET /v1/sellers/<door>/events?after=<the last seq you saw>

→ 200 {"last": 42, "more": false, "events": [{"seq": 41, "id": "evt_...", "type": "order.paid", "at": "...", "data": {...}}, ...]}
```

Better: name a webhook, and each event is POSTed to it as it happens.

```
POST /v1/sellers/<door>/webhooks
{"url": "https://hooks.yourtool.com/0cean", "events": ["order.paid", "item.sold_out", "order.refunded"]}

→ 201 {"id": "wh_...", "secret": "whsec_...", ...}      the secret is shown once
```

Leave `events` out for all of them. `GET` lists the door's webhooks (yours, or all of them for the seller) with how
the last send went; `DELETE /v1/sellers/<door>/webhooks/<id>` removes one. A door names ten at most.

Each POST is signed by the [Standard Webhooks](https://www.standardwebhooks.com/) scheme. The headers are
`webhook-id`, `webhook-timestamp` and `webhook-signature: v1,<base64>`, where the signature is HMAC-SHA256 of
`<webhook-id>.<webhook-timestamp>.<body>` with the secret's bytes (the part after `whsec_`, base64-decoded). Answer
2xx. A failed send is tried again after a minute, ten minutes, an hour and six hours; whatever is still missed is in
the log, so a tool that reads the log now and then never misses one.

| Event | `data` |
|-|-|
| `order.held` | `product`, `sku`, `title`, `quantity`, `quantity_left` (counted cards), `amount` and `currency` (smallest unit), `order`, `confirm_by`. The buyer's card holds the sum and the piece is put aside until the seller confirms (then `order.paid`) or says it already sold (then `order.cancelled`, `reason: "sold_elsewhere"`); not confirmed in 48 hours, `order.cancelled` with `reason: "not_confirmed"` and the piece back on sale. Take the piece off elsewhere at once. |
| `order.paid` | `product`, `sku`, `title`, `quantity`, `quantity_left` (counted cards), `amount` and `currency` (smallest unit), `order`, `confirmed_by`: `stripe`, or `seller` for a sale they marked |
| `item.sold_out` | `product`, `sku`, `title`, `quantity_left`, `by` (who: `seller`, a tool's id, `feed`; after an order there is none) |
| `item.back_in_stock` | the same |
| `order.refunded` | `product`, `sku`, `order`, `amount_refunded`, `amount`, `currency`, `whole`. Nothing goes back on sale by itself: whether the piece came back is the seller's to say. |
| `order.shipped` | `order`, `product`, `sku`, `carrier`, `tracking_number` (none for a parcel an inventory system sent untracked), `tracking_url` when told, `by` |
| `order.cancelled` | `order`, `product`, `sku`, `by`; with `refunded: true` (and Stripe's `refund` id, unless the payment was refunded already) when the cancellation gave the buyer's money back before it was made |
| `item.taken_down` | `product`, `sku`, `title`, `rule` |
| `door.taken_down` | `rule` |
| `feed.read` | `added`, `changed`, `refused`, `cards` |
| `review.posted` | `order`, `stars`, `changed` (true when the buyer changed their review). The words are on the door's page and in `reviews` of `GET /v1/sellers/<door>`. |

**Nothing about the buyer is in an event, or kept anywhere in the network.** Where an order goes is read from the
seller's own Stripe account at the moment the door's holder asks for it (below), and passed on, never written down.

### Held orders

A door holds a buyer's card until its seller confirms each order (docs/SELL.md, "Held until you confirm"). With the
door's key, or a tool's key to it:

```
GET  /v1/sellers/<door>/holds                    → {"hold_hours": 48, "holds": [{"id": "cs_...", "state": "held", "confirm_by": "...", ...}]}
POST /v1/sellers/<door>/holds/<id>/confirm       the sum is taken on the seller's own Stripe account: an order like any paid one
POST /v1/sellers/<door>/holds/<id>/release       already sold elsewhere: nothing is charged, and the card is sold out here
```

`state` is `held`, `confirmed`, `sold` or `lapsed`. Twice is once; a hold that ended answers 409.

## 5. Orders: where each goes, shipped, cancelled, refunded

What an order tool needs to fulfil an order, in the shape such tools read: changed since a time, in pages, by state,
each line by the seller's SKU, and where it goes.

```
GET /v1/sellers/<door>/orders?since=2026-11-21T00:00:00Z&status=awaiting_shipment&limit=100&include=ship_to

→ 200 {"orders": [{
         "order": "cs_live_...", "number": "A1B2C3D4E5", "at": "...", "changed": "...",
         "status": "awaiting_shipment", "paid": true, "confirmed_by": "stripe",
         "currency": "USD", "total": 4500, "total_amount": 45, "shipping_amount": 0, "tax_amount": 0,
         "lines": [{"product": "...", "sku": "LAMP-1", "title": "...", "quantity": 1, "unit_price": 45, "amount": 4500}],
         "shipments": [],
         "ship_to": {"name": "...", "address": {"line1": "...", "line2": "...", "city": "...", "state": "...", "postal_code": "...", "country": "US"}, "phone": "...", "email": "..."}
       }], "has_more": false, "next_cursor": "..."}
```

- `status`: `awaiting_shipment`, `shipped`, `cancelled`, `refunded`. `since` is when the order last changed. `cursor`
  is the `next_cursor` of the page before. 100 a page, 50 with `include=ship_to`.
- `ship_to` is read from the seller's Stripe account when you ask, ten orders at a time, and kept nowhere. Without
  `include=ship_to` Stripe is not asked. A sale the seller marked themself has none: the network never saw it.
- Amounts are in the currency's smallest unit; `total_amount` and `unit_price` are in the currency itself.
  Shipping is in the price (doors add none at payment), and no tax is added.

```
GET  /v1/sellers/<door>/orders/<order>                    one order, always with ship_to
POST /v1/sellers/<door>/orders/<order>/acknowledge        your tool took it in
POST /v1/sellers/<door>/orders/<order>/shipments          {"carrier": "ups", "service": "Ground", "tracking_number": "1Z...", "tracking_url": "https://..."}
POST /v1/sellers/<door>/orders/<order>/cancel             {"reason": "..."}: before it ships; moves no money
POST /v1/sellers/<door>/orders/<order>/refund             {"amount": 1500} or nothing for the whole order; Idempotency-Key honoured
```

- A shipment told twice with the same tracking number is one parcel: the second call answers 200 and adds nothing.
  The door's other tools hear `order.shipped`, and the buyer of a card payment gets a letter with the tracking number
  and a link to rate the seller ([SELL.md](SELL.md), "Reviews"). The same goes for a shipment ShipStation tells.
- A refund is made on the seller's own Stripe account, as the seller would make it in the Dashboard. The network
  takes no part of it and never holds the money. `order.refunded` follows when Stripe confirms it.
- A shipped order is not cancelled (409): refund it.
- An order an inventory system is cancelling, while its refund is under way at Stripe (seconds, a minute at most),
  takes no shipment: told again after that, it is shipped, or refused as cancelled.

`GET /v1/sellers/<door>/orders` with none of these parameters still lists every order as before (`order`,
`product`, `sku`, `status`, `quantity`, `amount`, `confirmed_by`).

## 6. ShipStation: a Custom Store, no code

Every ShipStation user connects a door on their own, in ShipStation: Settings, Selling Channels, Store Setup,
Connect a Store, **Custom Store**.

| ShipStation asks | Give it |
|-|-|
| URL to custom XML page | `https://get0cean.com/v1/shipstation/<door>` |
| Username | the door's short name |
| Password | the door's key, or a tool's key to the door |
| Statuses | `paid` → Awaiting Shipment, `shipped` → Shipped, `cancelled` → Cancelled |

ShipStation reads the paid orders as its XML (`action=export`, with the buyer's address read from Stripe at that
moment), prints the labels, and posts each shipment back (`action=shipnotify`). The door's tools hear
`order.shipped`. ShipStation's times are read as UTC, and the window it asks for is opened 14 hours earlier so that
no time zone loses an order; ShipStation keeps an order once by its number. A shipment finds its order by the id it
was exported with (`OrderID`, when ShipStation gives it back whole) or by its number: should two of the door's orders
ever share a number, a shipment named by that number alone is refused (409) rather than put on either.

## 7. A sale made elsewhere

When a piece sells on another marketplace, set its pieces: `PUT .../items/<sku> {"quantity": 0}` (or remove the
card). When the seller was paid outside the network and wants it counted, `POST
/v1/sellers/<door>/products/<id>/sold {"quantity": 1}` marks it as the seller's own word, takes the pieces off, and
tells the door's other tools.

## 8. No code at all: the door reads a feed

If your tool already makes a product feed for a "custom channel" (DataFeedWatch, Channable, GoDataFeed, Productsup,
a Shopify or WooCommerce feed app), the door can read it:

```
PATCH /v1/sellers/<door>
{"feed_url": "https://feeds.yourtool.com/hall-antiques.xml"}
```

The feed is read within minutes and every six hours after (`POST /v1/sellers/<door>/feed` reads it now, once in ten
minutes). XML (RSS or Atom), CSV or TSV with a header row, or JSON, in the common shopping feed's fields: `id`
(the card's code), `title`, `description`, `price`, `sale_price`, `availability`, `quantity`, `image_link`,
`additional_image_link`, `condition`, `brand`, `product_type` or `google_product_category`, `shipping_weight`,
`material`. The products' own links are not needed: their pages here are the network's. A product the feed no longer
has goes off sale. 30 MB and 5,000 products at most. `"feed_url": null` stops it.

## What the network does not do

- It takes no fee and sells no placement, to sellers or to tools. Your key changes nothing in where a card is shown.
- It never holds money. A card payment is a direct charge on the seller's own Stripe account.
- It keeps nothing about buyers: where an order goes is read from the seller's Stripe account when asked.
- It does not write to sellers on any marketplace, and it does not log in anywhere for them.

## For whoever runs a copy of the network

```
open-network integrators                                            the tools and how many doors each holds
open-network integrator add crosslist --name Crosslist --returns app.crosslist.com --contact partners@crosslist.com
open-network integrator crosslist --rekey | --off | --on | --returns a.com,b.com
```

The key is shown once; only its fingerprint is kept (`integrators.json` in the state folder). `--off` stops the
tool's key and its keys to doors at once; the doors stay their sellers'.

The code: `src/channel-http.ts` (the addresses, OAuth, ShipStation), `src/hosted.ts` (cards, codes, pieces, grants,
webhooks), `src/fulfil.ts` (shipments and cancels), `src/shipstation.ts` (its XML), `src/door-events.ts` (the log and
the webhooks), `src/integrators.ts` (tools' keys and the connect codes), `src/door-feed.ts` (a door's own feed),
`src/openapi.ts` (the OpenAPI document). Tests: `test/channel.test.ts`, `test/seller-tools.test.ts`.
