This commit is contained in:
greeneclipse committed 2026-10-16 00:34:06 +02:00
1 parent 6586722652
commit 1e7c7bbfbb
65 files changed
+1345 -640

No files matched your search

@@ -0,0 +1,51 @@
package httpapi
import (
"encoding/csv"
"net/http"
"strconv"
"strings"
"github.com/google/uuid"
)
// Exports audited AI usage by company. This is an operational cost report, NOT
// a customer invoice or the amount charged by Stripe.
func (s *Server) handleAdminExportAICosts(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
from, to, err := adminCostRange(q.Get("from"), q.Get("to"), q.Get("days"))
if err != nil {
Error(w, http.StatusBadRequest, err.Error())
return
}
args := []any{from, to}
where := "day >= $1 AND day <= $2"
if raw := strings.TrimSpace(q.Get("company_id")); raw != "" {
cid, err := uuid.Parse(raw)
if err != nil {
Error(w, http.StatusBadRequest, "invalid company_id")
return
}
args = append(args, cid)
where += " AND company_id = $3"
}
result, err := s.scanCostGroup(r.Context(), costGroupCompany, where, args)
if err != nil {
LogAndError(w, http.StatusInternalServerError, "could not export AI costs", err)
return
}
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
w.Header().Set("Content-Disposition", `attachment; filename="descrybe-ai-usage-costs.csv"`)
w.Header().Set("Cache-Control", "private, no-store")
out := csv.NewWriter(w)
_ = out.Write([]string{"from", "to", "company_id", "company", "calls", "failed_calls", "input_tokens", "cached_input_tokens", "output_tokens", "total_tokens", "provider_cost_usd", "notice"})
v := func(row map[string]any, key string) string { return strconv.FormatInt(int64(row[key].(int64)), 10) }
for _, row := range result {
cost := float64(row["cost_micros"].(int64)) / 1000000.0
_ = out.Write([]string{from.Format("2006-01-02"), to.Format("2006-01-02"), row["id"].(string), row["label"].(string),
v(row, "calls"), v(row, "failed_calls"), v(row, "prompt_tokens"), v(row, "cached_prompt_tokens"),
v(row, "completion_tokens"), v(row, "total_tokens"), strconv.FormatFloat(cost, 'f', 6, 64),
"Provider operating cost in USD; NOT client revenue, Stripe invoice, or payable total"})
}
out.Flush()
}
@@ -172,7 +172,7 @@ func (s *Server) scanCostGroup(ctx context.Context, group costGroup, whereSQL st
COALESCE(sum(u.cost_micros),0)
FROM ai_usage_daily u
LEFT JOIN companies c ON c.id = u.company_id
WHERE ` + whereSQL + `
WHERE ` + strings.ReplaceAll(whereSQL, "company_id =", "u.company_id =") + `
GROUP BY u.company_id, c.name
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
@@ -186,7 +186,7 @@ func (s *Server) scanCostGroup(ctx context.Context, group costGroup, whereSQL st
FROM ai_usage_daily u
LEFT JOIN users usr ON usr.id = u.user_id
LEFT JOIN companies c ON c.id = u.company_id
WHERE ` + whereSQL + `
WHERE ` + strings.ReplaceAll(whereSQL, "company_id =", "u.company_id =") + `
GROUP BY u.user_id, usr.email, u.company_id, c.name
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
@@ -198,7 +198,7 @@ func (s *Server) scanCostGroup(ctx context.Context, group costGroup, whereSQL st
COALESCE(sum(u.completion_tokens),0), COALESCE(sum(u.total_tokens),0),
COALESCE(sum(u.cost_micros),0)
FROM ai_usage_daily u
WHERE ` + whereSQL + `
WHERE ` + strings.ReplaceAll(whereSQL, "company_id =", "u.company_id =") + `
GROUP BY u.model
ORDER BY COALESCE(sum(u.cost_micros),0) DESC
LIMIT ` + strconv.Itoa(adminAICostsMaxRows)
@@ -151,13 +151,16 @@ func (s *Server) handleAdminAnalytics(w http.ResponseWriter, r *http.Request) {
tokenByDay := map[string]adminDayPoint{}
tokRows, err := s.Pool.Query(ctx, `
SELECT (created_at AT TIME ZONE 'UTC')::date AS d,
COALESCE(SUM(COALESCE(total_tokens, 0)), 0)::bigint,
COUNT(*)::bigint
FROM processed_products
WHERE created_at >= $1
GROUP BY 1
ORDER BY 1`, since)
WITH tokens AS (
SELECT day AS d, COALESCE(SUM(total_tokens),0)::bigint AS tok
FROM ai_usage_daily WHERE day >= $1::date GROUP BY 1
), products AS (
SELECT (created_at AT TIME ZONE 'UTC')::date AS d, COUNT(*)::bigint AS cnt
FROM processed_products WHERE created_at >= $1 GROUP BY 1
)
SELECT COALESCE(t.d,p.d) AS d, COALESCE(t.tok,0)::bigint, COALESCE(p.cnt,0)::bigint
FROM tokens t FULL OUTER JOIN products p ON t.d=p.d
ORDER BY 1`, since)
if err != nil {
Error(w, http.StatusInternalServerError, "analytics token series failed")
return
@@ -326,7 +329,7 @@ func (s *Server) handleAdminAnalytics(w http.ResponseWriter, r *http.Request) {
"providers": providers,
"tokens_by_provider_detail": providerDetail,
"notes": []string{
"Tokens come from processed_products.total_tokens (LLM usage recorded per product).",
"Tokens come from the durable ai_usage_daily call ledger (input + output), including multiple calls per product.",
"Provider classes use processed_products.ai_provider_mode: internal | popular:<name> | custom (blank/unknown rolled into the internal card).",
"Job tokens use processing_jobs.estimated_tokens (running tally during jobs).",
"Jobs stuck = status running with updated_at older than 2 hours (same threshold as diagnostics).",
@@ -353,12 +356,12 @@ func (s *Server) loadAdminAnalyticsSummary(ctx context.Context, since time.Time)
(SELECT COUNT(*)::bigint FROM companies WHERE created_at >= $1),
(SELECT COALESCE(SUM(total_credits), 0)::bigint FROM credit_balances),
(SELECT COALESCE(SUM(used_credits), 0)::bigint FROM credit_balances),
(SELECT COALESCE(SUM(COALESCE(total_tokens, 0)), 0)::bigint FROM processed_products),
(SELECT COALESCE(SUM(total_tokens), 0)::bigint FROM ai_usage_daily),
(SELECT COUNT(*)::bigint FROM processed_products),
(SELECT COUNT(*)::bigint FROM raw_products),
(SELECT COUNT(*)::bigint FROM input_feeds),
(SELECT COUNT(*)::bigint FROM export_feeds),
(SELECT COALESCE(SUM(COALESCE(total_tokens, 0)), 0)::bigint FROM processed_products WHERE created_at >= $1),
(SELECT COALESCE(SUM(total_tokens), 0)::bigint FROM ai_usage_daily WHERE day >= $1::date),
(SELECT COUNT(*)::bigint FROM processing_jobs WHERE created_at >= $1 AND status = 'failed'),
(SELECT COUNT(*)::bigint FROM processing_jobs WHERE created_at >= $1 AND status = 'completed'),
(SELECT COUNT(*)::bigint FROM processing_jobs
@@ -0,0 +1,37 @@
package httpapi
import (
"encoding/csv"
"net/http"
"strconv"
"strings"
"github.com/google/uuid"
)
// Platform-admin export of actual Stripe invoice amounts (not estimated usage).
// Scope must be a single company; customer IDs are resolved server-side.
func (s *Server) handleAdminExportCompanyInvoices(w http.ResponseWriter, r *http.Request) {
id, err := uuid.Parse(strings.TrimSpace(r.URL.Query().Get("company_id")))
if err != nil {
Error(w, http.StatusBadRequest, "company_id is required")
return
}
rows, err := s.stripeSvc().ListCompanyInvoices(r.Context(), id)
if err != nil {
LogAndError(w, http.StatusBadGateway, "could not export Stripe invoices", err)
return
}
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
w.Header().Set("Content-Disposition", `attachment; filename="descrybe-stripe-invoices.csv"`)
w.Header().Set("Cache-Control", "private, no-store")
out := csv.NewWriter(w)
_ = out.Write([]string{"company_id", "invoice_id", "number", "status", "currency", "created_unix", "amount_due_minor", "amount_paid_minor", "amount_remaining_minor", "hosted_invoice_url", "invoice_pdf"})
for _, row := range rows {
_ = out.Write([]string{id.String(), row.ID, row.Number, row.Status, row.Currency,
strconv.FormatInt(row.Created, 10), strconv.FormatInt(row.AmountDue, 10),
strconv.FormatInt(row.AmountPaid, 10), strconv.FormatInt(row.AmountRemaining, 10),
row.HostedInvoiceURL, row.InvoicePDF})
}
out.Flush()
}
@@ -0,0 +1,103 @@
package httpapi
import (
"net/http"
"strconv"
"strings"
"github.com/google/uuid"
)
var editableCostFeatures = map[string]bool{
"product_processing": true,
"openai_token_k": true,
"seo_meta_ai": true,
"campaign_copy": true,
}
func (s *Server) handleAdminGetProcessingCosts(w http.ResponseWriter, r *http.Request) {
rows, err := s.Pool.Query(r.Context(), `
SELECT 'default', '', feature_name, cost_per_unit FROM processing_costs WHERE is_active = true
UNION ALL
SELECT 'plan', plan_id::text, feature_name, cost_per_unit FROM plan_processing_costs
UNION ALL
SELECT 'company', company_id::text, feature_name, cost_per_unit FROM company_processing_costs
ORDER BY 1, 2, 3`)
if err != nil {
LogAndError(w, http.StatusInternalServerError, "could not load processing costs", err)
return
}
defer rows.Close()
out := make([]map[string]any, 0, 16)
for rows.Next() {
var scope, id, feature string
var cost int
if err := rows.Scan(&scope, &id, &feature, &cost); err != nil {
LogAndError(w, http.StatusInternalServerError, "could not scan processing costs", err)
return
}
out = append(out, map[string]any{"scope": scope, "id": id, "feature": feature, "cost_per_unit": cost})
}
if err := rows.Err(); err != nil {
LogAndError(w, http.StatusInternalServerError, "could not read processing costs", err)
return
}
w.Header().Set("Cache-Control", "private, no-store")
JSON(w, http.StatusOK, map[string]any{"rules": out, "notes": "Company overrides take priority over plan rules. Changes affect future debits only."})
}
func (s *Server) handleAdminPutProcessingCost(w http.ResponseWriter, r *http.Request) {
var body struct {
Scope string `json:"scope"`
ID string `json:"id"`
Feature string `json:"feature"`
Cost *int `json:"cost_per_unit"` // null removes an override; cannot remove global rule
}
if err := DecodeJSON(r, &body); err != nil {
Error(w, http.StatusBadRequest, "invalid json")
return
}
body.Scope = strings.TrimSpace(strings.ToLower(body.Scope))
body.Feature = strings.TrimSpace(body.Feature)
if !editableCostFeatures[body.Feature] || (body.Cost != nil && (*body.Cost < 1 || *body.Cost > 1000000)) {
Error(w, http.StatusBadRequest, "invalid feature or credit cost")
return
}
ctx := r.Context()
var err error
switch body.Scope {
case "company":
id, parseErr := uuid.Parse(body.ID)
if parseErr != nil {
Error(w, http.StatusBadRequest, "invalid company id")
return
}
if body.Cost == nil {
_, err = s.Pool.Exec(ctx, `DELETE FROM company_processing_costs WHERE company_id = $1 AND feature_name = $2`, id, body.Feature)
} else {
_, err = s.Pool.Exec(ctx, `INSERT INTO company_processing_costs (company_id,feature_name,cost_per_unit) VALUES ($1,$2,$3)
ON CONFLICT(company_id,feature_name) DO UPDATE SET cost_per_unit=EXCLUDED.cost_per_unit,updated_at=now()`, id, body.Feature, *body.Cost)
}
case "plan":
id, parseErr := strconv.ParseInt(body.ID, 10, 64)
if parseErr != nil || id <= 0 {
Error(w, http.StatusBadRequest, "invalid plan id")
return
}
if body.Cost == nil {
_, err = s.Pool.Exec(ctx, `DELETE FROM plan_processing_costs WHERE plan_id = $1 AND feature_name = $2`, id, body.Feature)
} else {
_, err = s.Pool.Exec(ctx, `INSERT INTO plan_processing_costs (plan_id,feature_name,cost_per_unit) VALUES ($1,$2,$3)
ON CONFLICT(plan_id,feature_name) DO UPDATE SET cost_per_unit=EXCLUDED.cost_per_unit,updated_at=now()`, id, body.Feature, *body.Cost)
}
default:
Error(w, http.StatusBadRequest, "scope must be company or plan")
return
}
if err != nil {
LogAndError(w, http.StatusBadRequest, "could not save processing cost", err)
return
}
w.Header().Set("Cache-Control", "private, no-store")
JSON(w, http.StatusOK, map[string]any{"status": "ok"})
}
@@ -57,12 +57,12 @@ func (s *Server) handleAdminSyncStripeCreditPacks(w http.ResponseWriter, r *http
return
}
written = append(written, map[string]any{
"pack_id": row.PackID,
"product_id": row.ProductID,
"price_id": row.PriceID,
"credits": row.Credits,
"price_usd": row.PriceUSD,
"created": row.Created,
"pack_id": row.PackID,
"product_id": row.ProductID,
"price_id": row.PriceID,
"credits": row.Credits,
"price_eur": row.PriceEUR,
"created": row.Created,
"settings_key": key,
})
}
@@ -155,3 +155,19 @@ func (s *Server) handleRunBillingCycles(w http.ResponseWriter, r *http.Request)
}
JSON(w, http.StatusOK, out)
}
// handleListBillingInvoices lists genuine Stripe invoices for the active company.
// Private Stripe payment and PDF links are only accessible to company owners.
func (s *Server) handleListBillingInvoices(w http.ResponseWriter, r *http.Request) {
if !s.allowCompanyOwnerOrPlatform(w, r) {
return
}
cid, _ := CompanyIDFromContext(r.Context())
invoices, err := s.stripeSvc().ListCompanyInvoices(r.Context(), cid)
if err != nil {
LogAndError(w, http.StatusBadGateway, "could not load invoices", err)
return
}
w.Header().Set("Cache-Control", "private, no-store")
JSON(w, http.StatusOK, map[string]any{"invoices": invoices, "source": "stripe"})
}
@@ -0,0 +1,45 @@
package httpapi
import (
"encoding/csv"
"net/http"
"strconv"
"github.com/google/uuid"
)
// Usage statements are informational exports, not tax invoices or payment records.
func (s *Server) handleBillingUsageExport(w http.ResponseWriter, r *http.Request) {
cid, _ := CompanyIDFromContext(r.Context())
if cid == uuid.Nil {
Error(w, http.StatusUnauthorized, "company required")
return
}
usage, err := s.Billing.UsageSummary(r.Context(), cid, r.URL.Query().Get("range"))
if err != nil {
LogAndError(w, http.StatusInternalServerError, "could not export usage", err)
return
}
w.Header().Set("Content-Type", "text/csv; charset=utf-8")
w.Header().Set("Content-Disposition", `attachment; filename="descrybe-usage.csv"`)
w.Header().Set("Cache-Control", "private, no-store")
out := csv.NewWriter(w)
_ = out.Write([]string{"company_id", "range", "metric", "value", "notes"})
rows := []struct {
label string
value int64
notes string
}{
{"ai_calls", usage.AICalls, "Recorded provider calls in period"},
{"input_tokens", usage.InputTokens, "Includes cached input"},
{"cached_input_tokens", usage.CachedInputTokens, "Subset of input"},
{"output_tokens", usage.OutputTokens, ""},
{"products_processed", int64(usage.ProductsProcessed), "Period"},
{"credits_used_wallet", int64(usage.CreditsUsed), "All-time wallet balance, not period credits"},
{"credits_remaining", int64(usage.CreditsRemaining), "Current wallet"},
}
for _, v := range rows {
_ = out.Write([]string{cid.String(), usage.Range, v.label, strconv.FormatInt(v.value, 10), v.notes})
}
out.Flush()
}
+8 -1
View File
@@ -403,7 +403,14 @@ func (s *Server) handleSyncAndProcessSample(w http.ResponseWriter, r *http.Reque
return
}
procJobs, err := s.Processing.StartJob(r.Context(), cid, uid, rawIDs, processingType)
// Public API feed sample processing is API-origin too. The session-based
// feed preview keeps the review workflow used by the dashboard.
var procJobs []processing.Job
if strings.HasPrefix(r.URL.Path, "/api/v1/") {
procJobs, err = s.Processing.StartAPIJob(r.Context(), cid, uid, rawIDs, processingType)
} else {
procJobs, err = s.Processing.StartJob(r.Context(), cid, uid, rawIDs, processingType)
}
if err != nil {
ClientOrLog(w, http.StatusBadRequest, "could not start processing", err, processing.ClientError)
return
@@ -43,6 +43,7 @@ var apiFeatureRoutes = map[string]string{
"/api/billing/checkout": "billing.checkout",
"/api/billing/portal": "billing.customer_portal",
"/api/billing/usage": "billing.overview",
"/api/billing/invoices": "billing.overview",
"/api/billing/plans": "billing.plans_compare",
"/api/billing/credit-packs": "billing.overview",
"/api/billing/stripe": "billing.overview",
@@ -3,6 +3,7 @@ package httpapi
import (
"errors"
"net/http"
"strings"
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
"github.com/descrybe/descrybe-v2/apps/api/internal/processing"
@@ -40,7 +41,15 @@ func (s *Server) handleStartProcessingJob(w http.ResponseWriter, r *http.Request
}
ids = append(ids, id)
}
jobs, err := s.Processing.StartJob(r.Context(), cid, uid, ids, body.ProcessingType)
// The shared handler serves session dashboard jobs and /api/v1/process.
// Public API results should be directly visible in the Processed catalog tab.
var jobs []processing.Job
var err error
if strings.HasPrefix(r.URL.Path, "/api/v1/") {
jobs, err = s.Processing.StartAPIJob(r.Context(), cid, uid, ids, body.ProcessingType)
} else {
jobs, err = s.Processing.StartJob(r.Context(), cid, uid, ids, body.ProcessingType)
}
if err != nil {
if writePlanGate(w, err) {
return
+6
View File
@@ -407,6 +407,10 @@ func (s *Server) Router() http.Handler {
r.Get("/diagnostics", s.handleAdminDiagnostics)
r.Get("/ai-calls", s.handleAdminListAICalls)
r.Get("/ai-costs", s.handleAdminAICosts)
r.Get("/ai-costs/export", s.handleAdminExportAICosts)
r.Get("/billing/invoices/export", s.handleAdminExportCompanyInvoices)
r.Get("/processing-costs", s.handleAdminGetProcessingCosts)
r.Put("/processing-costs", s.handleAdminPutProcessingCost)
r.Get("/ai-calls/{id}", s.handleAdminGetAICall)
r.Get("/analytics", s.handleAdminAnalytics)
r.Get("/jobs", s.handleAdminListJobs)
@@ -476,6 +480,8 @@ func (s *Server) Router() http.Handler {
r.Get("/billing/credits", s.handleCreditsOverview)
r.Get("/billing/capabilities", s.handleGetCapabilities)
r.Get("/billing/usage", s.handleBillingUsage)
r.Get("/billing/usage/export", s.handleBillingUsageExport)
r.Get("/billing/invoices", s.handleListBillingInvoices)
r.Get("/billing/plans", s.handleListPublicPlans)
r.Get("/billing/credit-packs", s.handleListCreditPacks)
r.Get("/billing/stripe", s.handleStripeStatus)
+76 -408
View File
@@ -18,12 +18,9 @@ info:
## Authentication
Public /api/v1 operations require a company API key (Bearer or X-API-Key)
except GET /health and GET /openapi.yaml. Dashboard-only Team/Admin
operations described separately use a signed-in session and CSRF header;
they are not executable with a company API key.
except GET /health and GET /openapi.yaml.
Document-level security is BearerAuth OR ApiKeyAuth (same key value).
Do not send dashboard session cookies or CSRF tokens to /api/v1.
### Security schemes (components.securitySchemes)
@@ -38,10 +35,8 @@ info:
1. Sign in at https://api.descrybe.io
2. Open Settings -> API keys (/settings?tab=api-keys)
3. Company admins or teammates granted API Keys management permission create
a key via dashboard POST /api/api-keys
(session cookie + CSRF; not this public OpenAPI surface). The secret is
shown once and starts with dk_.
3. Authorized users can create keys in Settings -> API keys. The secret is
shown once and starts with dk_.
4. Store it securely. Later list/revoke shows only key_prefix (first 10
characters). Revoked keys fail auth immediately.
@@ -64,22 +59,19 @@ info:
### 403 Forbidden
Bad API keys on /api/v1 never return 403 (always 401). Tenant scope comes
from the key; cross-company resources typically 404. HTTP 403 appears on
dashboard /api/* session routes (admin required, CSRF mismatch) under
Team/Admin tags (SessionCookie + CSRFHeader) - not this public key surface.
Invalid API keys return 401. Access to unrelated company resources
is denied by tenant-scoped authorization.
### Rate limits
Heavy mutations are limited to 30 requests per minute per company
(in-process per API replica; not shared across replicas). Counts HTTP
requests, not products inside a bulk body. Limited POST paths:
Processing and feed mutations are rate limited. Counts are per HTTP
request, not per product in a batch. Limited POST paths:
- /products/process, /process, /process/{id}/retry
- /feeds/{id}/sync, /feeds/{id}/extract-schema, /feeds/{id}/sync-process-sample
- /export-feeds/{id}/generate, /export-feeds/{id}/export-products, /export-feeds/{id}/rotate-token (admin)
- /export-feeds/{id}/generate, /export-feeds/{id}/export-products, /export-feeds/{id}/rotate-token
Over limit: HTTP 429, header Retry-After: 60, body
Over limit: HTTP 429 with Retry-After and body
{ "error": "rate limit exceeded" } (see TooManyRequests). Ordinary GETs and
other mutations are outside this HTTP budget (process starts may still return
402 for plan/credits).
@@ -104,8 +96,8 @@ info:
- Plan gates (credits / product limit / AI / EPREL / feature flags) run before
EnsureRaw catalog writes on the items[].ean path; blocked starts return HTTP 402
2. **Internal / dashboard-style jobs**
- POST /process with raw_product_ids (same body as POST /api/processing/jobs)
2. **Product processing jobs**
- POST /process with existing raw_product_ids
- GET /process, GET /process/{id}, cancel/terminate/retry
- Flat JSON (no data wrapper); 202 Accepted on start/retry
- Plan gates return HTTP 402 with PlanGateError (error + code + upgrade_url)
@@ -142,8 +134,7 @@ info:
product titles or descriptions. Company feature policies may still suppress
metadata output.
Note: Dashboard JSON under /api/* uses session cookies + CSRF and is separate
from this public API-key surface. Other path aliases
Other path aliases
(/categories/create, /attributes/create, /campaigns) appear next to canonical paths.
servers:
- url: https://api.descrybe.io/api/v1
@@ -161,10 +152,6 @@ tags:
- name: Campaigns
description: Seasonal content calendar (/campaigns aliases)
- name: Processing
- name: Team
description: Dashboard session routes under /api (not API-key)
- name: Admin
description: Platform-admin dashboard routes under /api (not API-key)
paths:
/health:
get:
@@ -498,7 +485,7 @@ paths:
responses:
'200':
description: Selected products returned to unprocessed. Returned when ResetProductsToUnprocessed
commits. Requires company-admin capability (API keys use role api and pass).
commits. Requires a valid company API key.
content:
application/json:
schema:
@@ -528,14 +515,14 @@ paths:
example:
error: product_ids is required
'403':
description: Caller role is neither admin nor api (requireCompanyAdmin). Valid company API keys
description: Access denied. Valid company API keys
use role api and do not hit this.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'500':
description: Unexpected reset failure after validation.
content:
@@ -642,15 +629,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -762,15 +747,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'404':
description: Resource id not found for this API-key company (or wrong tenant).
content:
@@ -1034,15 +1017,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -1350,15 +1331,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -1467,15 +1446,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -1550,15 +1527,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -1931,15 +1906,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2013,15 +1986,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2321,15 +2292,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2447,15 +2416,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2482,7 +2449,7 @@ paths:
- Feeds
summary: Delete feed
description: >-
Company-admin only. Atomically removes the input feed and its exclusively
Removes the input feed and its exclusively
owned, unprocessed or failed raw products. Previously processed products
are retained; active processing rows are not deleted, and products shared
with another existing feed are reassigned to that feed. Flat response
@@ -2508,13 +2475,13 @@ paths:
example:
error: invalid id
'403':
description: requireCompanyAdmin rejected the caller (session non-admin). API keys pass.
description: Access denied.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'404':
description: Feed not found.
content:
@@ -2608,15 +2575,13 @@ paths:
code: not_found
message: Feed not found
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2726,15 +2691,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2834,15 +2797,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2934,15 +2895,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -2971,7 +2930,7 @@ paths:
- Feeds
summary: Sync feed then process a sample of raw products
description: |
Optionally syncs the feed, then starts dashboard-style processing for up to N raw products
Optionally syncs the feed, then starts processing for up to N raw products
(default 10, max 100). Flat JSON; HTTP 202 when a job is queued, 200 when sync finishes with no products.
parameters:
- $ref: "#/components/parameters/ID"
@@ -3061,15 +3020,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -3342,15 +3299,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -3450,15 +3405,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -3484,10 +3437,10 @@ paths:
tags:
- Export feeds
summary: Delete export feed
description: "Company-admin only. Flat { status: ok } (not SuccessMessage)."
description: "Delete an export feed. Returns a deletion confirmation."
responses:
'200':
description: Export feed deleted (admin capability; API keys pass). Flat deleted marker.
description: Export feed deleted.
content:
application/json:
schema:
@@ -3504,13 +3457,13 @@ paths:
example:
error: invalid id
'403':
description: requireCompanyAdmin rejected session non-admin.
description: Access denied.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'404':
description: Export feed not found.
content:
@@ -3640,15 +3593,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -3677,7 +3628,7 @@ paths:
summary: Rotate public export URL token
description: |
Replaces public_token so the previous /api/public/export-feeds/{token}.{xml|csv|json}
URL stops working immediately. Requires company admin (or platform staff).
URL stops working immediately.
Response is a flat ExportFeedDetail including the new public_token.
parameters:
- $ref: "#/components/parameters/ID"
@@ -3703,13 +3654,13 @@ paths:
schema:
$ref: "#/components/schemas/CodedAPIError"
'403':
description: Admin required.
description: Access denied.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
"400": { $ref: "#/components/responses/BadRequest" }
"422": { $ref: "#/components/responses/ValidationError" }
"500": { $ref: "#/components/responses/InternalServerError" }
@@ -3792,15 +3743,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -3901,15 +3850,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -4294,7 +4241,7 @@ paths:
- $ref: "#/components/parameters/Limit"
responses:
'200':
description: "Recent dashboard-style jobs. Flat object with jobs[] and limit (handleV1ListProcessJobs\
description: "Recent processing jobs. Flat object with jobs[] and limit (\
\ — not a data envelope)."
content:
application/json:
@@ -4343,7 +4290,7 @@ paths:
summary: Start processing job by raw_product_ids
description: |
Enqueues AI processing for existing raw product UUIDs.
Same pipeline as dashboard POST /api/processing/jobs.
Uses the standard product processing pipeline.
Flat JSON body/response (no data wrapper); HTTP 202.
Pass raw_products.id only (GET /products data[].raw_product_id), never PresentProduct.id.
@@ -4505,15 +4452,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'422':
description: Validation failed. Current public v1 handlers emit these cases as HTTP 400 (flat
or coded). 422 is documented for clients that expect an explicit validation status; body matches
@@ -4582,15 +4527,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'404':
description: Resource id not found for this API-key company (or wrong tenant).
content:
@@ -4668,15 +4611,13 @@ paths:
example:
error: internal error
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'404':
description: Resource id not found for this API-key company (or wrong tenant).
content:
@@ -4754,15 +4695,13 @@ paths:
code: unauthorized
message: Unauthorized
'403':
description: Insufficient role or wrong company. On API-key routes, cross-tenant ids usually
return 404 instead. requireCompanyAdmin returns flat 'admin required' for session non-admin
callers (API keys use role api and pass).
description: Access denied or resource unavailable to this company.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
error: forbidden
'404':
description: Resource id not found for this API-key company (or wrong tenant).
content:
@@ -4792,265 +4731,6 @@ paths:
error:
code: validation_error
message: invalid json
/team/{userID}:
parameters:
- name: userID
in: path
required: true
schema:
type: string
format: uuid
description: Membership user id within the selected company
patch:
tags:
- Team
summary: Update team member role
description: |
Company admin or platform admin. Demoting the last active admin returns 409.
Requires session cookie + CSRF double-submit (X-CSRF-Token).
Dashboard surface under /api (not the public /api/v1 API-key base).
security:
- SessionCookie: []
CSRFHeader: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- role
properties:
role:
type: string
enum:
- admin
- member
description: Normalized to admin|member (case-insensitive input accepted)
example:
role: member
responses:
'200':
description: Role updated (or unchanged)
content:
application/json:
schema:
type: object
required:
- status
- role
- user_id
properties:
status:
type: string
example: ok
role:
type: string
enum:
- admin
- member
user_id:
type: string
format: uuid
example:
status: ok
role: member
user_id: 4f3c2b1a-0e9d-4c8b-7a6f-5e4d3c2b1a09
'400':
description: Invalid request for this route (HTTP 400).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: invalid json
'403':
description: Forbidden (not company/platform admin)
'404':
description: Resource not found (HTTP 404).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: not found
'409':
description: Cannot demote the last admin
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: cannot demote the last admin
'401':
description: Missing or invalid API key. RequireAPIKey returns this when Authorization Bearer
and X-API-Key are both absent/empty or AuthenticateAPIKey returns ErrInvalidAPIKey. Coded
envelope (not a flat string).
content:
application/json:
schema:
$ref: "#/components/schemas/CodedAPIError"
example:
error:
code: unauthorized
message: Unauthorized
'422':
description: Validation failed. Dashboard routes may use this status; prefer reading the message.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: validation failed
'500':
description: Unexpected server error (HTTP 500).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: list failed
/admin/emails/set-password:
post:
tags:
- Admin
summary: Re-issue set-password invites
description: |
Platform admin only. Prefers durable invite reissue (ReissueSetPasswordInvite);
falls back to HMAC set-password tokens when the user has no active membership.
Skips synthetic placeholder emails. Rate-limited per admin.
When SMTP is disabled and a single user_id is provided, the response may include
a one-time token for local/staging link copy (never logs email/token).
Dashboard surface under /api (not the public /api/v1 API-key base).
security:
- SessionCookie: []
CSRFHeader: []
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
user_id:
type: string
format: uuid
description: |
Target user UUID. When omitted, bulk-targets users needing a password (capped).
example:
user_id: 4f3c2b1a-0e9d-4c8b-7a6f-5e4d3c2b1a09
responses:
'200':
description: Issue/send summary
content:
application/json:
schema:
type: object
required:
- sent
- issued
- skipped
- smtp_enabled
- mode
properties:
sent:
type: integer
issued:
type: integer
skipped:
type: integer
skipped_synthetic:
type: integer
skipped_ineligible:
type: integer
skipped_rate_limited:
type: integer
skipped_send:
type: integer
smtp_enabled:
type: boolean
mode:
type: string
example: invite
token:
type: string
description: Present only for single-user reissue when SMTP is off
example:
sent: 1
issued: 1
skipped: 0
skipped_synthetic: 0
skipped_ineligible: 0
skipped_rate_limited: 0
skipped_send: 0
smtp_enabled: true
mode: invite
'401':
description: Unauthorized — missing session or privilege for this dashboard route.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: unauthorized
'429':
description: Rate limit exceeded for this admin action. May include Retry-After.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: Too many requests
'503':
description: Dependency unavailable (for example mailer down).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: mailer unavailable
'400':
description: Invalid request for this route (HTTP 400).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: invalid json
'403':
description: Forbidden for this route (HTTP 403).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: admin required
'409':
description: Conflict with current resource state.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: conflict
'422':
description: Validation failed. Dashboard routes may use this status; prefer reading the message.
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: validation failed
'500':
description: Unexpected server error (HTTP 500).
content:
application/json:
schema:
$ref: "#/components/schemas/FlatAPIError"
example:
error: list failed
components:
securitySchemes:
BearerAuth:
@@ -5074,18 +4754,6 @@ components:
Alternate scheme for /api/v1. Same company API key as BearerAuth, sent
as header X-API-Key: dk_your_key. When both Authorization Bearer and
X-API-Key are present, Bearer wins.
SessionCookie:
type: apiKey
in: cookie
name: descrybe_session
description: Dashboard session cookie only (SESSION_COOKIE_NAME; default descrybe_session). Not
valid for /api/v1 public routes.
CSRFHeader:
type: apiKey
in: header
name: X-CSRF-Token
description: Dashboard CSRF double-submit header (must match descrybe_csrf cookie). Not used by
/api/v1 API-key routes.
parameters:
ID:
in: path
@@ -11,6 +11,27 @@ import (
"gopkg.in/yaml.v3"
)
func TestV1OpenAPIYAMLDoesNotPublishAdminRoutes(t *testing.T) {
t.Parallel()
root := mustParseOpenAPIRoot(t, v1OpenAPIYAML)
paths, ok := root["paths"].(map[string]any)
if !ok {
t.Fatal("missing paths map")
}
for path := range paths {
if strings.HasPrefix(path, "/admin/") || strings.HasPrefix(path, "/team/") {
t.Fatalf("non-public dashboard path leaked: %s", path)
}
}
schemes := root["components"].(map[string]any)["securitySchemes"].(map[string]any)
if _, ok := schemes["SessionCookie"]; ok {
t.Fatal("session-cookie authentication leaked into public docs")
}
if _, ok := schemes["CSRFHeader"]; ok {
t.Fatal("CSRF authentication leaked into public docs")
}
}
func TestV1OpenAPIYAMLParses(t *testing.T) {
t.Parallel()
@@ -375,7 +375,7 @@ func (s *Server) startV1Jobs(ctx context.Context, companyID, userID uuid.UUID, r
if s != nil && s.testStartJobs != nil {
return s.testStartJobs(ctx, companyID, userID, rawIDs, processingType)
}
return s.Processing.StartJob(ctx, companyID, userID, rawIDs, processingType)
return s.Processing.StartAPIJob(ctx, companyID, userID, rawIDs, processingType)
}
func (s *Server) enqueueV1Job(ctx context.Context, jobID uuid.UUID) error {