Skip to content

About

Crossly add-on for Google Sheets: pull inventory, listings, orders and sales into a sheet, bulk-edit stock and prices, and push them back to eBay, Poshmark, Mercari and more. Apps Script + clasp.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Crossly for Google Workspace

CI Release License: MIT Apps Script V8

A Google Workspace add-on for Crossly, the multi-marketplace crossposting platform for resellers. One Apps Script project and one Google Workspace Marketplace listing give you a Crossly side panel in Gmail, Drive, Calendar, Docs and Sheets.

App What the Crossly panel does
Gmail Open a sale, offer or buyer-message email from eBay, Poshmark, Mercari, Depop, Etsy, Grailed, Vinted, Whatnot, Facebook Marketplace, Shopify (and more) and the panel shows the matching Crossly order, conversation, offer or listing. You can mark the order shipped with a tracking number, message the buyer, reply in the thread, or accept, counter or decline the offer. Other mail gets a search box.
Drive Select photos of one item and click Create item. Crossly reads the photos, suggests a title, price, brand, size and condition, and saves an unlisted item in your inventory for you to list.
Calendar See the next 7 days of your Crossly calendar: scheduled listings, drops, live shows, sales and deadlines. You can also schedule a listing to publish at a time you pick.
Docs Insert a listing's details (title, price, SKU, description and live marketplace links) or a sales summary table at the cursor.
Sheets Pull inventory, listings, orders or sales into tabs. Bulk-edit stock and prices in cells, then push only the changed rows back.

Every app has the same homepage: who you're signed in as, your last 30 days of sales, and a search across listings, orders and inventory. The ⋮ menu has Open Crossly, Settings and Sign out.

Contents

Sign-in

The add-on supports two sign-in methods.

  1. Sign in with Crossly (OAuth 2.0, preferred). This is the authorization code flow with PKCE (S256) against Crossly's authorization server, through Google's apps-script-oauth2 library (OAuth2, version 43). The endpoints come from https://crossly.net/.well-known/oauth-authorization-server:

    Authorize https://crossly.net/atlas/oauth2/authorize
    Token https://crossly.net/atlas/oauth2/token
    Revoke https://crossly.net/atlas/oauth2/revoke
    resource https://crossly.net/api/v1 (sent on the authorize and token requests)
    Scopes openid offline_access inventory:read inventory:write listings:read listings:write orders:read orders:write fulfillment:write inbox:read inbox:write sales:read analytics:read
    Redirect URI https://script.google.com/macros/d/{SCRIPT_ID}/usercallback

    The client id is read from the script property CROSSLY_OAUTH_CLIENT_ID. Set CROSSLY_OAUTH_CLIENT_SECRET only for a confidential client. With no client id set, the Sign in with Crossly button is hidden and only the token method below is offered. Access and refresh tokens are stored in the user's own UserProperties. Crossly rotates refresh tokens, and the library refreshes under a user lock. Sign out revokes the refresh token and deletes it.

  2. Personal Access Token (fallback). Paste a crossly_pat_… token from Crossly → Settings → API tokens. It is checked with GET /v1/me before it is saved to the user's UserProperties. The token is never written to a cell, document, card, log or document property, and Sign out deletes it.

Either way, credentials belong to the signed-in Google user and this script. Collaborators on a shared spreadsheet or document cannot read them.

OAuth client registration (one time, by a Crossly admin)

