External APIs Overview¶
Workbench AI integrates with several third-party services. This page documents which APIs are used, what for, and where they are wired, without exposing any sensitive keys.
All secrets (API keys, webhook secrets, service role keys) are configured via environment variables and must never be committed to git. Use only placeholders like
YOUR_STRIPE_SECRET_KEYin documentation.
Stripe¶
Stripe is used for subscription billing, customer billing portal, and historical invoice data. It is not used for per-invoice card processing inside Workbench itself (Greyhaven Payments is used there).
Usage areas¶
-
Subscriptions (SaaS billing)
- Creating subscriptions via Checkout.
- Managing subscriptions via Billing Portal.
- Reactivating/correcting subscriptions.
- Webhooks for subscription lifecycle events.
-
Invoices & payment history (SaaS side)
- Fetching historical Stripe invoices.
- Mirroring invoice/payment events into Supabase (
payment_history).
API surfaces¶
Stripe Checkout¶
Used by:
create-checkout-sessionedge functionupgrade-checkout-sessionedge function (indirectly via subscription updates)reactivate-subscriptionedge function
Key behavior:
stripe.checkout.sessions.create({ ... })with:mode: 'subscription'customer: <stripe_customer_id>line_items: [{ price: <PRICE_ID>, quantity: 1 }]- Metadata:
company_id,plan_name,source,feature,user_id,referral. - Hosted URLs for
success_urlandcancel_url.
Config (env vars, placeholders only):
STRIPE_SECRET_KEY="YOUR_STRIPE_SECRET_KEY"STRIPE_STARTER_PRICE_ID="price_XXX_STARTER"STRIPE_PROFESSIONAL_PRICE_ID="price_XXX_PROFESSIONAL"
Billing Portal¶
Used by:
create-portal-sessionedge function
Key behavior:
stripe.billingPortal.sessions.create({ customer, return_url }).- Customer ID is resolved from
subscriptionsor fetched via Stripe.
Subscriptions¶
Used by:
get-stripe-subscriptionedge functionsync-stripe-subscriptionsedge functionreactivate-subscription,upgrade-checkout-session
Key behavior:
stripe.subscriptions.retrieve(<subscription_id>)to get:- Status (
trialing,active,past_due, etc.). - Items and recurring price (amount, interval).
- Trial dates (
trial_start,trial_end). - Current period start/end.
- Status (
Invoices¶
Used by:
get-upcoming-invoiceedge functionget-customer-invoicesedge functionsync-payment-historyedge function
Key behavior:
stripe.invoices.retrieveUpcoming({ customer, subscription })for upcoming charges.stripe.invoices.list({ customer, status })for historical invoices.
Webhooks¶
Used by:
stripe-webhookedge function
Key behavior:
- Receives events like:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeeded
- Verified via:
Config (env vars):
STRIPE_WEBHOOK_SECRET="whsec_..."(per environment)
Stripe configuration
Actual product/price, webhook endpoint configuration, and Dashboard settings are maintained in Stripe itself. This doc only describes usage patterns; see internal ops docs for deployment-specific configuration.
AI providers¶
Workbench AI uses an external AI provider for image generation in the Nameplate Studio. The implementation is intentionally abstracted to avoid locking in a specific vendor in docs.
Nameplate generation¶
Used by:
generate-nameplateedge function- Library & design flows (to display generated assets)
Key behavior:
- Edge function constructs a prompt for a jewelry nameplate design.
- Calls an external image API (e.g. DALL·E / compatible service) with that prompt.
- Receives image bytes/URL, stores the image in Supabase Storage (
nameplatesbucket). - Inserts a row into
nameplateswith metadata and usage tracking. - Tracks monthly usage per user via
nameplate_usage.
Config (env vars, placeholders):
OPENAI_API_KEY="YOUR_IMAGE_API_KEY"
Abstraction
The implementation references a specific provider in code today, but you can swap it out for any compatible image API by:
- Updating the HTTP call in
generate-nameplate. - Keeping the
nameplatesschema and storage behavior compatible.
Email / notifications (future)¶
As of this documentation pass, outbound notifications (email/SMS) are not yet fully wired into an external transactional email API inside this repo snapshot. When that changes, document:
- Which provider is used (e.g. SendGrid, Postmark, SES).
- Which flows send emails (invoices, pay links, affiliate notifications).
- How unsubscribe / compliance is handled.
Placeholder env vars for future email integration:
EMAIL_PROVIDER_API_KEY="YOUR_EMAIL_API_KEY"EMAIL_FROM_ADDRESS="no-reply@your-domain.com"
Greyhaven Payments (conceptual)¶
The Payments section in the app refers merchant users to Greyhaven Payments for invoice and pay-link processing. The actual card processing gateway is external and not fully configured in this repo.
What’s modeled in this codebase:
invoicesandinvoice_line_itemstables (internal representation of invoices).pay_linksandpay_link_line_itemstables (internal representation of payment links).- Temporary
link_urlvalues for pay links are generated inPayLinkCreation(e.g.https://payments.greyhavengroup.com/pay/<code>). gateway_payment_idandgateway_link_idfields are reserved for future integration.
What is not in this repo:
- Actual Greyhaven Payments API client.
- Webhooks from Greyhaven informing
pay_linksorordersof payment success.
Production integration
When integrating Greyhaven’s API, ensure:
- All callbacks verify signatures or shared secrets.
- Payment status updates (
paid,failed,refunded) are mirrored intopay_links,orders, and any reporting tables. - No raw card data ever touches Workbench AI servers.
Other integrations¶
Supabase¶
While not an "external API" in the same sense, the SPA uses the Supabase JavaScript client to talk to Postgres, Auth, and Storage:
@supabase/supabase-jsinitialized with:VITE_SUPABASE_URL/NEXT_PUBLIC_SUPABASE_URLVITE_SUPABASE_ANON_KEY/NEXT_PUBLIC_SUPABASE_ANON_KEY
Usage patterns:
supabase.from('table').select(/* ... */)for data.supabase.auth.signInWithPassword(...),supabase.auth.getSession()for auth.supabase.storage.from('bucket').upload(...),getPublicUrl(...)for files.
Config (placeholders):
VITE_SUPABASE_URL="https://YOUR_PROJECT.supabase.co"VITE_SUPABASE_ANON_KEY="YOUR_SUPABASE_ANON_KEY"
See:
Security & configuration summary¶
- All third-party API keys and secrets are supplied via env vars.
- Never log full keys; log the presence/absence only, or masked prefixes when debugging.
- For multi-environment setups:
- Keep variable names consistent across dev/stage/prod.
- Change only the values.
Quick checklist when adding a new external API:
- Define placeholder env vars (e.g.
THIRD_PARTY_API_KEY). - Store secrets in the appropriate configuration (Supabase project, hosting platform, or secret manager).
- Add a short entry to this page under a new section.
- Ensure edge functions or backend code handle:
- Network timeouts and retries.
- Rate limiting / backoff.
- Clear error messages for the frontend.