Create the client in Crossly under Settings → Developers → Apps → New (https://crossly.net/settings/developers/apps/new):

  • Name: Crossly for Google Workspace
  • Type: public client (PKCE, no secret). If you choose confidential instead, store the secret in the script property CROSSLY_OAUTH_CLIENT_SECRET, never in the repo.
  • Redirect URI: https://script.google.com/macros/d/{SCRIPT_ID}/usercallback, with the production script's ID. Add one per script, for example a dev copy too.
  • Grant types: authorization_code, refresh_token.
  • Scopes: the list in the table above. orders:write (buyer messages) may need Crossly's app review.
  • Then, in the Apps Script project: Project Settings → Script properties → CROSSLY_OAUTH_CLIENT_ID.

What it does in each app

Gmail

The contextual trigger runs when you open a message. The add-on reads that one message through the gmail.addons.current.message.readonly scope (GmailApp.setCurrentMessageAccessToken), and only the sender, subject and plain-text body. It never reads the rest of your mailbox.

src/detect.js matches the sender domain, including subdomains, against the marketplaces Crossly supports (eBay, Poshmark, Mercari, Depop, Etsy, Grailed, Vinted, Whatnot, Facebook Marketplace, Shopify, OfferUp, Vestiaire, Reverb, StockX, TikTok Shop, Walmart, Amazon, Bonanza, Discogs, Curtsy, TCGplayer and Crossly itself). A look-alike domain such as ebay.com.evil.io does not match. The subject decides what kind of email it is: offer, sale, shipping update or buyer message. The subject and body also supply the order number (eBay NN-NNNNN-NNNNN, Crossly NNN-NNNNNNN-NNNNNNN or a generic Order #…), the buyer's username, the amount and the item title.

Then the add-on looks the email up in Crossly:

  • If it found an order number, it calls GET /v1/orders?orderNumber=…, which matches a Crossly order number or the marketplace order id exactly.
  • Otherwise, and always for offers and messages, it calls GET /v1/search with the order:, buyer: and platform: operators.
Found Card actions
Order Open in Crossly, Add tracking (tracking number + carrier → marks shipped and notifies the marketplace), Message buyer
Marketplace conversation Reply, plus Accept / Counter / Decline when the conversation has an open offer
Crossly marketplace offer Accept / Counter / Decline
Listing Open in Crossly
Nothing The facts it read from the email, a note that imports can take a few minutes, and a prefilled search

A non-marketplace email shows a search box over listings, orders and inventory. There is no compose trigger: it would need another Gmail scope (gmail.addons.current.action.compose) for little gain.

Drive

There is a homepage, and an onItemsSelectedTrigger that runs when you select files.

  • The add-on only sees the metadata of the selected items (id, title, MIME type) through drive.addons.metadata.readonly.
  • For each JPEG, PNG, WebP or GIF photo it can't read yet, it shows an Allow button. The button calls requestFileScope(fileId), so Drive asks you to grant drive.file access to that one file. The add-on never sees other files.
  • Create item reads up to 8 granted photos (5 MB in total, under the API's 8 MB body limit after base64) with the Advanced Drive service, then:
    1. POST /v1/ai/magic-listing with the photos as data URLs, plus your brand and condition hints if you gave any. The response suggests a title, price, brand, size, colours, condition and description.
    2. POST /v1/inventory creates an unlisted inventory item from those suggestions: defaultTitle, originalPrice, brand, size, colour, condition, and the suggested description in notes.
    3. The card links to the item in Crossly, where you add the photos and list it.

Why an inventory item and not a listing draft? POST /v1/listings needs at least one platform and publishes at once, so there is no draft-only create. Why do the photos stay in Drive? The Crossly API has no photo-upload endpoint, and listing images are URLs. The add-on does not make Drive files public to work around this. See Missing API endpoints.

Calendar

There is a homepage card only. The add-on does not read your calendar events: reading an event's time needs a Calendar data scope that this card doesn't justify.

  • Next 7 days: GET /v1/calendar?from=&to= lists scheduled listings, drops, live shows, sales, events, rentals, workflow runs, vacation and tax deadlines, with conflicts flagged. Days follow your Calendar time zone (script.locale).
  • Schedule a listing: find a listing, pick a date and time, then POST /v1/listings/schedule { ids, verb: "publish", mode: "at", at }. Crossly publishes it at that time to the marketplaces already booked for it. If it can't be scheduled, the card shows Crossly's skipped reason.

Docs

The Docs homepage uses documents.currentonly, so the add-on can open only the document you are in.

  • Insert a listing: search, pick a listing, and GET /v1/listings/{id} supplies the content. The add-on inserts the title as a heading, a line with price · SKU · brand · size · condition, the description, and a bulleted list of the marketplaces it's live on, each linked. It goes after the paragraph your cursor is in, or at the end of the document.
  • Insert a sales summary: GET /v1/analytics/summary?days=7|30|90|365 inserts a table of orders, units sold, net sales, fees and net profit.

Sheets

The Sheets side panel uses spreadsheets.currentonly and does what the editor add-on menu always did, with the same code (crosslyPull_, crosslyPushStock_, crosslyPushPrices_ in src/main.js):

  • Pull inventory, listings, orders or sales into their own tab. Pull walks every page.
  • Bulk-edit: change quantityAvailable on the Inventory tab or price on the Listings tab. The editable column has a yellow header.
  • Push sends only the rows you changed. Stock goes out in one batched call per 5,000 items, and each price is one call per listing. Afterwards the tab is pulled again.
Tab Columns
Crossly Inventory id, sku, defaultTitle, brand, size, condition, status, quantity, quantityAvailable, quantityReserved, quantitySold, originalPrice, costBasisCents, warehouseLocation, updatedAt
Crossly Listings id, sku, title, price, currency, status, quantity, quantityAvailable, brand, size, condition, updatedAt
Crossly Orders id, platform, platformOrderId, status, channel, salePrice, platformFee, sku, quantity, buyerUsername, trackingNumber, carrier, shippedAt, deliveredAt, createdAt
Crossly Sales id, platform, platformOrderId, salePrice, platformFee, shippingCost, costOfGoods, netProfit, currency, detectedBy, detectedAt, orderId

Each pull also writes the editable column to a hidden tab (_crossly_snapshot_inventory or _crossly_snapshot_listings), keyed by id. A push compares the visible tab with that snapshot, so you can sort, filter or reorder columns first. Stock must be a whole number of 0 or more (the available stock; reserved units on open orders are kept). A price must be above 0 and is rounded to cents. An invalid cell is skipped and counted in the summary. Don't rename the id column or the editable column's header.

Scopes

These are the scopes in appsscript.json. Each one has a justification you can paste into the OAuth consent screen and the Marketplace SDK.

Scope Sensitivity Why
https://www.googleapis.com/auth/script.external_request — Calls the Crossly API and Crossly's OAuth token endpoint. urlFetchWhitelist limits it to https://crossly.net/.
https://www.googleapis.com/auth/script.locale Non-sensitive Shows Crossly calendar entries and scheduling times in the user's own time zone.
https://www.googleapis.com/auth/gmail.addons.execute Non-sensitive Required for any Gmail add-on to run its contextual trigger.
https://www.googleapis.com/auth/gmail.addons.current.message.readonly Sensitive Reads the sender, subject and body of the one message the user has open, to recognise marketplace sale, offer and buyer emails and find the matching Crossly order. It does not read any other mail and never stores or sends message content anywhere.
https://www.googleapis.com/auth/drive.addons.metadata.readonly Non-sensitive Sees the names and types of the files the user selects in Drive, to offer "Create item" for photos.
https://www.googleapis.com/auth/drive.file Non-sensitive Reads only the photos the user grants one by one (requestFileScope), to send them to Crossly's photo-to-listing AI.
https://www.googleapis.com/auth/calendar.addons.execute Non-sensitive Runs the Calendar homepage card, which shows the user's Crossly schedule. No calendar event data is read.
https://www.googleapis.com/auth/documents.currentonly Non-sensitive Inserts a listing or sales summary into the document the user has open, and no other document.
https://www.googleapis.com/auth/spreadsheets.currentonly Non-sensitive Pulls Crossly data into, and reads edits from, the spreadsheet the user has open, and no other spreadsheet.

The add-on deliberately does not request gmail.readonly, gmail.modify, compose scopes, drive, drive.readonly, calendar, calendar.readonly, documents, spreadsheets or script.container.ui. gmail.addons.current.message.readonly is the only sensitive scope. Because of it, Google will ask for a justification and a demo video (see Publishing). None of the scopes is restricted, so no CASA security assessment is needed.

API operations used

Every endpoint, parameter and field comes from the public OpenAPI spec (https://crossly.net/openapi/seller.json). The base URL is https://crossly.net/api and auth is Authorization: Bearer <OAuth access token | crossly_pat_…>.

Where Method Path operationId Crossly scope
Sign-in, homepage GET /v1/me getMe any
Homepage, Docs GET /v1/analytics/summary getAnalyticSummary analytics:read
Search, Gmail, Docs, Calendar GET /v1/search getSearch read scope per group
Gmail GET /v1/orders?orderNumber= listOrders orders:read
Gmail POST /v1/orders/{id}/tracking createOrderTracking fulfillment:write or orders:write
Gmail POST /v1/orders/{id}/message createOrderMessage orders:write
Gmail GET /v1/inbox/{id} getInbox inbox:read
Gmail POST /v1/inbox/{id}/reply createInboxReply inbox:write
Gmail POST /v1/inbox/{id}/offer createInboxOffer inbox:write
Gmail POST /v1/offers/{id}/respond createOfferRespond inbox:write
Drive POST /v1/ai/magic-listing createAiMagicListing listings:write
Drive POST /v1/inventory createInventory inventory:write
Calendar GET /v1/calendar listCalendar
Calendar POST /v1/listings/schedule createListingSchedule
Docs GET /v1/listings/{id} getListing listings:read
Sheets GET /v1/inventory, /v1/listings, /v1/orders, /v1/sales (?page=&limit=100) listInventory, listListings, listOrders, listSales *:read
Sheets POST /v1/inventory/bulk-quantity createInventoryBulkQuantity inventory:write
Sheets PATCH /v1/listings/{id} updateListing listings:write

Missing API endpoints

These features were cut down or left out because the API has no endpoint for them:

  • Photo upload. No endpoint accepts image bytes or returns an upload URL for listing or inventory photos (only videos have upload-urls). Without one, Drive can't attach photos to an item ("Add photos to listing"), and "Create item" leaves the photos in Drive.
  • Draft-only listing create. POST /v1/listings requires platforms (at least 1) and crossposts right away. Drive creates an inventory item instead.
  • Order lookup by buyer. GET /v1/orders has no buyer filter. The add-on uses GET /v1/search with buyer:.
  • Conversation lookup by marketplace thread or email id. There is no GET /v1/inbox?platformConversationId=, so offers and messages are found by GET /v1/search (buyer, item title, platform), which is fuzzy.
  • Scopes in the OpenAPI spec. Operations don't declare the scope they need. The scope column above comes from the API source and may be incomplete for /v1/search, /v1/calendar and /v1/listings/schedule.

Install and develop with clasp

You need Node 20+ and a Google account.

  1. Install clasp and log in: npm install -g @google/clasp, then clasp login. If you have never used the Apps Script API, enable it once at https://script.google.com/home/usersettings.
  2. Get the code: git clone https://github.com/crossly-dev/crossly-sheets.git, or download a release zip. Each zip carries a build-provenance attestation, which you can check with gh attestation verify crossly-sheets-v0.2.0.zip -R crossly-dev/crossly-sheets.
  3. Create a standalone Apps Script project (a Workspace add-on is not bound to a file):
    clasp create --type standalone --title "Crossly for Google Workspace" --rootDir .
    Or copy .clasp.json.example to .clasp.json and put an existing script ID in it.
  4. clasp push. .claspignore limits the push to appsscript.json and src/. The manifest pulls in the OAuth2 library and the Advanced Drive service by itself.
  5. Optional: set the script property CROSSLY_OAUTH_CLIENT_ID (see client registration). Without it, sign-in uses personal access tokens.
  6. In the Apps Script editor, go to Deploy → Test deployments → Install (Google Workspace add-on). Then reload Gmail, Drive, Calendar, Docs or Sheets and open the Crossly icon in the side panel.

Code layout

There is no build step. Every file runs unchanged in Apps Script, where all files share one global scope.

File What it holds Touches Apps Script globals?
src/core.js Pure logic: URLs, pagination, rows, edit detection, batching, backoff, error parsing, money, OAuth config, card-link rules, the Drive → inventory mapping No
src/detect.js Pure marketplace email detection (sender domain → platform, kind, order number, buyer, amount, title) and the search query No
src/main.js HTTP with retries (crosslyRequest_, crosslyCall_), token lookup, Sheets pull/push, the editor-add-on menu Only in crosslyEnv_()
src/auth.js OAuth2 service, the OAuth callback, auth state, sign-out OAuth2, CacheService, LockService, HtmlService
src/cards.js Every CardService card and callback for Gmail, Drive, Calendar, Docs and Sheets CardService, GmailApp, DocumentApp, Drive, Utilities

The tests use only Node built-ins (node:test, node:assert, node:vm). test/harness.js loads every src file into a vm context with in-memory fakes of SpreadsheetApp, UrlFetchApp, PropertiesService, Utilities, GmailApp and a recording CardService. It then drives the real triggers and callbacks.

npm install
npm run check    # node --check every src file
npm run lint
npm test
npm run bundle   # dist/crossly-sheets-<version>.zip

Continuous deployment (optional)

Every release on a v* tag lints, tests, zips the clasp project, attests the zip's build provenance and attaches it to a GitHub Release. To also clasp push into a real Apps Script project, set the repository variable CLASP_PUSH=true and add two secrets:

  • CLASPRC_JSON: the contents of ~/.clasprc.json from an account that can edit the script.
  • SCRIPT_ID: the script to push to.

The release job does not create a deployment or touch the Marketplace listing.

Editor add-on vs Workspace add-on

This project ships as a Google Workspace add-on, the card-based kind with an addOns section in the manifest. It is not also published as an editor add-on, for these reasons:

  • The Marketplace takes them differently. The Marketplace SDK publishes a Google Workspace add-on by its deployment ID, and an editor add-on by script ID plus version number. Google's docs say only that "some" integrations can be combined in one listing, and never document one Apps Script project as both kinds. A single listing for Gmail, Drive, Calendar, Docs and Sheets has to be a Workspace add-on.
  • Menus don't run in a Workspace add-on. An installed Workspace add-on gets no onOpen simple trigger, so createAddonMenu() menus never appear. The Sheets side panel card replaces the menu feature for feature.
  • Scopes stay minimal. The menu and its prompt dialog need script.container.ui, which the card add-on never uses. Keeping it in the manifest would add an unused scope to the Google review.

The editor menu code still works. onOpen, onInstall and the crossly* menu functions are still in src/main.js and share the pull/push code with the card. To run the old Extensions → Crossly menu bound to a single spreadsheet (self-hosting, or debugging the Sheets logic), push the editor manifest variant into a spreadsheet-bound script:

npm run manifest:editor      # copies manifests/editor-addon.appsscript.json over appsscript.json
clasp push                   # into a script made with: clasp create --type sheets --title "Crossly" --rootDir .
git checkout appsscript.json # back to the Workspace add-on manifest

The editor variant has the original three scopes (spreadsheets.currentonly, script.external_request and script.container.ui) and no addOns section. It signs in with a personal access token through Set API token….

Publishing to the Google Workspace Marketplace

Publishing happens in Google's consoles, once per listing. The store copy and screenshot plan are in MARKETPLACE.md.

1. Google Cloud project

  • Create a standard GCP project, for example crossly-workspace-addon, owned by the Crossly Google Workspace or Cloud organization rather than a personal account.
  • In Apps Script, go to Project Settings → Google Cloud Platform (GCP) Project → Change project and enter that project's number.
  • In the GCP project, enable the Google Workspace Marketplace SDK and the Google Drive API. The Drive API is what the Advanced Drive service (Drive, v3) calls.

2. OAuth consent screen and brand verification

  • Google Auth Platform → Branding: app name Crossly, user support email, logo (120×120 PNG of the Crossly mark), app home page https://crossly.net, privacy policy https://crossly.net/privacy, terms https://crossly.net/terms, authorized domain crossly.net, and developer contact.
  • Audience: External, in production. Not Testing, because Testing users are capped at 100 and their tokens expire after 7 days.
  • Data access: add exactly the nine scopes from Scopes, each with its one-line justification.
  • Verify the domain crossly.net in Google Search Console with the same Google account that owns the project.
  • Submit brand verification, which covers the name, logo and domain, and sensitive scope verification for gmail.addons.current.message.readonly. Both are reviewed together. They need:
    • the privacy policy to say what Gmail data is read (sender, subject and body of the open message), that it is used only to find the matching Crossly record and is not stored, and that it is not used for ads; plus the Google API Services User Data Policy "Limited Use" disclosure,
    • a demo video (unlisted YouTube link, see below),
    • a written justification for each sensitive scope (use the table above).

3. Demo video for the Gmail scope

Google wants one unlisted YouTube video, 2 to 4 minutes long, in English or with English captions, that shows:

  1. The OAuth consent screen with the app name and the full scope list visible, with the browser URL bar showing the client_id. Install from a test deployment, or from the Marketplace listing once it is private.
  2. Gmail: opening an eBay or Poshmark sale email, the Crossly card with the matching order, then Add tracking from start to finish. The video should say that only the open message is read.
  3. Gmail: an offer email, then Counter.
  4. Gmail: a non-marketplace email, which only shows the search box (so no mail is read for anything else).
  5. Brief shots of Drive (Allow for one photo, then Create item), Calendar, Docs and Sheets, so every requested scope is shown in use.
  6. Sign out from the ⋮ menu.

4. Deployment

  • clasp push, then clasp version "v0.2.0" and clasp deploy --versionNumber <n> --description "v0.2.0". Or in the editor, go to Deploy → New deployment → Add-on.
  • Copy the Deployment ID (AKfycb…), not the version number. Workspace add-ons are published by deployment ID.
  • Each release after that: create a new version and edit the same deployment to point at it (clasp deploy -i <deploymentId> -V <n>). The Marketplace picks it up with no new review unless the scopes change.

5. Marketplace SDK → App configuration

  • App visibility: Public. Once saved, this can't be changed.
  • Installation settings: individual + admin install.
  • App integration: select Google Workspace add-on, then Deploy using Apps Script deployment ID and paste the deployment ID. Do not select an editor add-on, which would ask for a script ID and version.
  • OAuth scopes: the same nine scopes, exactly as in appsscript.json.
  • Developer information: developer name Crossly, website https://crossly.net, email, and trader status (EU DSA), with a business address if trader.

6. Marketplace SDK → Store listing

Copy everything here from MARKETPLACE.md.

  • App name, short description (200 characters at most), detailed description, category, and the Gmail / Drive / Calendar / Docs / Sheets "works with" flags.
  • Graphics: app icon at 128×128 and 32×32 (PNG, square, transparent or solid background), and a card banner at 220×140. The current https://crossly.net/icon-192.png and icon-512.png can be scaled down for the icons. The banner has to be made.
  • Screenshots: at least 1 and up to 5, 1280×800 PNG/JPEG (the five-shot plan is in MARKETPLACE.md). Optionally, a promo video (YouTube).
  • Support links: terms https://crossly.net/terms, privacy https://crossly.net/privacy, support https://crossly.net/docs (or the help center), and a "post-install / setup" URL such as https://crossly.net/docs/api-quickstart.
  • Publish. Review takes several days. Google re-checks the OAuth verification and tries the add-on with a demo account, so put the login for a demo Crossly account with sample orders and offers in the reviewer notes.

7. Before you submit

  • Install the test deployment for a non-developer Google account and open each host app.
  • Sign in with Crossly (OAuth), sign out, then sign in with a personal access token.
  • Check that the OAuth client's redirect URI uses the production script ID.
  • Check appsscript.json: urlFetchWhitelist is ["https://crossly.net/"], and logoUrl is a PNG.

Rate limits

Crossly counts requests per minute for each token. Reads get 1,200 a minute. Writes depend on your plan: Free 15, Starter 60, Pro 240, Business 1,000, Scale 2,000 (see Rate limits). Every call from every app goes through one function, which:

  • reads X-Quota-Remaining after every response and waits X-Quota-Reset seconds when it reaches 0,
  • retries a 429 after Retry-After seconds, up to 5 attempts, but does not retry a 429 retry_storm,
  • retries 502/503/504 with exponential backoff,
  • shows the API's error.message, error.code and correlationId (quote the correlationId to support).

An Apps Script run stops after 6 minutes, and a card callback after 30 seconds. A long Sheets push from the side panel may stop part-way. The rows that didn't go out still differ from the snapshot, so push again to finish.

Related

Links

License

MIT

About

Crossly add-on for Google Sheets: pull inventory, listings, orders and sales into a sheet, bulk-edit stock and prices, and push them back to eBay, Poshmark, Mercari and more. Apps Script + clasp.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages