openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 1.0.0 description: BANCO Asset Marketplace API — Cars, Real Estate, Industrial servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: feed description: Adaptive feed - name: listings description: Listing management - name: search description: Search and discovery - name: leads description: Lead tracking and behavior signals - name: saves description: Saved listings - name: dealer description: Banco Market (B2B) - name: me description: Current authenticated user state components: securitySchemes: ClerkAuth: type: http scheme: bearer bearerFormat: JWT schemas: HealthStatus: type: object required: [status] properties: status: type: string enum: [ok, degraded] ApiError: type: object required: [code, message] properties: code: type: string enum: [INVALID_DATA, NOT_FOUND, UNAUTHORIZED, INTERNAL_ERROR, FORBIDDEN, RATE_LIMITED, INVALID_TOKEN, CONFLICT] message: type: string Meta: type: object properties: cursor: type: string has_next: type: boolean total: type: integer FacetCounts: type: object description: >- Per-value counts of the currently-visible inventory. Each map is keyed by the attribute value (e.g. fuel_type "diesel") with the count of matching active, publicly-visible listings. Maps only include values that have at least one listing, so clients can render facet chips directly. The category map is unscoped; all other maps respect the requested category. required: - total - category - condition - fuel_type - transmission - payment_plan - property_type - finishing_type - offer_type - industrial_type - industry - origin_type - compound - furnished - has_installment properties: total: type: integer category: type: object additionalProperties: type: integer condition: type: object additionalProperties: type: integer fuel_type: type: object additionalProperties: type: integer transmission: type: object additionalProperties: type: integer payment_plan: type: object additionalProperties: type: integer property_type: type: object additionalProperties: type: integer finishing_type: type: object additionalProperties: type: integer offer_type: type: object additionalProperties: type: integer industrial_type: type: object additionalProperties: type: integer industry: type: object additionalProperties: type: integer origin_type: type: object additionalProperties: type: integer compound: type: integer furnished: type: integer has_installment: type: integer UserState: type: object description: Authoritative current-user state. DB is the source of truth for role. required: [id, clerk_id, account_number, role, staff_role, name, is_verified, is_admin, wallet_balance, created_at] properties: id: type: string clerk_id: type: string account_number: type: string nullable: true description: Internal default account number, auto-assigned per user. role: type: string enum: [individual, dealer, company, enterprise, financial_institution] staff_role: type: string enum: [owner, admin, moderator, support, user] description: > Internal staff role, a separate axis from `role`. "user" means no staff access; the others grant Admin Control Center permissions. is_admin: type: boolean description: Whether this user has Admin Control Center access. name: type: string email: type: string nullable: true phone: type: string nullable: true is_verified: type: boolean wallet_balance: type: string created_at: type: string FeedItem: type: object description: > Immutable v1 contract — exactly 11 fields. No renames, no removals allowed in v1. Breaking changes go to /v2/*. required: - id - media_preview - price_display - title - location - trust_signal - has_video - is_sponsored properties: id: type: string description: Listing identifier (use for detail navigation). media_preview: type: string price_display: type: string installment_badge: type: string nullable: true title: type: string location: type: string urgency_signal: type: string nullable: true trust_signal: type: string smart_badge: type: string nullable: true has_video: type: boolean is_sponsored: type: boolean coordinates: $ref: "#/components/schemas/Coordinates" nullable: true best_offer_badge: type: string nullable: true industrial_type: type: string nullable: true description: Industrial sub-type (factory, warehouse, land, production_line, raw_material, machine) used for client-side category grouping. Null for non-industrial listings. origin_type: type: string nullable: true description: '"imported" when the listing is imported (else null) — drives the "مستورد / Imported" card badge on industrial + car listings.' category: type: string enum: [car, real_estate, industrial] nullable: true description: Additive. The listing's main section — lets clients adapt per-section UI (e.g. the save glyph) without re-deriving it. is_active: type: boolean nullable: true description: True when the listing status is "active" (publicly visible and promotable). Lets owner-facing surfaces built on FeedItem (e.g. the profile grid) gate the Promote control without fetching ListingDetail. Null when status is unknown. whatsapp_enabled: type: boolean nullable: true description: True when the seller opted this listing in to WhatsApp contact. Opt-in only (default false). Lets surfaces decide whether to surface a WhatsApp action. Null when unknown. created_at: type: string nullable: true description: Listing creation timestamp (ISO 8601). Owner-facing grids (profile, "my listings") render a "Listed " caption. Null only when the source row lacks it; public feeds always carry it. is_request: type: boolean nullable: true description: True when this is a buyer "request/wanted" post (looking to buy) rather than a sale listing. Surfaces render a "طلب / Wanted" badge and the requests filter keys off it. Null when unknown. is_bookable: type: boolean nullable: true description: >- Additive. True when this listing is a furnished/daily rental (hotel model) that can be reserved from its detail. Lets the feed, search card, and map pin surface a "قابل للحجز / Bookable" affordance without fetching the detail. Null/false for everything else. Coordinates: type: object required: [lat, lng] properties: lat: type: number lng: type: number Offer: type: object description: > Display-ready financing offer. Intentionally has NO rate/APR field — Islamic offers must never carry or imply one. All money is pre-formatted server-side; the client never calculates. required: - id - financing_type - provider - provider_badge - monthly_display - duration_months - total_payable_display - is_best properties: id: type: string financing_type: type: string enum: [islamic, conventional] provider: type: string enum: [seller, bank, dealer, supplier] provider_badge: type: string monthly_display: type: string duration_months: type: integer down_payment_display: type: string nullable: true total_payable_display: type: string is_best: type: boolean MediaItem: type: object required: [id, type, url, is_thumbnail] properties: id: type: string type: type: string enum: [image, video] url: type: string thumbnail_url: type: string nullable: true is_thumbnail: type: boolean PaymentOption: type: object properties: mode: type: string enum: [cash, seller_installment, bank_finance] down_payment: type: string nullable: true monthly_payment: type: string nullable: true duration_months: type: integer nullable: true is_islamic_compliant: type: boolean PaymentSummary: type: object required: [has_installment, options] properties: has_installment: type: boolean options: type: array items: $ref: "#/components/schemas/PaymentOption" lowest_monthly: type: string nullable: true lowest_down_payment: type: string nullable: true badge: type: string nullable: true Seller: type: object required: [id, name, role, is_verified] properties: id: type: string name: type: string role: type: string is_verified: type: boolean phone: type: string nullable: true # Additive (Profiles 2.0): seller-published marketing links — public by # design; the phone stays behind the contact-token flow. social_links: type: array items: type: object required: [platform, value] properties: platform: type: string value: type: string ListingDetail: type: object required: - id - title - category - price_display - location - status - created_at - media - specs - payment - seller - interactions - is_saved properties: id: type: string title: type: string description: type: string nullable: true category: type: string enum: [car, real_estate, industrial] price_display: type: string price_cash: type: number nullable: true description: >- Additive. Raw numeric cash price. For furnished/daily rentals this is the per-night rate the booking widget multiplies by the night count for a pre-booking estimate; the server stays authoritative on the real total. Null when unknown. location: type: string status: type: string enum: [active, sold, archived] created_at: type: string format: date-time media: type: array items: $ref: "#/components/schemas/MediaItem" specs: type: object additionalProperties: true payment: $ref: "#/components/schemas/PaymentSummary" seller: $ref: "#/components/schemas/Seller" interactions: type: object properties: views: type: integer clicks: type: integer is_saved: type: boolean is_request: type: boolean coordinates: $ref: "#/components/schemas/Coordinates" nullable: true offers: type: array items: $ref: "#/components/schemas/Offer" best_offer: $ref: "#/components/schemas/Offer" nullable: true linked_listings: type: array description: > Additive (Task #33). Bidirectional supply-chain cross-links surfaced on the listing detail only. Optional — older clients may ignore it. items: $ref: "#/components/schemas/LinkedListing" logistics: allOf: - $ref: "#/components/schemas/Logistics" nullable: true description: > Additive (Task #40). Optional seller-provided logistics & delivery block; null when the seller provided none. Older clients may ignore it. contact_token: type: string nullable: true description: > Single-use UUID token minted server-side when an authenticated non-owner loads this listing. Required by POST /v1/leads/contact. Null for the listing owner and for unauthenticated viewers. whatsapp_enabled: type: boolean nullable: true description: > True when the seller opted this listing in to WhatsApp contact. Opt-in only (default false); clients gate the WhatsApp CTA on it. DealerListing: type: object properties: id: type: string title: type: string category: type: string price_display: type: string price_raw: type: string location: type: string status: type: string created_at: type: string views: type: integer clicks: type: integer leads: type: integer Lead: type: object properties: id: type: string listing_id: type: string listing_title: type: string action_type: type: string enum: [whatsapp, call, chat, finance_request] status: type: string enum: [new, contacted, closed] buyer_name: type: string nullable: true buyer_phone: type: string nullable: true created_at: type: string ConversationSummary: type: object required: [id, listing_id, counterparty_name, unread, viewer_role] properties: id: type: string listing_id: type: string listing_title: type: string nullable: true listing_thumb: type: string nullable: true counterparty_id: type: string counterparty_name: type: string last_message_text: type: string nullable: true last_message_at: type: string nullable: true unread: type: integer viewer_role: type: string enum: [buyer, seller] Message: type: object required: [id, conversation_id, sender_id, body, is_mine, created_at] properties: id: type: string conversation_id: type: string sender_id: type: string body: type: string is_mine: type: boolean created_at: type: string read_at: type: string nullable: true media_url: type: string nullable: true media_kind: type: string nullable: true description: Attachment kind — image | video | audio (voice note). reactions: type: object additionalProperties: type: integer description: Count of each emoji reaction on the message. my_reactions: type: array items: type: string description: Emojis the viewer has reacted with. reply_to: type: object nullable: true description: Preview of the message this one replies to. required: [id, body, sender_id] properties: id: type: string body: type: string sender_id: type: string listing_ref: type: object nullable: true description: A listing shared as a card inside the chat. required: [id] properties: id: type: string title: type: string nullable: true thumb: type: string nullable: true price: type: string nullable: true ReactionResult: type: object required: [reactions, my_reactions] properties: reactions: type: object additionalProperties: type: integer my_reactions: type: array items: type: string Notification: type: object required: [id, type, title, body, created_at] properties: id: type: string type: type: string enum: [message, lead, system, rfq, new_match, price_drop, comment, review, investment, global_supply, booking, payment_success, payment_failed, subscription_expiring, car_import] title: type: string body: type: string data: type: object additionalProperties: true nullable: true read_at: type: string nullable: true created_at: type: string Comment: type: object description: A listing Q&A entry — a question (parent_id null) or a reply (Task #39). required: [id, listing_id, parent_id, author_id, author_name, is_seller, body, created_at] properties: id: type: string listing_id: type: string parent_id: type: string nullable: true author_id: type: string author_name: type: string is_seller: type: boolean description: True when the author owns the listing (the seller's answer). body: type: string created_at: type: string CommentBody: type: object description: Payload to ask a question or reply on a listing (Task #39). required: [body] properties: body: type: string parent_id: type: string nullable: true description: Set to reply to an existing question; omit for a top-level question. CommentDeleteResult: type: object description: Result of deleting a comment (author or listing owner). required: [deleted] properties: deleted: type: boolean SellerReview: type: object description: A buyer's rating/review of a seller (Task #39). required: [id, seller_id, author_id, author_name, rating, body, created_at] properties: id: type: string seller_id: type: string author_id: type: string author_name: type: string rating: type: integer minimum: 1 maximum: 5 body: type: string nullable: true created_at: type: string ReviewSummary: type: object description: Aggregate rating for a seller (Task #39). required: [average, count] properties: average: type: number nullable: true description: Average rating (1 decimal), null when there are no reviews. count: type: integer ReviewsResponse: type: object description: A seller's reviews with aggregate + viewer-aware eligibility (Task #39). required: [items, summary, can_review, my_rating] properties: items: type: array items: $ref: "#/components/schemas/SellerReview" summary: $ref: "#/components/schemas/ReviewSummary" can_review: type: boolean description: Whether the authenticated viewer may leave/update a review. my_rating: type: integer minimum: 1 maximum: 5 nullable: true description: The viewer's existing rating, if any (for prefill). ReviewBody: type: object description: Payload to create or update a seller review (Task #39). required: [rating] properties: rating: type: integer minimum: 1 maximum: 5 body: type: string nullable: true SocialLink: type: object description: Public seller/company social link shown on the profile (Task #38). required: [platform, value] properties: platform: type: string enum: [instagram, linkedin, website, whatsapp] value: type: string description: URL (website/linkedin/instagram) or phone (whatsapp), normalized server-side. NotificationPreference: type: object description: Per-category notification preference. Absence of a row = enabled (Task #38). required: [type, in_app, email] properties: type: type: string enum: [message, lead, system, rfq, new_match, price_drop, comment, review, investment, global_supply, booking, payment_success, payment_failed, subscription_expiring, car_import] in_app: type: boolean email: type: boolean SavedSearch: type: object description: A saved search with optional price-tracking + match alerts (Task #38). required: [id, name, alerts_enabled, created_at] properties: id: type: string name: type: string query: type: string nullable: true category: type: string enum: [car, real_estate, industrial] nullable: true filters: type: object additionalProperties: true nullable: true price_min: type: string nullable: true price_max: type: string nullable: true alerts_enabled: type: boolean created_at: type: string LinkedListing: type: object description: > Compact supply-chain cross-link surfaced on listing detail (Task #33). required: - id - title - price_display - thumbnail - category - industrial_type - relation - direction - supplier properties: id: type: string title: type: string price_display: type: string thumbnail: type: string nullable: true category: type: string enum: [car, real_estate, industrial] industrial_type: type: string nullable: true relation: type: string enum: [feeds_into, part_of, compatible_with] direction: type: string enum: [incoming, outgoing] supplier: type: object nullable: true required: [id, name, is_verified] properties: id: type: string name: type: string is_verified: type: boolean CompanyStats: type: object description: Public seller stats — safe to expose, no lead PII (Task #33). required: - active_listings - total_listings - member_since - years_active - response_rate - is_verified properties: active_listings: type: number total_listings: type: number member_since: type: string years_active: type: number response_rate: type: number nullable: true is_verified: type: boolean description: Real admin-set verification flag; never inferred client-side. AiAssistantMessage: type: object required: [role, content] properties: role: type: string enum: [user, assistant] content: type: string AiAssistantBody: type: object required: [message] properties: message: type: string description: The user's new message/question for the BANCO assistant. history: type: array description: Prior turns in this session (client-held, capped server-side). Optional. items: $ref: "#/components/schemas/AiAssistantMessage" AiAssistantAction: type: object description: > An actionable suggestion the assistant attaches to a reply so the client can deep-link the user to the right place. Every action is built server-side from REAL data (real listing ids, the user's real conversations, real search filters) — never fabricated by the model. required: [kind, label] properties: kind: type: string enum: [listing, search, conversation, navigate] label: type: string description: Display text for the tappable chip/card. listing_id: type: string nullable: true description: For kind=listing — navigate to /listing/{id}. price_display: type: string nullable: true thumbnail_url: type: string nullable: true location: type: string nullable: true query: type: string nullable: true description: For kind=search — the search text to run. category: type: string nullable: true max_price: type: number nullable: true has_installment: type: boolean nullable: true conversation_id: type: string nullable: true description: For kind=conversation — open /messages/{id}. screen: type: string nullable: true description: > For kind=navigate — a known in-app screen key the client maps to a route (home, search, saved, messages, my_listings, create_listing, wallet, profile, notifications). AiAssistantResponse: type: object required: [answer] properties: answer: type: string description: The assistant's reply, grounded only in real BANCO context. actions: type: array description: > Optional deep-link suggestions (real listings, a search, a conversation, or an app screen). Additive/back-compatible — older clients ignore it. items: $ref: "#/components/schemas/AiAssistantAction" CompanyTrade: type: object description: > Structured B2B trade block. Null on the profile when the seller has no company profile (e.g. an individual). required: - about - year_established - countries_import_from - countries_export_to - min_order_value - min_order_unit - monthly_capacity - lead_time_days - certifications - website_url - logo_url - cover_url - industry - hq_country properties: about: type: string nullable: true year_established: type: number nullable: true countries_import_from: type: array items: type: string countries_export_to: type: array items: type: string min_order_value: type: string nullable: true min_order_unit: type: string nullable: true monthly_capacity: type: string nullable: true lead_time_days: type: number nullable: true certifications: type: array items: type: string website_url: type: string nullable: true logo_url: type: string nullable: true cover_url: type: string nullable: true industry: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] nullable: true hq_country: type: string nullable: true CompanyProfile: type: object description: Public company / supplier profile (Task #33). required: [id, name, role, is_verified, stats, company] properties: id: type: string name: type: string role: type: string is_verified: type: boolean stats: $ref: "#/components/schemas/CompanyStats" company: $ref: "#/components/schemas/CompanyTrade" nullable: true follower_count: type: integer description: Additive (Task #40). Supplier-directory follower count. is_following: type: boolean description: > Additive (Task #40). Viewer-relative; false when unauthenticated. latest_listing_id: type: string nullable: true description: > Additive. The seller's newest visible listing — anchors the profile "Message" button (conversations are listing-anchored). Rfq: type: object description: RFQ summary (list item + base of the detail) (Task #33). required: - id - buyer_id - buyer_name - category - title - description - quantity - unit - target_price_max - destination_country - industry - industrial_type - status - deadline - offer_count - created_at properties: id: type: string buyer_id: type: string buyer_name: type: string nullable: true category: type: string enum: [car, real_estate, industrial] title: type: string description: type: string nullable: true quantity: type: string nullable: true unit: type: string nullable: true target_price_max: type: string nullable: true destination_country: type: string nullable: true industry: type: string nullable: true industrial_type: type: string nullable: true status: type: string enum: [open, awarded, closed, cancelled] deadline: type: string nullable: true offer_count: type: number created_at: type: string RfqOffer: type: object description: A supplier's offer on an RFQ (Task #33). required: - id - rfq_id - supplier_id - supplier_name - supplier_is_verified - price_quote - currency - lead_time_days - moq - message - status - is_mine - created_at properties: id: type: string rfq_id: type: string supplier_id: type: string supplier_name: type: string nullable: true supplier_is_verified: type: boolean price_quote: type: string currency: type: string lead_time_days: type: number nullable: true moq: type: string nullable: true message: type: string nullable: true status: type: string enum: [pending, accepted, rejected, withdrawn] is_mine: type: boolean created_at: type: string RfqDetail: type: object description: > RFQ detail. offers visibility is enforced server-side: the buyer sees ALL offers; a supplier sees only their own; the public sees none (Task #33). required: - id - buyer_id - buyer_name - category - title - description - quantity - unit - target_price_max - destination_country - industry - industrial_type - status - deadline - offer_count - created_at - offers - viewer_is_buyer properties: id: type: string buyer_id: type: string buyer_name: type: string nullable: true category: type: string enum: [car, real_estate, industrial] title: type: string description: type: string nullable: true quantity: type: string nullable: true unit: type: string nullable: true target_price_max: type: string nullable: true destination_country: type: string nullable: true industry: type: string nullable: true industrial_type: type: string nullable: true status: type: string enum: [open, awarded, closed, cancelled] deadline: type: string nullable: true offer_count: type: number created_at: type: string offers: type: array items: $ref: "#/components/schemas/RfqOffer" viewer_is_buyer: type: boolean Story: type: object required: [id, user_id, user_name, media_url, created_at, expires_at, seen, is_mine] properties: id: type: string user_id: type: string user_name: type: string user_avatar: type: string nullable: true media_url: type: string caption: type: string nullable: true listing_id: type: string nullable: true created_at: type: string expires_at: type: string seen: type: boolean is_mine: type: boolean view_count: type: integer DealerStats: type: object properties: active_listings: type: integer total_listings: type: integer leads_today: type: integer conversion_rate: type: string total_views: type: integer leads_chart: type: array items: type: object properties: date: type: string leads: type: integer BoostResult: type: object properties: ad_id: type: string listing_id: type: string ad_type: type: string expires_at: type: string duration_days: type: integer promo_used: type: string description: > Promo ad credit applied to this boost (consumed before the real wallet), as a 2-dp string. "0.00" when no promo was available. wallet_charged: type: string description: > Real wallet money charged — the remainder after promo credit — as a 2-dp string. ImportResult: type: object properties: success_count: type: integer failed_count: type: integer errors: type: array items: type: object properties: batch_index: type: integer rows_in_batch: type: integer message: type: string Ad: type: object properties: id: type: string listing_id: type: string listing_title: type: string nullable: true seller_id: type: string nullable: true seller_name: type: string nullable: true ad_type: type: string is_active: type: boolean budget_total: type: string nullable: true budget_spent: type: string impressions: type: integer billable_impressions: type: integer starts_at: type: string nullable: true expires_at: type: string created_at: type: string nullable: true AdminUser: type: object properties: id: type: string account_number: type: string nullable: true description: Internal default account number, auto-assigned per user. name: type: string email: type: string nullable: true phone: type: string nullable: true role: type: string enum: [individual, dealer, company, enterprise, financial_institution] staff_role: type: string enum: [owner, admin, moderator, support, user] description: Internal staff role (separate axis from `role`). is_admin: type: boolean is_verified: type: boolean is_shadow_banned: type: boolean wallet_balance: type: string listing_count: type: integer created_at: type: string company_details: type: object nullable: true description: > Business / FI onboarding payload used for KYC review (activity, names, city, document URLs). Null when the user never submitted business verification. properties: activity_type: type: string nullable: true business_name: type: string nullable: true trade_name: type: string nullable: true owner_name: type: string nullable: true city: type: string nullable: true documents: type: array items: type: string description: Uploaded verification document / ID photo URLs. fi_license_number: type: string nullable: true fi_license_type: type: string nullable: true fi_regulator: type: string nullable: true fi_registry_number: type: string nullable: true AdminListing: type: object properties: id: type: string title: type: string price_display: type: string category: type: string status: type: string enum: [active, sold, archived, draft, pending_approval, pending_review, approved, rejected, flagged] is_flagged: type: boolean seller_id: type: string nullable: true seller_name: type: string nullable: true seller_shadow_banned: type: boolean media_preview: type: string nullable: true report_count: type: integer view_count: type: integer lead_count: type: integer location: type: string nullable: true created_at: type: string FinancingRequest: type: object properties: lead_id: type: string status: type: string enum: [new, forwarded, contacted, closed, rejected] branch_id: type: string nullable: true listing_id: type: string listing_title: type: string category: type: string enum: [car, real_estate, industrial] buyer_name: type: string nullable: true buyer_phone: type: string nullable: true asset_price: type: string nullable: true down_payment: type: string nullable: true monthly_payment: type: string nullable: true duration_months: type: integer nullable: true provider_name: type: string nullable: true intermediary_id: type: string nullable: true intermediary_name: type: string nullable: true notes: type: string nullable: true assigned_at: type: string nullable: true created_at: type: string nullable: true updated_at: type: string nullable: true FinancingIntermediary: type: object properties: id: type: string name: type: string contact_email: type: string nullable: true contact_phone: type: string nullable: true notes: type: string nullable: true owner_user_id: type: string nullable: true description: >- FI phase 2 — the bank's own marketplace account that owns this intermediary (null = legacy admin-only row). Linking it enables the automatic hand-off of forwarded requests to the bank's people. is_active: type: boolean created_at: type: string nullable: true FinancingBranch: type: object properties: id: type: string intermediary_id: type: string name: type: string city: type: string nullable: true is_active: type: boolean created_at: type: string nullable: true FinancingSeat: type: object properties: id: type: string intermediary_id: type: string branch_id: type: string nullable: true user_id: type: string user_name: type: string nullable: true user_email: type: string nullable: true role: type: string enum: [manager, agent] created_at: type: string nullable: true InstitutionMembership: type: object description: >- Who the caller is inside a financial institution — the owning FI account or an employee seat (manager sees all branches; agent is scoped to its branch plus unrouted requests). properties: intermediary_id: type: string intermediary_name: type: string role: type: string enum: [owner, manager, agent] branch_id: type: string nullable: true InstitutionInbox: type: object required: [membership, items, has_next] properties: membership: $ref: "#/components/schemas/InstitutionMembership" items: type: array items: $ref: "#/components/schemas/FinancingRequest" # Additive: the institution's branches for the bank-side routing picker # (scoped by membership — no admin endpoint needed on the bank side). branches: type: array items: type: object required: [id, name] properties: id: type: string name: type: string cursor: type: string nullable: true has_next: type: boolean Report: type: object properties: id: type: string listing_id: type: string listing_title: type: string nullable: true reason: type: string enum: [fake_price, wrong_data, scam, duplicate, other] details: type: string nullable: true status: type: string enum: [open, reviewing, resolved, dismissed] reporter_name: type: string nullable: true resolution_note: type: string nullable: true created_at: type: string resolved_at: type: string nullable: true SupportMessage: type: object properties: id: type: string body: type: string is_admin: type: boolean author_name: type: string nullable: true created_at: type: string SupportTicket: type: object properties: id: type: string subject: type: string category: type: string nullable: true status: type: string enum: [open, closed] user_id: type: string nullable: true user_name: type: string nullable: true message_count: type: integer last_reply_at: type: string nullable: true created_at: type: string messages: type: array items: $ref: "#/components/schemas/SupportMessage" RevenueSummary: type: object properties: total_mtd: type: string total_all_time: type: string currency: type: string by_channel: type: array items: type: object properties: channel: type: string amount: type: string note: type: string nullable: true timeseries: type: array items: type: object properties: date: type: string amount: type: string AdminAnalytics: type: object properties: conversion_rate: type: number total_listings: type: integer active_listings: type: integer sold_listings: type: integer total_leads: type: integer top_categories: type: array items: type: object properties: category: type: string listing_count: type: integer lead_count: type: integer best_sellers: type: array items: type: object properties: user_id: type: string name: type: string sold_count: type: integer lead_count: type: integer trending_listings: type: array items: type: object properties: id: type: string title: type: string view_count: type: integer lead_count: type: integer FraudSignal: type: object properties: id: type: string type: type: string severity: type: string enum: [info, warning, critical] title: type: string description: type: string subject_id: type: string nullable: true count: type: integer created_at: type: string Alert: type: object properties: id: type: string type: type: string enum: [lead_drop, error_spike, fraud_spike, payment_failure] severity: type: string enum: [info, warning, critical] title: type: string description: type: string value: type: string nullable: true created_at: type: string Monitoring: type: object properties: uptime_seconds: type: number total_requests: type: integer throughput_per_min: type: number error_rate: type: number latency_p50_ms: type: number latency_p95_ms: type: number feed_latency_p50_ms: type: number feed_latency_p95_ms: type: number endpoints: type: array items: type: object properties: path: type: string count: type: integer error_count: type: integer p50_ms: type: number p95_ms: type: number PaymentConfigView: type: object description: > Masked payment-provider config for the admin UI. Secret material is NEVER included — only booleans indicating whether secrets are stored. required: - provider - source - configured - enabled - mode - integration_ids - has_secret_key - has_hmac_secret properties: provider: type: string source: type: string enum: [db, env, none] configured: type: boolean enabled: type: boolean mode: type: string enum: [test, live] public_key: type: string nullable: true integration_ids: type: string api_base: type: string nullable: true has_secret_key: type: boolean has_hmac_secret: type: boolean updated_at: type: string nullable: true updated_by: type: string nullable: true PaymentConfigUpdate: type: object description: > Editable PSP fields. Secret fields (secret_key, hmac_secret) are write-only — omit or send an empty string to keep the stored value. properties: enabled: type: boolean mode: type: string enum: [test, live] public_key: type: string nullable: true integration_ids: type: string nullable: true api_base: type: string nullable: true secret_key: type: string hmac_secret: type: string PaymentConfigTestResult: type: object required: - ok - message - mode - source properties: ok: type: boolean message: type: string mode: type: string enum: [test, live] source: type: string enum: [db, env, none] EmailConfigView: type: object description: > Masked email-provider (Resend) config for the admin UI. The API key is NEVER included — only a boolean indicating whether a key is stored. required: - provider - source - configured - enabled - active_transport - has_api_key properties: provider: type: string source: type: string enum: [db, env, none] configured: type: boolean enabled: type: boolean active_transport: type: string enum: [resend, log] from_name: type: string nullable: true from_email: type: string nullable: true sending_domain: type: string nullable: true reply_to: type: string nullable: true public_app_url: type: string nullable: true has_api_key: type: boolean updated_at: type: string nullable: true updated_by: type: string nullable: true EmailConfigUpdate: type: object description: > Editable email-provider fields. The API key is write-only — omit or send an empty string to keep the stored value. properties: enabled: type: boolean from_name: type: string nullable: true from_email: type: string nullable: true sending_domain: type: string nullable: true reply_to: type: string nullable: true public_app_url: type: string nullable: true api_key: type: string EmailConfigTestResult: type: object required: - ok - message - active_transport - source properties: ok: type: boolean message: type: string active_transport: type: string enum: [resend, log] source: type: string enum: [db, env, none] AdminPlan: type: object description: > A subscription plan — the platform's economic levers (pricing, listing quota, cost-per-lead, boost price, ranking weight, feature flags). required: - id - slug - name - name_ar - audience - is_baseline - monthly_price - listing_quota - active_listing_cap - boost_price - cpl_whatsapp - cpl_call - cpl_chat - cpl_finance_request - ranking_weight - features - is_active - sort_order properties: id: type: string slug: type: string name: type: string name_ar: type: string nullable: true audience: type: string is_baseline: type: boolean monthly_price: type: number listing_quota: type: integer nullable: true active_listing_cap: type: integer nullable: true boost_price: type: number cpl_whatsapp: type: number cpl_call: type: number cpl_chat: type: number cpl_finance_request: type: number ranking_weight: type: number features: type: object additionalProperties: true nullable: true is_active: type: boolean sort_order: type: integer AdminPlanUpdate: type: object description: Partial update — only the provided fields change. properties: name: type: string name_ar: type: string nullable: true audience: type: string enum: [individual, dealer, company, enterprise, financial_institution] is_baseline: type: boolean monthly_price: type: number listing_quota: type: integer nullable: true active_listing_cap: type: integer nullable: true boost_price: type: number cpl_whatsapp: type: number cpl_call: type: number cpl_chat: type: number cpl_finance_request: type: number ranking_weight: type: number features: type: object additionalProperties: true nullable: true is_active: type: boolean sort_order: type: integer AdminPlanCreate: allOf: - $ref: "#/components/schemas/AdminPlanUpdate" - type: object required: - slug - name properties: slug: type: string MapCluster: type: object description: > One occupied grid cell on the map — its centroid and how many listings it aggregates. listing_id is set ONLY when count is 1 (a single tappable pin); for multi-listing cells it is null and the client shows a count bubble. required: - lat - lng - count - listing_id properties: lat: type: number lng: type: number count: type: integer listing_id: type: string nullable: true PriceHistoryPoint: type: object description: One month of aggregated real prices for a market segment. required: - month - count properties: month: type: string description: YYYY-MM count: type: integer average: type: number nullable: true median: type: number nullable: true min: type: number nullable: true max: type: number nullable: true DealInsights: type: object description: > A listing's price versus its market segment. `rating` is insufficient_data (and the figures null) until the segment has enough real observations — never a fabricated number. required: - rating - segment_key - sample_size - currency - history properties: rating: type: string enum: [great_deal, good_deal, fair, above_market, insufficient_data] segment_key: type: string sample_size: type: integer currency: type: string median: type: number nullable: true average: type: number nullable: true min: type: number nullable: true max: type: number nullable: true delta_pct: type: number nullable: true description: How far this listing's price sits below (−) or above (+) the segment median, in %. trend_pct: type: number nullable: true description: Last 3-month average vs the prior 3 months, in %. history: type: array items: $ref: "#/components/schemas/PriceHistoryPoint" PlaceSuggestion: type: object description: A geo/real-estate reference place matched for autocomplete. required: - id - global_id - place_type - name_en - name_ar - iso_country_code - popularity properties: id: type: string global_id: type: string place_type: type: string name_en: type: string name_ar: type: string nullable: true iso_country_code: type: string nullable: true popularity: type: integer AvailabilityRange: type: object description: A booked (unavailable) date range for a furnished/daily rental. required: [check_in, check_out] properties: check_in: type: string check_out: type: string Booking: type: object description: A short‑stay reservation of a furnished/daily rental (hotel model). required: [id, listing_id, check_in, check_out, nights, guests, currency, status] properties: id: type: string listing_id: type: string check_in: type: string check_out: type: string nights: type: integer guests: type: integer price_per_night: type: number nullable: true total_price: type: number nullable: true currency: type: string status: type: string created_at: type: string nullable: true CreateBookingBody: type: object required: [check_in, check_out] properties: check_in: type: string description: YYYY-MM-DD check_out: type: string description: YYYY-MM-DD guests: type: integer note: type: string nullable: true BookingListItem: type: object description: >- A booking enriched for the inbox — the underlying reservation plus the listing title/location and the other party's name (the guest in the host view, the host in the guest view). required: [id, listing_id, check_in, check_out, nights, guests, currency, status, listing_title] properties: id: type: string listing_id: type: string check_in: type: string check_out: type: string nights: type: integer guests: type: integer price_per_night: type: number nullable: true total_price: type: number nullable: true currency: type: string status: type: string created_at: type: string nullable: true listing_title: type: string listing_location: type: string nullable: true counterparty_name: type: string nullable: true UpdateBookingBody: type: object required: [action] properties: action: type: string enum: [confirm, reject, cancel] description: >- confirm/reject are host-only (on a requested booking); cancel is guest-only (on a requested/confirmed booking). ImportOrderStage: type: string enum: [order, review, confirm, shipping, customs, delivered, cancelled] description: >- Live sequential stage of a car-import order, matching the in-app import guide: order to review to confirm to shipping to customs to delivered, with cancelled as the terminal negative outcome. CreateImportOrderBody: type: object description: A buyer's request to import a vehicle from abroad. properties: listing_id: type: string nullable: true description: Optional marketplace listing this import is based on. origin_country: type: string nullable: true description: ISO country the vehicle is imported from. destination_country: type: string nullable: true description: ISO country the vehicle is imported to (buyer's market). details: type: object additionalProperties: true nullable: true description: Free-form vehicle spec (make/model/year/trim) for listing-less requests. budget_amount: type: number nullable: true currency: type: string nullable: true note: type: string nullable: true ImportOrder: type: object required: [id, stage, created_at] properties: id: type: string user_id: type: string listing_id: type: string nullable: true stage: $ref: "#/components/schemas/ImportOrderStage" origin_country: type: string nullable: true destination_country: type: string nullable: true details: type: object additionalProperties: true nullable: true budget_amount: type: number nullable: true quote_amount: type: number nullable: true currency: type: string nullable: true notes: type: string nullable: true created_at: type: string nullable: true updated_at: type: string nullable: true ImportOrderListItem: type: object description: An import order enriched for the buyer's tracking list. required: [id, stage, created_at] properties: id: type: string stage: $ref: "#/components/schemas/ImportOrderStage" origin_country: type: string nullable: true destination_country: type: string nullable: true budget_amount: type: number nullable: true currency: type: string nullable: true listing_title: type: string nullable: true created_at: type: string nullable: true updated_at: type: string nullable: true PromoCampaignView: type: object description: > Admin view of the promo ad-credit campaign — a SEPARATE virtual ad-only allowance auto-granted monthly to every user, tiered by verification, and use-it-or-lose-it. Not real money. required: - enabled - verified_monthly_amount - unverified_monthly_amount - duration_months - campaign_version - starts_at - status - current_month_index - months_remaining properties: enabled: type: boolean verified_monthly_amount: type: string description: Monthly allowance for verified users (2-dp EGP string). unverified_monthly_amount: type: string description: Monthly allowance for unverified users (2-dp EGP string). duration_months: type: integer description: How many monthly grants the campaign runs for. campaign_version: type: integer starts_at: type: string updated_at: type: string nullable: true updated_by: type: string nullable: true status: type: string enum: [disabled, upcoming, active, ended] current_month_index: type: integer description: Zero-based month index of the campaign (negative if upcoming). months_remaining: type: integer PromoCampaignUpdate: type: object description: > Editable promo-campaign fields. Updating amounts/duration only changes what FUTURE monthly grants give — it does not reset balances. Use the renew endpoint to start a fresh cycle. properties: enabled: type: boolean verified_monthly_amount: type: string description: Non-negative number as a string. unverified_monthly_amount: type: string description: Non-negative number as a string. duration_months: type: integer minimum: 1 maximum: 24 PromoAdSummary: type: object description: > A user's promo ad-credit standing. Promo credit is spent before the real wallet on a boost and lapses (use-it-or-lose-it) at expires_at. required: - balance - campaign_enabled - campaign_active - monthly_amount - months_remaining properties: balance: type: string description: Effective (non-expired) promo balance as a 2-dp string. expires_at: type: string nullable: true description: When the current balance lapses, or null when none/expired. campaign_enabled: type: boolean campaign_active: type: boolean monthly_amount: type: string description: The monthly allowance for THIS user's verification tier. months_remaining: type: integer AdminOverview: type: object properties: total_users: type: integer total_listings: type: integer active_listings: type: integer total_leads: type: integer open_reports: type: integer moderation_queue_count: type: integer open_tickets: type: integer revenue_mtd: type: string active_alerts: type: integer fraud_signals: type: integer error_rate: type: number WalletState: type: object required: [balance, currency] properties: balance: type: string currency: type: string enum: [EGP] WalletTransaction: type: object required: [ id, type, amount, balance_after, payment_method, reference_type, reference_id, description, created_at, ] properties: id: type: string type: type: string enum: [ wallet_topup, boost_charge, subscription_charge, lead_charge, refund, adjustment, ] amount: type: string balance_after: type: string payment_method: type: string nullable: true enum: [vodafone_cash, fawry, instapay, bank_transfer, wallet] reference_type: type: string nullable: true reference_id: type: string nullable: true description: type: string nullable: true created_at: type: string TopupIntentResult: type: object required: [intent_id, amount, method, status, provider_ref, created_at] properties: intent_id: type: string amount: type: string method: type: string enum: [vodafone_cash, fawry, instapay, bank_transfer] status: type: string enum: [pending, completed, failed, expired] provider_ref: type: string nullable: true checkout_url: type: string nullable: true description: Hosted provider checkout URL the buyer opens to pay. created_at: type: string TopupConfirmResult: type: object required: [intent_id, status, transaction_id, balance, already_processed] properties: intent_id: type: string status: type: string enum: [pending, completed, failed, expired] transaction_id: type: string nullable: true balance: type: string already_processed: type: boolean AdImpressionResult: type: object required: [counted, billable, deactivated] properties: counted: type: boolean billable: type: boolean reason: type: string deactivated: type: boolean Plan: type: object required: [ id, slug, name, name_ar, audience, is_baseline, monthly_price, listing_quota, active_listing_cap, boost_price, cpl_whatsapp, cpl_call, cpl_chat, cpl_finance_request, ranking_weight, features, sort_order, ] properties: id: type: string slug: type: string name: type: string name_ar: type: string nullable: true audience: type: string enum: [individual, dealer, company, enterprise, financial_institution] is_baseline: type: boolean monthly_price: type: string listing_quota: type: integer nullable: true active_listing_cap: type: integer nullable: true boost_price: type: string cpl_whatsapp: type: string cpl_call: type: string cpl_chat: type: string cpl_finance_request: type: string ranking_weight: type: string features: type: object nullable: true additionalProperties: type: boolean sort_order: type: integer nullable: true Subscription: type: object required: [ id, status, plan, price_paid, starts_at, expires_at, auto_renew, cancelled_at, ] properties: id: type: string status: type: string enum: [active, expired, cancelled, pending] plan: $ref: "#/components/schemas/Plan" price_paid: type: string starts_at: type: string expires_at: type: string auto_renew: type: boolean cancelled_at: type: string nullable: true SubscriptionIntentResult: type: object required: [intent_id, plan_slug, amount, method, status, provider_ref, created_at] properties: intent_id: type: string plan_slug: type: string amount: type: string method: type: string enum: [vodafone_cash, fawry, instapay, bank_transfer] status: type: string enum: [pending, completed, failed, expired] provider_ref: type: string nullable: true checkout_url: type: string nullable: true description: Hosted provider checkout URL the buyer opens to pay. created_at: type: string SubscribeResult: type: object required: [mode, subscription, intent] properties: mode: type: string enum: [active, intent] subscription: $ref: "#/components/schemas/Subscription" nullable: true intent: $ref: "#/components/schemas/SubscriptionIntentResult" nullable: true SubscriptionConfirmResult: type: object required: [intent_id, status, subscription, balance, already_processed] properties: intent_id: type: string status: type: string enum: [pending, completed, failed, expired] subscription: $ref: "#/components/schemas/Subscription" nullable: true balance: type: string already_processed: type: boolean SubscriptionUsage: type: object required: [listings_this_month, active_listings, listing_quota, active_listing_cap] properties: listings_this_month: type: integer active_listings: type: integer listing_quota: type: integer nullable: true active_listing_cap: type: integer nullable: true SubscriptionMe: type: object required: [plan, subscription, usage] properties: plan: $ref: "#/components/schemas/Plan" subscription: $ref: "#/components/schemas/Subscription" nullable: true usage: $ref: "#/components/schemas/SubscriptionUsage" InvoiceLineItem: type: object required: [label, amount] properties: label: type: string amount: type: string Invoice: type: object required: [ id, invoice_number, amount, status, transaction_id, transaction_type, description, line_items, issued_at, created_at, ] properties: id: type: string invoice_number: type: string amount: type: string status: type: string enum: [paid, void] transaction_id: type: string transaction_type: type: string nullable: true enum: [ wallet_topup, boost_charge, subscription_charge, lead_charge, refund, adjustment, ] description: type: string nullable: true line_items: type: array nullable: true items: $ref: "#/components/schemas/InvoiceLineItem" issued_at: type: string nullable: true created_at: type: string nullable: true BillingReportLine: type: object required: [type, total, count] properties: type: type: string enum: [ wallet_topup, boost_charge, subscription_charge, lead_charge, refund, adjustment, ] total: type: string count: type: integer BillingReport: type: object required: [ month, currency, total_charged, total_topped_up, transaction_count, by_type, ] properties: month: type: string currency: type: string enum: [EGP] total_charged: type: string total_topped_up: type: string transaction_count: type: integer by_type: type: array items: $ref: "#/components/schemas/BillingReportLine" Logistics: type: object description: > Additive (Task #40). Optional seller-provided logistics & delivery block on a listing. Every field is nullable; the whole object is null when the seller provided nothing. Never part of the immutable FeedItem. required: - delivery_time_days - origin_type - country_of_origin - shipping_method properties: delivery_time_days: type: integer nullable: true origin_type: type: string enum: [local, imported] nullable: true country_of_origin: type: string nullable: true shipping_method: type: string enum: [container, bulk, air] nullable: true InvestmentSummary: type: object description: > Additive (Task #40). Investment opportunity summary. A standalone entity (NOT a listing). All financial figures are seller-provided or estimates (see figures_source) and nullable — never fabricated. required: - id - owner_id - owner_name - owner_is_verified - investment_type - title - description - industry - location - total_value_amount - total_value_display - currency - expected_roi_pct - payback_years - revenue_range_min - revenue_range_max - figures_source - cover_url - status - created_at properties: id: type: string owner_id: type: string owner_name: type: string nullable: true owner_is_verified: type: boolean investment_type: type: string enum: [ factory_sale, business_sale, production_line_investment, franchise, partnership, ] title: type: string description: type: string nullable: true industry: type: string nullable: true location: type: string total_value_amount: type: string total_value_display: type: string currency: type: string expected_roi_pct: type: string nullable: true payback_years: type: string nullable: true revenue_range_min: type: string nullable: true revenue_range_max: type: string nullable: true figures_source: type: string enum: [seller_provided, estimate] cover_url: type: string nullable: true status: type: string enum: [draft, active, under_offer, closed] created_at: type: string format: date-time InvestmentDetail: allOf: - $ref: "#/components/schemas/InvestmentSummary" - type: object required: - cost_structure_note - growth_potential_note - interest_count - viewer_has_interest - viewer_is_owner properties: cost_structure_note: type: string nullable: true growth_potential_note: type: string nullable: true interest_count: type: integer viewer_has_interest: type: boolean viewer_is_owner: type: boolean CompanyDirectoryItem: type: object description: > Additive (Task #40). Suppliers directory entry with real active-listing and follower counts. is_following is viewer-relative (false when unauthenticated). required: - id - name - role - is_verified - industry - hq_country - logo_url - cover_url - active_listings - follower_count - is_following properties: id: type: string name: type: string role: type: string is_verified: type: boolean industry: type: string nullable: true hq_country: type: string nullable: true logo_url: type: string nullable: true cover_url: type: string nullable: true active_listings: type: integer follower_count: type: integer is_following: type: boolean FollowResult: type: object description: Additive (Task #40). Result of a follow/unfollow toggle. required: [following, follower_count] properties: following: type: boolean follower_count: type: integer GlobalSupplyRequest: type: object description: > Additive (Task #40). A buyer's global sourcing / import-export request. required: - id - buyer_id - buyer_name - product_text - category - industry - quantity - unit - destination_country - budget_max - currency - incoterms - notes - status - response_count - created_at properties: id: type: string buyer_id: type: string buyer_name: type: string nullable: true product_text: type: string category: type: string enum: [car, real_estate, industrial] nullable: true industry: type: string nullable: true quantity: type: string nullable: true unit: type: string nullable: true destination_country: type: string budget_max: type: string nullable: true currency: type: string incoterms: type: string nullable: true notes: type: string nullable: true status: type: string enum: [open, fulfilled, closed, cancelled] response_count: type: integer created_at: type: string format: date-time GlobalSupplyResponse: type: object description: > Additive (Task #40). A supplier's quote/response to a sourcing request. required: - id - request_id - supplier_id - supplier_name - supplier_is_verified - country_of_origin - moq - shipping_time_days - incoterms - delivery_estimate - price_quote - currency - message - status - is_mine - created_at properties: id: type: string request_id: type: string supplier_id: type: string supplier_name: type: string nullable: true supplier_is_verified: type: boolean country_of_origin: type: string nullable: true moq: type: string nullable: true shipping_time_days: type: integer nullable: true incoterms: type: string nullable: true delivery_estimate: type: string nullable: true price_quote: type: string nullable: true currency: type: string message: type: string nullable: true status: type: string enum: [pending, accepted, rejected, withdrawn] is_mine: type: boolean created_at: type: string format: date-time SupplierMatch: type: object description: > Additive (Task #40). A directory supplier ranked for a sourcing request. match_reason explains the ranking; never a fabricated score. required: [id, name, is_verified, industry, hq_country, logo_url, match_reason] properties: id: type: string name: type: string is_verified: type: boolean industry: type: string nullable: true hq_country: type: string nullable: true logo_url: type: string nullable: true match_reason: type: string GlobalSupplyDetail: allOf: - $ref: "#/components/schemas/GlobalSupplyRequest" - type: object required: [responses, supplier_matches, viewer_is_buyer] properties: responses: type: array items: $ref: "#/components/schemas/GlobalSupplyResponse" supplier_matches: type: array items: $ref: "#/components/schemas/SupplierMatch" viewer_is_buyer: type: boolean MarketTrend: type: object description: > Additive (Task #40). A single market trend computed LIVE from real listings/interactions/leads. Low samples report direction "insufficient" and data_quality "insufficient" — figures are never fabricated. required: - segment - segment_label - metric - direction - change_pct - change_display - current_value_display - period_label - sample_size - data_quality properties: segment: type: string segment_label: type: string metric: type: string enum: [avg_price, listing_volume, demand, lead_volume] direction: type: string enum: [up, down, stable, insufficient] change_pct: type: number nullable: true change_display: type: string current_value_display: type: string nullable: true period_label: type: string sample_size: type: integer data_quality: type: string enum: [high, medium, low, insufficient] MarketTrendsResult: type: object description: > Additive (Task #40). LIVE market intelligence payload. period_label + generated_at carry provenance so the client renders figures honestly. required: [trends, period_label, generated_at] properties: trends: type: array items: $ref: "#/components/schemas/MarketTrend" period_label: type: string generated_at: type: string format: date-time paths: /v1/reference/places: get: operationId: getPlaceSuggestions summary: Autocomplete suggestions from the geo/real-estate reference dataset description: >- Multilingual, typo-tolerant place suggestions (cities, districts, compounds, projects) for search / autocomplete. Matches Arabic or Latin partial names and tolerates typos; prefix + popularity rank first. Read-only reference data — creates nothing and touches no live table. tags: [reference] parameters: - in: query name: q required: true description: Query text (min 2 chars); Arabic or Latin, partial ok. schema: { type: string } - in: query name: country description: Optional ISO country code filter (e.g. EG). schema: { type: string } - in: query name: limit schema: { type: integer } responses: "200": description: Place suggestions content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/PlaceSuggestion" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /v1/me: get: operationId: getMe summary: Current authenticated user state (DB source of truth) tags: [me] security: - ClerkAuth: [] responses: "200": description: User state content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/UserState" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" patch: operationId: updateMe summary: Update current user — phone and optional Banco Business upgrade tags: [me] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object properties: account_type: type: string description: Account type chosen at onboarding. Server is authoritative for the resulting role (individual/dealer/company/financial_institution); a client can never request admin/enterprise. A financial_institution must still pass verification before its financing features unlock. enum: [individual, dealer, company, financial_institution] phone: type: string nullable: true business: type: object description: When present, upgrades the account to a Banco Business (dealer) seller. required: [activity_type, business_name, city] properties: activity_type: type: string enum: [car_dealer, real_estate_developer, factory, supplier, financial_institution] business_name: type: string trade_name: type: string description: Optional trade/brand name (الاسم التجاري) shown publicly; falls back to business_name when omitted. owner_name: type: string description: Optional name of the business owner / decision-maker, captured for verification. city: type: string documents: type: array description: Optional verification document/photo URLs (already uploaded to object storage) submitted for admin review. items: type: string format: uri fi_license_number: type: string description: > FI only. Regulator-issued licence number. Collected on the financial-institution onboarding path so a bank is never verified on the same evidence as a car dealer. fi_license_type: type: string enum: [bank, financing_company, leasing, microfinance, insurance, other] description: FI only. Kind of licence held by the institution. fi_regulator: type: string description: > FI only. Supervising authority that issued the licence (e.g. Central Bank of Egypt, FRA). A licence number is meaningless without knowing who issued it. fi_registry_number: type: string description: FI only. Registry/record number held with the regulator. responses: "200": description: Updated user state content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/UserState" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/feed: get: operationId: getFeed summary: Get adaptive scored feed tags: [feed] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 - in: query name: category schema: type: string enum: [car, real_estate, industrial] - in: query name: is_request description: >- Buyer request/wanted filter. Omit to include both sale listings and requests. true = only requests; false = only sale listings. schema: type: boolean - in: query name: industrial_type description: >- Industrial subtype filter (only meaningful with category=industrial). A single subtype or a comma-separated list (a whole group), e.g. "factory,warehouse,land". Valid subtypes: factory, warehouse, land, production_line, raw_material, machine. schema: type: string - in: query name: condition description: Filter by condition (cars). Real data via listing_attributes.condition or specs. schema: type: string enum: [new, used] - in: query name: payment_plan description: >- Payment engine filter. installment = any non-cash plan; bank = bank_finance; direct = seller_installment; islamic = sharia-compliant non-cash plan. schema: type: string enum: [installment, bank, direct, islamic] - in: query name: property_type description: Filter real-estate by property type (villa, apartment, penthouse, duplex, ...). schema: type: string - in: query name: finishing_type description: Filter real-estate by finishing level. schema: type: string - in: query name: compound description: Real-estate located inside a compound (specs.compound). schema: type: boolean - in: query name: furnished description: Furnished real-estate (specs.furnished). schema: type: boolean - in: query name: offer_type description: Real-estate offer type — sale (تمليك) or rent (إيجار), from specs.offer_type. schema: type: string enum: [sale, rent] - in: query name: rental_term description: >- Rental system within rent — the country's legal/duration regime (Egypt: furnished_daily from 1 day, new_law up to 5 years, old_law up to 59 years; Gulf: annual_contract). Free string; the catalog is client-side and grows per country. schema: type: string - in: query name: market_country description: >- ISO 3166-1 alpha-2 market country (EG, SA, …). Filters inventory by specs.market_country; listings without the key are treated as EG. schema: type: string pattern: "^[A-Za-z]{2}$" - in: query name: material description: >- Filter raw-material commodity listings by specs.material (steel, aluminum, copper, …). Free string; catalog is client-side. schema: type: string maxLength: 40 - in: query name: fuel_type description: Filter cars by fuel type (listing_attributes.fuel_type or specs). schema: type: string enum: [petrol, diesel, hybrid, electric, natural_gas] - in: query name: transmission description: Filter cars by transmission (listing_attributes.transmission or specs). schema: type: string enum: [manual, automatic, cvt] - in: query name: brand description: >- Filter cars by brand, matched against the English listing title (titles are canonical " "). schema: type: string - in: query name: model description: Filter cars by model, matched against the English listing title. schema: type: string - in: query name: min_year description: Minimum car model year (numeric specs.year). schema: type: integer - in: query name: max_year description: Maximum car model year (numeric specs.year). schema: type: integer - in: query name: industry description: Filter industrial listings by industry (listing_attributes.industry). schema: type: string enum: [food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other] - in: query name: origin_type description: Filter industrial listings by origin (listing_attributes.origin_type). schema: type: string enum: [local, imported] - in: query name: session_id schema: type: string responses: "200": description: Feed items with cursor pagination content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/uploads/request-url: post: operationId: requestUploadUrl summary: Request a presigned URL to upload listing media tags: [uploads] security: - ClerkAuth: [] requestBody: required: false content: application/json: schema: type: object properties: filename: type: string content_type: type: string size: type: integer responses: "200": description: Presigned upload URL and the public serving URL content: application/json: schema: type: object properties: data: type: object required: [upload_url, object_path, url] properties: upload_url: type: string object_path: type: string url: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/uploads/promote: post: operationId: promoteUpload summary: Promote an uploaded image to public so it can be served without auth tags: [uploads] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [url] properties: url: type: string responses: "200": description: The upload was promoted to public content: application/json: schema: type: object properties: data: type: object required: [url, promoted] properties: url: type: string promoted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/uploads/verify: post: operationId: verifyUpload summary: Confirm an uploaded asset landed in storage with a valid type and size tags: [uploads] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [url] properties: url: type: string responses: "200": description: The upload exists in storage and is within type/size limits content: application/json: schema: type: object properties: data: type: object required: [url, ok, type, content_type, size] properties: url: type: string ok: type: boolean type: type: string nullable: true enum: [image, video] content_type: type: string nullable: true size: type: integer nullable: true error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings: get: operationId: getListings summary: Browse public listings tags: [listings] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 - in: query name: category schema: type: string enum: [car, real_estate, industrial] responses: "200": description: Paginated listing feed content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createListing summary: Create listing tags: [listings] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [title, category, location, specs, media] properties: title: type: string description: type: string category: type: string enum: [car, real_estate, industrial] base_price_cash: type: number description: Required for normal sale listings. Optional when is_request is true (a buyer request). is_request: type: boolean description: When true, this is a buyer "request/wanted" post. Price (base_price_cash) becomes optional and a description is required. location: type: string latitude: type: number description: Optional precise pin (send with longitude). Overrides the area centroid for near-me search + map display. longitude: type: number description: Optional precise pin (send with latitude). specs: type: object additionalProperties: true media: type: array items: type: object properties: type: type: string enum: [image, video] url: type: string thumbnail_url: type: string is_thumbnail: type: boolean payment_options: type: array items: type: object properties: mode: type: string enum: [cash, seller_installment, bank_finance] down_payment: type: number monthly_payment: type: number duration_months: type: integer is_islamic_compliant: type: boolean # P8/M8: declared murabaha/interest rate (0-100). Engine # input only — public offers never expose it. profit_rate_pct: type: number logistics: type: object description: > Additive (Task #40). Optional seller-provided logistics & delivery block. All fields optional/nullable. properties: delivery_time_days: type: integer nullable: true origin_type: type: string enum: [local, imported] nullable: true country_of_origin: type: string nullable: true shipping_method: type: string enum: [container, bulk, air] nullable: true responses: "201": description: Created content: application/json: schema: type: object properties: data: type: object properties: id: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}: get: operationId: getListing summary: Get listing detail description: > Returns full listing detail for active listings. Non-active listings (sold, archived) are only visible to their owner; all other callers receive 404, preventing access to withdrawn inventory and seller contact details. tags: [listings] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Listing detail content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/ListingDetail" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "404": description: Not found or listing is non-active and caller is not the owner patch: operationId: updateListing summary: Update own listing (partial) tags: [listings] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: title: type: string description: type: string base_price_cash: type: number location: type: string status: type: string enum: [active, sold, archived] description: > Lifecycle status. Sellers set "sold" to mark the deal closed or "archived" to hide the listing. specs: type: object additionalProperties: true logistics: type: object description: > Additive (Task #40). Optional logistics & delivery patch. All fields optional/nullable. properties: delivery_time_days: type: integer nullable: true origin_type: type: string enum: [local, imported] nullable: true country_of_origin: type: string nullable: true shipping_method: type: string enum: [container, bulk, air] nullable: true media: type: array description: > Replace listing media in seller order. Omit to leave photos unchanged. Sale listings must keep at least one item. items: type: object required: [type, url] properties: type: type: string enum: [image, video] url: type: string format: uri thumbnail_url: type: string format: uri is_thumbnail: type: boolean width: type: integer height: type: integer responses: "200": description: Updated content: application/json: schema: type: object properties: data: type: object properties: id: type: string updated: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "404": description: Not found delete: operationId: deleteListing summary: Delete own listing tags: [listings] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Deleted content: application/json: schema: type: object properties: data: type: object properties: id: type: string deleted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "404": description: Not found /v1/listings/{id}/similar: get: operationId: getSimilarListings summary: Get similar listings tags: [listings] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Similar listings content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}/insights: get: operationId: getListingInsights summary: Market insights + deal rating for a listing description: >- How this listing's price compares to its own market segment (category + location + a per-category discriminator). Returns a deal rating, the segment's current statistics and a monthly price history. Ratings and figures appear only once the segment has enough REAL observations; otherwise rating is "insufficient_data" and the figures are null — nothing is fabricated. tags: [listings] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Deal insights content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/DealInsights" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}/availability: get: operationId: getListingAvailability summary: Booked date ranges for a furnished/daily rental description: >- The date ranges already reserved for a furnished/daily (hotel‑model) rental, so the client can grey them out on the calendar. Empty for non‑daily listings. tags: [listings] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Booked ranges content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/AvailabilityRange" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}/bookings: post: operationId: createBooking summary: Request a short‑stay booking (furnished/daily rental only) description: >- Reserve a furnished/daily real‑estate listing for a date range (hotel model). Allowed ONLY when the listing's rental_term is furnished_daily; long‑term rent and sale are not bookable. Prevents double‑booking. No payment yet — this is a request/hold. tags: [listings] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateBookingBody" responses: "200": description: Booking created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Booking" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/bookings: get: operationId: listBookings summary: My bookings — as guest or as host description: >- The signed-in user's short-stay bookings from one side. role=guest lists stays I requested; role=host lists incoming requests on listings I own. Each item carries the listing title/location and the counterparty name so the inbox renders directly. Newest first. tags: [bookings] security: - ClerkAuth: [] parameters: - in: query name: role required: false schema: type: string enum: [guest, host] default: guest responses: "200": description: My bookings content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/BookingListItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/bookings/{id}: patch: operationId: updateBooking summary: Confirm / reject / cancel a booking description: >- Drive a booking through its lifecycle with role separation. The host (listing owner) may confirm or reject a requested booking; the guest may cancel their own requested/confirmed booking. Rejecting/cancelling frees the dates. No-op success when already in the target state. tags: [bookings] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateBookingBody" responses: "200": description: Updated booking content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Booking" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/import-orders: post: operationId: createImportOrder summary: Request a car import description: >- Create a car-import order from the buyer's request. Starts at stage "order". Optionally references an existing listing; otherwise the vehicle is described free-form in details. tags: [import-orders] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateImportOrderBody" responses: "200": description: Import order created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/ImportOrder" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/import-orders/mine: get: operationId: listMyImportOrders summary: My car-import orders description: >- The signed-in buyer's car-import orders with their live stage, newest first. Powers the import-tracking screen. tags: [import-orders] security: - ClerkAuth: [] responses: "200": description: My import orders content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/ImportOrderListItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/import-orders/{id}: get: operationId: getImportOrder summary: Import order detail description: >- A single car-import order owned by the signed-in buyer, with its full stage and details for the tracking detail view. tags: [import-orders] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Import order content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/ImportOrder" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}/bump: post: operationId: bumpListing summary: Recycle (renew) a listing to the top of recency feeds description: > Owner-only. Sets bumped_at to now so the listing sorts by COALESCE(bumped_at, created_at) in recency feeds and search. NEVER changes created_at — the true publish date is preserved. Rate-limited with a cooldown; only active, publicly visible listings can be recycled. tags: [listings] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Listing recycled content: application/json: schema: type: object properties: data: type: object properties: id: type: string bumped_at: type: string description: ISO 8601 timestamp the listing was recycled to. next_bump_available_at: type: string description: ISO 8601 timestamp when the listing may be recycled again (cooldown end). error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "403": description: Caller is not the listing owner "404": description: Listing not found, or not eligible to recycle (inactive/hidden) "429": description: Cooldown has not elapsed (rate limited) /v1/search: get: operationId: searchListings summary: Full-text + filter search with Arabic NLP tags: [search] parameters: - in: query name: q description: Optional free-text query (Arabic NLP). Omit for filter-only section results. schema: type: string - in: query name: category schema: type: string enum: [car, real_estate, industrial] - in: query name: is_request description: >- Buyer request/wanted filter. Omit to include both sale listings and requests. true = only requests; false = only sale listings. schema: type: boolean - in: query name: min_price schema: type: number - in: query name: max_price schema: type: number - in: query name: location schema: type: string - in: query name: has_installment schema: type: boolean - in: query name: industrial_type description: >- Industrial subtype filter (only meaningful with category=industrial). A single subtype or a comma-separated list (a whole group), e.g. "production_line,raw_material,machine". schema: type: string - in: query name: condition description: Filter by condition (cars). Real data via listing_attributes.condition or specs. schema: type: string enum: [new, used] - in: query name: payment_plan description: >- Payment engine filter. installment = any non-cash plan; bank = bank_finance; direct = seller_installment; islamic = sharia-compliant non-cash plan. schema: type: string enum: [installment, bank, direct, islamic] - in: query name: property_type description: Filter real-estate by property type (villa, apartment, penthouse, duplex, ...). schema: type: string - in: query name: finishing_type description: Filter real-estate by finishing level. schema: type: string - in: query name: compound description: Real-estate located inside a compound (specs.compound). schema: type: boolean - in: query name: furnished description: Furnished real-estate (specs.furnished). schema: type: boolean - in: query name: offer_type description: Real-estate offer type — sale (تمليك) or rent (إيجار), from specs.offer_type. schema: type: string enum: [sale, rent] - in: query name: rental_term description: >- Rental system within rent — the country's legal/duration regime (Egypt: furnished_daily from 1 day, new_law up to 5 years, old_law up to 59 years; Gulf: annual_contract). Free string; the catalog is client-side and grows per country. schema: type: string - in: query name: market_country description: >- ISO 3166-1 alpha-2 market country (EG, SA, …). Filters inventory by specs.market_country; listings without the key are treated as EG. schema: type: string pattern: "^[A-Za-z]{2}$" - in: query name: material description: >- Filter raw-material commodity listings by specs.material (steel, aluminum, copper, …). Free string; catalog is client-side. schema: type: string maxLength: 40 - in: query name: fuel_type description: Filter cars by fuel type (listing_attributes.fuel_type or specs). schema: type: string enum: [petrol, diesel, hybrid, electric, natural_gas] - in: query name: transmission description: Filter cars by transmission (listing_attributes.transmission or specs). schema: type: string enum: [manual, automatic, cvt] - in: query name: brand description: >- Filter cars by brand, matched against the English listing title (titles are canonical " "). schema: type: string - in: query name: model description: Filter cars by model, matched against the English listing title. schema: type: string - in: query name: min_year description: Minimum car model year (numeric specs.year). schema: type: integer - in: query name: max_year description: Maximum car model year (numeric specs.year). schema: type: integer - in: query name: industry description: Filter industrial listings by industry (listing_attributes.industry). schema: type: string enum: [food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other] - in: query name: origin_type description: Filter industrial listings by origin (listing_attributes.origin_type). schema: type: string enum: [local, imported] - in: query name: near_lat description: Near-me anchor latitude (requires near_lng and radius_km). schema: type: number - in: query name: near_lng description: Near-me anchor longitude (requires near_lat and radius_km). schema: type: number - in: query name: radius_km description: Search radius in kilometres from the near-me anchor. schema: type: number minimum: 0.1 maximum: 500 - in: query name: sort description: >- Result ordering. recommended (default) and newest use the created_at keyset cursor; price_asc, price_desc and popular switch to offset pagination (their cursor is an opaque numeric offset). popular ranks by lifetime interactions (views + clicks). schema: type: string enum: [recommended, newest, price_asc, price_desc, popular] default: recommended - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Search results content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/search/map: get: operationId: getMapClusters summary: Server-side clustered listing pins for a map viewport description: >- The SAME filters as /v1/search (so the map and list stay consistent), within a viewport bounding box, aggregated into a zoom-dependent grid. Returns one cluster per occupied cell (centroid + count); listing_id is set only when a cell holds exactly one listing (a tappable pin). offer_type=rent powers the Booking-style rental map for real-estate, land and factories. tags: [search] parameters: - in: query name: min_lat required: true schema: { type: number } - in: query name: max_lat required: true schema: { type: number } - in: query name: min_lng required: true schema: { type: number } - in: query name: max_lng required: true schema: { type: number } - in: query name: zoom required: true description: Map zoom level (0-22); sets the cluster grid granularity. schema: { type: number } - in: query name: q schema: { type: string } - in: query name: category schema: { type: string, enum: [car, real_estate, industrial] } - in: query name: is_request schema: { type: boolean } - in: query name: min_price schema: { type: number } - in: query name: max_price schema: { type: number } - in: query name: location schema: { type: string } - in: query name: has_installment schema: { type: boolean } - in: query name: industrial_type schema: { type: string } - in: query name: condition schema: { type: string, enum: [new, used] } - in: query name: payment_plan schema: { type: string, enum: [installment, bank, direct, islamic] } - in: query name: property_type schema: { type: string } - in: query name: finishing_type schema: { type: string } - in: query name: compound schema: { type: boolean } - in: query name: furnished schema: { type: boolean } - in: query name: offer_type description: sale (تمليك) or rent (إيجار). schema: { type: string, enum: [sale, rent] } - in: query name: rental_term description: Rental regime (furnished_daily / new_law / old_law / annual_contract). schema: { type: string } - in: query name: market_country description: ISO market country (EG, SA, …); missing specs coalesce to EG. schema: { type: string, pattern: "^[A-Za-z]{2}$" } - in: query name: material description: Commodity material filter (specs.material) — free string. schema: { type: string, maxLength: 40 } - in: query name: fuel_type schema: { type: string, enum: [petrol, diesel, hybrid, electric, natural_gas] } - in: query name: transmission schema: { type: string, enum: [manual, automatic, cvt] } - in: query name: brand schema: { type: string } - in: query name: model schema: { type: string } - in: query name: min_year schema: { type: integer } - in: query name: max_year schema: { type: integer } - in: query name: industry schema: { type: string, enum: [food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other] } - in: query name: origin_type schema: { type: string, enum: [local, imported] } - in: query name: near_lat description: Near-me anchor latitude (requires near_lng and radius_km). schema: { type: number } - in: query name: near_lng description: Near-me anchor longitude (requires near_lat and radius_km). schema: { type: number } - in: query name: radius_km description: Search radius in kilometres from the near-me anchor. schema: { type: number, minimum: 0.1, maximum: 500 } responses: "200": description: Map clusters content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/MapCluster" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/search/facets: get: operationId: getFacets summary: Per-value counts of the currently-visible inventory description: >- Counts of active, publicly-visible listings grouped by each filterable attribute, optionally scoped to a category. Each count uses the same column/specs matching logic as the search filters, so a chip's badge count equals the size of the result set that chip produces. Clients gate filter chips on count > 0 to avoid offering filters that return nothing. tags: [search] parameters: - in: query name: category description: Scope counts to a single category (the category facet stays unscoped). schema: type: string enum: [car, real_estate, industrial] responses: "200": description: Facet counts content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FacetCounts" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/search/autocomplete: get: operationId: getAutocomplete summary: Autocomplete suggestions tags: [search] parameters: - in: query name: q required: true schema: type: string responses: "200": description: Suggestions content: application/json: schema: type: object properties: data: type: array items: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/search/trending: get: operationId: getTrending summary: Trending listings by engagement score tags: [search] responses: "200": description: Trending content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/search/recommendations: get: operationId: getRecommendations summary: Personalized recommendations tags: [search] security: - ClerkAuth: [] responses: "200": description: Recommendations content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/leads/contact: post: operationId: contactLead summary: Record a contact lead and reveal seller phone description: > Atomically validates the single-use contact_token minted by GET /v1/listings/:id, records the lead, and returns the seller's phone number. The token is bound to the authenticated caller and the listing; it expires after 30 minutes and can only be used once. Returns 403 if the token is missing, expired, already used, or bound to a different caller or listing. tags: [leads] security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: [listing_id, action_type, contact_token] properties: listing_id: type: string action_type: type: string enum: [whatsapp, call, chat, finance_request] buyer_name: type: string buyer_phone: type: string contact_token: type: string format: uuid description: Single-use token from GET /v1/listings/:id responses: "200": description: Lead recorded; seller phone returned content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object nullable: true properties: phone: type: string nullable: true error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "403": description: Invalid, expired, or already-used contact token /v1/leads/signal: post: operationId: sendBehaviorSignal summary: Send session behavior signal tags: [leads] requestBody: required: true content: application/json: schema: type: object required: [session_id, action] properties: session_id: type: string listing_id: type: string action: type: string enum: [view, click, scroll_fast, scroll_slow, category_tap, open_detail, interested, angry] category: type: string enum: [car, real_estate, industrial] price: type: number responses: "200": description: Signal received content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [received] properties: received: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/saves/toggle: post: operationId: toggleSaveListing summary: Save or unsave a listing tags: [saves] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [listing_id] properties: listing_id: type: string responses: "200": description: Toggle result content: application/json: schema: type: object properties: data: type: object properties: saved: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/saves: get: operationId: getSavedListings summary: Get saved listing IDs tags: [saves] security: - ClerkAuth: [] responses: "200": description: Saved IDs content: application/json: schema: type: object properties: data: type: array items: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/conversations: get: operationId: listConversations summary: List my conversations (inbox) tags: [conversations] security: - ClerkAuth: [] responses: "200": description: Conversation inbox content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/ConversationSummary" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createConversation summary: Start (or fetch existing) a conversation on a listing tags: [conversations] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [listing_id] properties: listing_id: type: string responses: "200": description: Conversation content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/ConversationSummary" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/conversations/{id}: delete: operationId: deleteConversation summary: Hide a conversation from my inbox (per-participant) tags: [conversations] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Delete result content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [deleted] properties: deleted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/conversations/{id}/messages: get: operationId: getMessages summary: Get messages in a conversation tags: [conversations] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Messages (chronological ascending) content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/Message" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: sendMessage summary: Send a message in a conversation tags: [conversations] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [body] properties: body: type: string media_url: type: string nullable: true description: > Optional single attachment URL (from /v1/uploads/request-url). When set, body may be empty. media_kind: type: string nullable: true enum: [image, video, audio] description: Attachment kind for the renderer. reply_to_id: type: string nullable: true description: Reply target — a message in the same conversation. listing_ref_id: type: string nullable: true description: A listing to share as a card (body may be empty). responses: "200": description: The created message content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/Message" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/conversations/{id}/messages/{messageId}/react: post: operationId: reactToMessage summary: Toggle an emoji reaction on a message tags: [conversations] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string - name: messageId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [emoji] properties: emoji: type: string description: Allowlisted emoji to toggle for the viewer. responses: "200": description: Updated reaction counts content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/ReactionResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/conversations/{id}/read: post: operationId: markConversationRead summary: Mark a conversation's messages as read for the viewer tags: [conversations] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Read result content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [read] properties: read: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/notifications: get: operationId: listNotifications summary: List my in-app notifications tags: [notifications] security: - ClerkAuth: [] responses: "200": description: Notifications (newest first) with unread count in meta.total content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/Notification" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/notifications/read: post: operationId: markNotificationsRead summary: Mark notifications read (all, or a single id) tags: [notifications] security: - ClerkAuth: [] requestBody: required: false content: application/json: schema: type: object properties: id: type: string responses: "200": description: Read result content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [read] properties: read: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/notifications/push-token: post: operationId: registerPushToken summary: Register this device's Expo push token for remote notifications tags: [notifications] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [token] properties: token: type: string platform: type: string enum: [ios, android, web] nullable: true responses: "200": description: Registration result content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [registered] properties: registered: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" delete: operationId: unregisterPushToken summary: Remove this device's Expo push token (e.g. on sign-out) tags: [notifications] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [token] properties: token: type: string responses: "200": description: Removal result content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [removed] properties: removed: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/metrics: get: operationId: getMyMetrics summary: Real seller metrics for my profile (listings, response rate, active since) tags: [me] security: - ClerkAuth: [] responses: "200": description: My seller metrics (real, computed — never faked) content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/CompanyStats" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/listings: get: operationId: getMyListings summary: The caller's own listings (role-agnostic) for the profile grid tags: [me] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated owner listings (FeedItem contract) content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/listings/manage: get: operationId: getMyManagedListings summary: The caller's own listings with management fields (role-agnostic) tags: [me] security: - ClerkAuth: [] parameters: - in: query name: status schema: type: string enum: [active, sold, archived] - in: query name: sort schema: type: string enum: [created_at, price, views, leads] - in: query name: order schema: type: string enum: [asc, desc] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated owner listings with management fields content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/DealerListing" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/ai/assistant: post: operationId: askBancoAssistant summary: Ask the BANCO AI assistant (server-side, grounded in real context only) tags: [me] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AiAssistantBody" responses: "200": description: Assistant reply (grounded in real BANCO data; never invents numbers) content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/AiAssistantResponse" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/social-links: get: operationId: getMySocialLinks summary: Get my profile social links tags: [me] security: - ClerkAuth: [] responses: "200": description: My social links content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/SocialLink" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" put: operationId: setMySocialLinks summary: Replace my full set of social links tags: [me] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [links] properties: links: type: array items: $ref: "#/components/schemas/SocialLink" responses: "200": description: Updated social links content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/SocialLink" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/notification-preferences: get: operationId: getMyNotificationPreferences summary: Get my per-category notification preferences tags: [me] security: - ClerkAuth: [] responses: "200": description: My notification preferences (defaults applied for missing categories) content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/NotificationPreference" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" put: operationId: setMyNotificationPreferences summary: Update my notification preferences (mute/unmute categories) tags: [me] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [preferences] properties: preferences: type: array items: $ref: "#/components/schemas/NotificationPreference" responses: "200": description: Updated notification preferences content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/NotificationPreference" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/saved-searches: get: operationId: listMySavedSearches summary: List my saved searches tags: [me] security: - ClerkAuth: [] responses: "200": description: My saved searches (newest first) content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/SavedSearch" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createSavedSearch summary: Save a search (with optional price tracking + alerts) tags: [me] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [name] properties: name: type: string query: type: string nullable: true category: type: string enum: [car, real_estate, industrial] nullable: true filters: type: object additionalProperties: true nullable: true price_min: type: string nullable: true price_max: type: string nullable: true alerts_enabled: type: boolean responses: "200": description: The created saved search content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/SavedSearch" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/saved-searches/{id}: patch: operationId: updateSavedSearch summary: Update a saved search (rename, toggle alerts, adjust price range) tags: [me] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: name: type: string price_min: type: string nullable: true price_max: type: string nullable: true alerts_enabled: type: boolean responses: "200": description: The updated saved search content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/SavedSearch" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" delete: operationId: deleteSavedSearch summary: Delete a saved search tags: [me] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Delete result content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [deleted] properties: deleted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/stories: get: operationId: listStories summary: List active (non-expired) stories for the rail tags: [stories] security: - ClerkAuth: [] - {} responses: "200": description: Active stories, newest first. `seen` is per-viewer. content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/Story" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createStory summary: Publish a 24h story tags: [stories] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [media_url] properties: media_url: type: string listing_id: type: string caption: type: string responses: "201": description: Created story content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/Story" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/stories/{id}/view: post: operationId: viewStory summary: Mark a story as viewed by the current user tags: [stories] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: View recorded content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [viewed] properties: viewed: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/users/me: delete: operationId: deleteAccount summary: Delete the authenticated user's account (Google Play compliance) tags: [users] security: - ClerkAuth: [] responses: "200": description: Account deleted content: application/json: schema: type: object required: [data, error, meta] properties: data: type: object required: [deleted] properties: deleted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/stats: get: operationId: getDealerStats summary: Dealer dashboard stats tags: [dealer] security: - ClerkAuth: [] responses: "200": description: Stats content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/DealerStats" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/analytics: get: operationId: getDealerAnalytics summary: 30-day analytics tags: [dealer] security: - ClerkAuth: [] responses: "200": description: Analytics content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/DealerStats" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/listings: get: operationId: getDealerListings summary: Dealer's own listings tags: [dealer] security: - ClerkAuth: [] parameters: - in: query name: status schema: type: string enum: [active, sold, archived] - in: query name: sort schema: type: string enum: [created_at, price, views, leads] - in: query name: order schema: type: string enum: [asc, desc] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Listings content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/DealerListing" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/listings/bulk: post: operationId: dealerBulkAction summary: Bulk listing action tags: [dealer] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [listing_ids, action] properties: listing_ids: type: array items: type: string action: type: string enum: [activate, archive, delete] responses: "200": description: Done /v1/dealer/listings/boost: post: operationId: boostListing summary: Boost listing as sponsored ad tags: [dealer] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [listing_id] properties: listing_id: type: string ad_type: type: string enum: [featured, native_feed, top_search] duration_days: type: integer default: 7 idempotency_key: type: string description: > Optional client-supplied key. Retrying a boost with the same key returns the original ad without re-consuming promo credit or re-charging the wallet. responses: "200": description: Boost created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/BoostResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/listings/import: post: operationId: bulkImportListings summary: Bulk import from CSV tags: [dealer] security: - ClerkAuth: [] requestBody: required: true content: text/csv: schema: type: string format: binary responses: "200": description: Import result content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/ImportResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/leads: get: operationId: getDealerLeads summary: Dealer CRM leads tags: [dealer] security: - ClerkAuth: [] parameters: - in: query name: status schema: type: string enum: [new, contacted, closed] - in: query name: action_type schema: type: string enum: [whatsapp, call, chat, finance_request] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Leads content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Lead" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/dealer/leads/{id}: patch: operationId: updateLeadStatus summary: Update lead status tags: [dealer] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [status] properties: status: type: string enum: [new, contacted, closed] responses: "200": description: Updated # ── PUBLIC: user-submitted reports & support tickets ────────────────── /v1/reports: post: operationId: createReport summary: Report a listing (fake price, scam, wrong data, duplicate) tags: [reports] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [listing_id, reason] properties: listing_id: type: string reason: type: string enum: [fake_price, wrong_data, scam, duplicate, other] details: type: string responses: "200": description: Report created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Report" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/support/tickets: post: operationId: createSupportTicket summary: Open a support ticket tags: [support] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [subject, message] properties: subject: type: string message: type: string category: type: string responses: "200": description: Ticket created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SupportTicket" error: $ref: "#/components/schemas/ApiError" nullable: true # ── WALLET & BILLING (consumer) ─────────────────────────────────────── /v1/wallet: get: operationId: getWallet summary: Get wallet balance tags: [wallet] security: - ClerkAuth: [] responses: "200": description: Wallet balance content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/WalletState" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/wallet/promo: get: operationId: getPromoAdSummary summary: Get the user's promo ad-credit standing description: > Returns the user's effective (non-expired) promo ad-credit balance, its expiry, and the active campaign tier. Promo credit is spent before the real wallet on a boost. tags: [wallet] security: - ClerkAuth: [] responses: "200": description: Promo ad-credit summary content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PromoAdSummary" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/wallet/transactions: get: operationId: listTransactions summary: List wallet transactions (ledger) tags: [wallet] security: - ClerkAuth: [] parameters: - name: cursor in: query required: false schema: type: string - name: limit in: query required: false schema: type: integer minimum: 1 maximum: 50 default: 20 - name: from in: query required: false description: ISO-8601 lower bound (inclusive) on created_at schema: type: string format: date-time - name: to in: query required: false description: ISO-8601 upper bound (inclusive) on created_at schema: type: string format: date-time - name: type in: query required: false schema: type: string enum: [ wallet_topup, boost_charge, subscription_charge, lead_charge, refund, adjustment, ] responses: "200": description: Transaction page content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/WalletTransaction" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/wallet/topup: post: operationId: createTopup summary: Create a wallet top-up payment intent tags: [wallet] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [amount, method] properties: amount: type: number method: type: string enum: [vodafone_cash, fawry, instapay, bank_transfer] responses: "200": description: Top-up intent created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/TopupIntentResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/wallet/topup/{id}/confirm: post: operationId: confirmTopup summary: Confirm a wallet top-up payment intent tags: [wallet] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Top-up confirmation result content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/TopupConfirmResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/subscriptions/plans: get: operationId: listPlans summary: List subscription plans available to the caller's role tags: [subscriptions] security: - ClerkAuth: [] responses: "200": description: Plans content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Plan" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/subscriptions/me: get: operationId: getMySubscription summary: Effective plan, active subscription, and usage against quotas tags: [subscriptions] security: - ClerkAuth: [] responses: "200": description: Subscription state content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SubscriptionMe" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/subscriptions: post: operationId: subscribe summary: Subscribe to a plan (wallet charge or external payment intent) tags: [subscriptions] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [plan_slug] properties: plan_slug: type: string payment_method: type: string enum: [wallet, vodafone_cash, fawry, instapay, bank_transfer] default: wallet responses: "200": description: Subscription started or intent created content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SubscribeResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/subscriptions/intents/{id}/confirm: post: operationId: confirmSubscription summary: Confirm a pending subscription payment intent tags: [subscriptions] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Subscription confirmation result content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SubscriptionConfirmResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/subscriptions/cancel: post: operationId: cancelSubscription summary: Cancel the active subscription (stays active until expiry) tags: [subscriptions] security: - ClerkAuth: [] responses: "200": description: Cancelled subscription content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Subscription" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/billing/invoices: get: operationId: listInvoices summary: List the caller's invoices (newest first) tags: [billing] security: - ClerkAuth: [] parameters: - name: cursor in: query required: false schema: type: string - name: limit in: query required: false schema: type: integer minimum: 1 maximum: 50 default: 20 responses: "200": description: Invoice page content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Invoice" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/billing/invoices/{id}/pdf: get: operationId: getInvoicePdf summary: Download a PDF copy of an invoice the caller owns tags: [billing] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string format: uuid responses: "200": description: Invoice PDF content: application/pdf: schema: type: string format: binary "404": description: Invoice not found /v1/billing/invoices/{id}: get: operationId: getInvoice summary: Get a single invoice the caller owns tags: [billing] security: - ClerkAuth: [] parameters: - name: id in: path required: true schema: type: string responses: "200": description: Invoice content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Invoice" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/billing/report.csv: get: operationId: getBillingReportCsv summary: Monthly billing summary as CSV (ledger breakdown) tags: [billing] security: - ClerkAuth: [] parameters: - name: month in: query required: false description: Report month as YYYY-MM (UTC). Defaults to the current month. schema: type: string responses: "200": description: Billing report CSV content: text/csv: schema: type: string /v1/billing/report: get: operationId: getBillingReport summary: Monthly billing summary computed from the ledger tags: [billing] security: - ClerkAuth: [] parameters: - name: month in: query required: false description: Report month as YYYY-MM (UTC). Defaults to the current month. schema: type: string responses: "200": description: Billing report content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/BillingReport" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/ads/{id}/impression: post: operationId: adImpression summary: Record an ad impression for a sponsored listing tags: [ads] parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [session_id] properties: session_id: type: string device_id: type: string responses: "200": description: Impression result content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdImpressionResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" # ── ADMIN CONTROL CENTER (admin-only) ───────────────────────────────── /v1/admin/overview: get: operationId: getAdminOverview summary: Admin dashboard KPIs tags: [admin] security: - ClerkAuth: [] responses: "200": description: Overview content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminOverview" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/users: get: operationId: getAdminUsers summary: List all users tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: search schema: type: string - in: query name: role schema: type: string enum: [individual, dealer, company, enterprise, financial_institution] - in: query name: banned schema: type: boolean - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Users content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/AdminUser" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/users/{id}/ban: post: operationId: setUserBan summary: Ban or unban (shadow-ban) a user tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [banned] properties: banned: type: boolean reason: type: string responses: "200": description: Updated content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminUser" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/users/{id}/role: post: operationId: setUserRole summary: Assign a staff role to a user description: > Sets the internal staff role (owner/admin/moderator/support/user). Requires the `manage_roles` permission. Guards prevent changing your own role and removing the last Owner. tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [role] properties: role: type: string enum: [owner, admin, moderator, support, user] responses: "200": description: Updated content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminUser" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/users/{id}/verify: post: operationId: setUserVerified summary: Set a user's verified status description: Requires the `verify_users` permission. tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [verified] properties: verified: type: boolean responses: "200": description: Updated content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminUser" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/listings: get: operationId: getAdminListings summary: List all listings (any status) tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: search schema: type: string - in: query name: status schema: type: string enum: [active, sold, archived, draft, pending_approval, pending_review, approved, rejected, flagged] - in: query name: flagged schema: type: boolean - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Listings content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/AdminListing" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/moderation/queue: get: operationId: getModerationQueue summary: Listings needing review (flagged / pending / reported) tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Moderation queue content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/AdminListing" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/listings/{id}/moderate: post: operationId: moderateListing summary: Take a moderation action on a listing tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [action] properties: action: type: string enum: [approve, reject, archive, flag, unflag] reason: type: string responses: "200": description: Moderated content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminListing" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/leads: get: operationId: getAdminLeads summary: Global lead activity tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: action_type schema: type: string enum: [whatsapp, call, chat, finance_request] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Leads content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Lead" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/financing/requests: get: operationId: getFinancingRequests summary: Bank-financing CRM — list finance requests tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: category schema: type: string enum: [car, real_estate, industrial] - in: query name: status schema: type: string enum: [new, forwarded, contacted, closed, rejected] - in: query name: search schema: type: string - in: query name: date_from schema: type: string - in: query name: date_to schema: type: string - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Financing requests content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FinancingRequest" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/financing/requests/export: get: operationId: exportFinancingRequests summary: Bank-financing CRM — export filtered requests as CSV tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: category schema: type: string enum: [car, real_estate, industrial] - in: query name: status schema: type: string enum: [new, forwarded, contacted, closed, rejected] - in: query name: search schema: type: string - in: query name: date_from schema: type: string - in: query name: date_to schema: type: string responses: "200": description: CSV export content: text/csv: schema: type: string /v1/admin/financing/requests/{leadId}: patch: operationId: updateFinancingRequest summary: Bank-financing CRM — update status / intermediary assignment tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: leadId required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: status: type: string enum: [new, forwarded, contacted, closed, rejected] intermediary_id: type: string nullable: true notes: type: string nullable: true responses: "200": description: Updated financing request content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FinancingRequest" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/financing/intermediaries: get: operationId: getFinancingIntermediaries summary: Bank-financing CRM — list intermediary (bank/financier) accounts tags: [admin] security: - ClerkAuth: [] responses: "200": description: Intermediaries content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FinancingIntermediary" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createFinancingIntermediary summary: Bank-financing CRM — add an intermediary account tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [name] properties: name: type: string contact_email: type: string nullable: true contact_phone: type: string nullable: true notes: type: string nullable: true responses: "200": description: Created intermediary content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FinancingIntermediary" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/financing/intermediaries/{id}: patch: operationId: updateFinancingIntermediary summary: Bank-financing CRM — update / deactivate an intermediary account tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: name: type: string contact_email: type: string nullable: true contact_phone: type: string nullable: true notes: type: string nullable: true is_active: type: boolean owner_user_id: type: string format: uuid nullable: true description: >- FI phase 2 — link (or null to unlink) the bank's own marketplace account; enables the automatic hand-off of forwarded requests to the bank's people. responses: "200": description: Updated intermediary content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FinancingIntermediary" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/financing/intermediaries/{id}/branches: parameters: - in: path name: id required: true schema: type: string get: operationId: getFinancingBranches summary: FI phase 2 — an institution's branches tags: [admin] security: - ClerkAuth: [] responses: "200": description: Branches content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FinancingBranch" error: $ref: "#/components/schemas/ApiError" nullable: true post: operationId: createFinancingBranch summary: FI phase 2 — add a branch to an institution tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [name] properties: name: type: string city: type: string nullable: true responses: "200": description: Created branch content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FinancingBranch" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/financing/intermediaries/{id}/seats: parameters: - in: path name: id required: true schema: type: string get: operationId: getFinancingSeats summary: FI phase 2 — an institution's employee seats tags: [admin] security: - ClerkAuth: [] responses: "200": description: Seats content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FinancingSeat" error: $ref: "#/components/schemas/ApiError" nullable: true post: operationId: createFinancingSeat summary: FI phase 2 — seat a marketplace user inside an institution tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [user_id] properties: user_id: type: string format: uuid branch_id: type: string format: uuid nullable: true role: type: string enum: [manager, agent] responses: "200": description: Created seat content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FinancingSeat" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/financing/inbox: get: operationId: getInstitutionInbox summary: >- FI phase 2 — the bank's own inbox: requests Banco forwarded to the caller's institution after its risk review. Owner/manager see all; an agent seat is scoped to its branch plus unrouted requests. tags: [financing] security: - ClerkAuth: [] parameters: - in: query name: status schema: type: string enum: [forwarded, contacted, closed] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Institution inbox content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/InstitutionInbox" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/financing/inbox/{leadId}: patch: operationId: updateInstitutionRequest summary: >- FI phase 2 — bank-side lifecycle: mark a forwarded request contacted or closed, and (owner/manager only) route it to a branch. tags: [financing] security: - ClerkAuth: [] parameters: - in: path name: leadId required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: status: type: string enum: [contacted, closed] branch_id: type: string format: uuid nullable: true responses: "200": description: Updated request content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FinancingRequest" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/ads: get: operationId: getAdminAds summary: All ad campaigns tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Ads content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Ad" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/reports: get: operationId: getAdminReports summary: List listing reports tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: status schema: type: string enum: [open, reviewing, resolved, dismissed] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Reports content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Report" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/reports/{id}/resolve: post: operationId: resolveReport summary: Resolve or dismiss a report tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [status] properties: status: type: string enum: [resolved, dismissed, reviewing] note: type: string responses: "200": description: Resolved content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Report" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/support/tickets: get: operationId: getSupportTickets summary: List support tickets tags: [admin] security: - ClerkAuth: [] parameters: - in: query name: status schema: type: string enum: [open, closed] - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer responses: "200": description: Tickets content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/SupportTicket" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/admin/support/tickets/{id}: get: operationId: getSupportTicket summary: Get a support ticket with its messages tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Ticket content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SupportTicket" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/support/tickets/{id}/respond: post: operationId: respondSupportTicket summary: Post an admin reply to a ticket tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [message] properties: message: type: string responses: "200": description: Ticket updated content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SupportTicket" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/support/tickets/{id}/resolve: post: operationId: resolveSupportTicket summary: Open or close a support ticket tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [status] properties: status: type: string enum: [open, closed] responses: "200": description: Ticket updated content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/SupportTicket" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/revenue: get: operationId: getAdminRevenue summary: Revenue summary across channels tags: [admin] security: - ClerkAuth: [] responses: "200": description: Revenue content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/RevenueSummary" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/analytics: get: operationId: getAdminAnalytics summary: Marketplace analytics tags: [admin] security: - ClerkAuth: [] responses: "200": description: Analytics content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminAnalytics" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/fraud-signals: get: operationId: getFraudSignals summary: Fraud & abuse signals tags: [admin] security: - ClerkAuth: [] responses: "200": description: Fraud signals content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FraudSignal" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/alerts: get: operationId: getAdminAlerts summary: Operational alerts tags: [admin] security: - ClerkAuth: [] responses: "200": description: Alerts content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Alert" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/monitoring: get: operationId: getAdminMonitoring summary: System health & performance metrics tags: [admin] security: - ClerkAuth: [] responses: "200": description: Monitoring content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/Monitoring" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/payment-config: get: operationId: getPaymentConfig summary: Read the masked payment-provider configuration description: > Returns the admin-editable PSP configuration with all secret material redacted. Raw secret keys / HMAC secrets are NEVER returned. tags: [admin] security: - ClerkAuth: [] responses: "200": description: Masked payment config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PaymentConfigView" error: $ref: "#/components/schemas/ApiError" nullable: true put: operationId: updatePaymentConfig summary: Create or update the payment-provider configuration description: > Upserts the PSP configuration. Secret fields are write-only: omit or send an empty string to keep the stored value. Returns the masked view. tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PaymentConfigUpdate" responses: "200": description: Updated, masked payment config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PaymentConfigView" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/payment-config/test: post: operationId: testPaymentConfig summary: Test the saved payment-provider connection description: > Opens a throwaway intention against the gateway using the saved credentials (ignores the enabled flag) to validate them. No money moves. tags: [admin] security: - ClerkAuth: [] responses: "200": description: Connection test result content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PaymentConfigTestResult" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/email-config: get: operationId: getEmailConfig summary: Read the masked email-provider (Resend) configuration description: > Returns the admin view of the transactional-email provider config. The API key is never returned — only whether one is stored and which transport is currently active (real Resend delivery vs honest log-only). tags: [admin] security: - ClerkAuth: [] responses: "200": description: Email provider config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/EmailConfigView" error: $ref: "#/components/schemas/ApiError" nullable: true put: operationId: updateEmailConfig summary: Create or update the email-provider configuration description: > Upserts the Resend config. The API key is write-only — omit or send an empty string to keep the stored value. Non-secret fields are applied when present (empty string clears an optional field). tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/EmailConfigUpdate" responses: "200": description: Updated email provider config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/EmailConfigView" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/email-config/test: post: operationId: testEmailConfig summary: Validate the saved email-provider key description: > Validates the stored Resend API key against the provider (ignores the enabled flag). With no key configured it reports the honest log-only state rather than failing. No email is sent. tags: [admin] security: - ClerkAuth: [] responses: "200": description: Email connection test result content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/EmailConfigTestResult" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/promo-campaign: get: operationId: getPromoCampaign summary: Read the promo ad-credit campaign configuration description: > Returns the admin view of the monthly promo ad-credit campaign, including its current status and remaining months. tags: [admin] security: - ClerkAuth: [] responses: "200": description: Promo campaign config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PromoCampaignView" error: $ref: "#/components/schemas/ApiError" nullable: true put: operationId: updatePromoCampaign summary: Create or update the promo ad-credit campaign description: > Upserts the campaign config. Changing amounts/duration affects only FUTURE monthly grants; it does not reset balances or bump the version. tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PromoCampaignUpdate" responses: "200": description: Updated promo campaign config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PromoCampaignView" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/promo-campaign/renew: post: operationId: renewPromoCampaign summary: Start a fresh promo ad-credit campaign cycle description: > Bumps the campaign version, re-anchors the start to now, optionally applies config overrides, and resets every user's promo balance to 0. The next daily cycle then grants month 0 of the new version. tags: [admin] security: - ClerkAuth: [] requestBody: required: false content: application/json: schema: $ref: "#/components/schemas/PromoCampaignUpdate" responses: "200": description: Renewed promo campaign config content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/PromoCampaignView" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/plans: get: operationId: getAdminPlans summary: List all subscription plans (admin) description: > Every plan across all audiences and statuses — the platform's economic levers (pricing, quotas, cost-per-lead, boost, ranking, features). tags: [admin] security: - ClerkAuth: [] responses: "200": description: Plans content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/AdminPlan" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createAdminPlan summary: Create a subscription plan tags: [admin] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminPlanCreate" responses: "200": description: Created plan content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminPlan" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/admin/plans/{id}: patch: operationId: updateAdminPlan summary: Update a subscription plan tags: [admin] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminPlanUpdate" responses: "200": description: Updated plan content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/AdminPlan" error: $ref: "#/components/schemas/ApiError" nullable: true /v1/listings/{id}/links: post: operationId: createListingLink summary: Create a supply-chain link from a listing you own (Task #33) tags: [listings] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [to_listing_id, relation] properties: to_listing_id: type: string relation: type: string enum: [feeds_into, part_of, compatible_with] responses: "201": description: Link created (or already existed) content: application/json: schema: type: object properties: data: type: object required: [id, created] properties: id: type: string created: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}/comments: get: operationId: getListingComments summary: Public Q&A thread for a listing (Task #39) tags: [comments] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: The listing's comments (chronological ascending) content: application/json: schema: type: object required: [data, error, meta] properties: data: type: array items: $ref: "#/components/schemas/Comment" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createListingComment summary: Ask a question or reply on a listing (Task #39) tags: [comments] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CommentBody" responses: "200": description: The created comment content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/Comment" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/listings/{id}/comments/{commentId}: delete: operationId: deleteListingComment summary: Delete a comment — author or listing owner only tags: [comments] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string - in: path name: commentId required: true schema: type: string responses: "200": description: The comment was deleted content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/CommentDeleteResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/sellers/{id}/reviews: get: operationId: getSellerReviews summary: Public reviews + aggregate for a seller (Task #39) tags: [reviews] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Seller reviews with summary and viewer eligibility content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/ReviewsResponse" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createSellerReview summary: Create or update your review of a seller (Task #39) tags: [reviews] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReviewBody" responses: "200": description: The created/updated review content: application/json: schema: type: object required: [data, error, meta] properties: data: $ref: "#/components/schemas/SellerReview" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/companies/{id}: get: operationId: getCompany summary: Public company / supplier profile (Task #33) tags: [companies] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Company profile with public stats content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/CompanyProfile" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/companies/{id}/listings: get: operationId: getCompanyListings summary: Public active listings for a company (Task #33) tags: [companies] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated company listings (FeedItem contract) content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/FeedItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/company: patch: operationId: updateMyCompany summary: Upsert the caller's rich B2B company profile (Task #33) tags: [companies] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object properties: about: type: string nullable: true year_established: type: integer nullable: true countries_import_from: type: array items: type: string countries_export_to: type: array items: type: string min_order_value: type: number nullable: true min_order_unit: type: string nullable: true monthly_capacity: type: string nullable: true lead_time_days: type: integer nullable: true certifications: type: array items: type: string website_url: type: string nullable: true logo_url: type: string nullable: true cover_url: type: string nullable: true industry: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] nullable: true hq_country: type: string nullable: true responses: "200": description: Update result content: application/json: schema: type: object properties: data: type: object required: [updated] properties: updated: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/rfqs: get: operationId: listRfqs summary: List open RFQs with optional filters (Task #33) tags: [rfqs] security: - {} - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 - in: query name: category schema: type: string enum: [car, real_estate, industrial] - in: query name: industry schema: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] - in: query name: industrial_type schema: type: string enum: [factory, warehouse, machine, production_line, land, raw_material] responses: "200": description: Paginated open RFQs content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Rfq" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createRfq summary: Create an RFQ (Task #33) tags: [rfqs] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [title] properties: category: type: string enum: [car, real_estate, industrial] default: industrial title: type: string description: type: string quantity: type: number unit: type: string target_price_max: type: number destination_country: type: string industry: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] industrial_type: type: string enum: [factory, warehouse, machine, production_line, land, raw_material] deadline: type: string format: date-time responses: "201": description: Created RFQ id content: application/json: schema: type: object properties: data: type: object required: [id] properties: id: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/rfqs/mine: get: operationId: listMyRfqs summary: List RFQs created by the caller (Task #33) tags: [rfqs] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated own RFQs content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/Rfq" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/rfqs/{id}: get: operationId: getRfq summary: RFQ detail with visibility-scoped offers (Task #33) tags: [rfqs] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: RFQ detail content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/RfqDetail" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/rfqs/{id}/offers: post: operationId: submitRfqOffer summary: Submit (or update) the caller's offer on an RFQ (Task #33) tags: [rfqs] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: [price_quote] properties: price_quote: type: number currency: type: string default: EGP lead_time_days: type: integer moq: type: number message: type: string responses: "201": description: Offer submitted content: application/json: schema: type: object properties: data: type: object required: [id, submitted] properties: id: type: string submitted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/rfqs/{id}/offers/{offerId}/accept: post: operationId: acceptRfqOffer summary: Accept an offer (buyer only); awards the RFQ (Task #33) tags: [rfqs] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string - in: path name: offerId required: true schema: type: string responses: "200": description: Offer accepted, RFQ awarded content: application/json: schema: type: object properties: data: type: object required: [rfq_id, offer_id, awarded] properties: rfq_id: type: string offer_id: type: string awarded: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/investments: get: operationId: listInvestments summary: List open investment opportunities (Task #40) tags: [investments] security: - {} - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 - in: query name: investment_type schema: type: string enum: [ factory_sale, business_sale, production_line_investment, franchise, partnership, ] - in: query name: industry schema: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] - in: query name: location schema: type: string - in: query name: status schema: type: string enum: [draft, active, under_offer, closed] responses: "200": description: Paginated investment opportunities content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/InvestmentSummary" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createInvestment summary: Create an investment opportunity (Task #40) tags: [investments] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [investment_type, title, location, total_value_amount] properties: investment_type: type: string enum: [ factory_sale, business_sale, production_line_investment, franchise, partnership, ] title: type: string description: type: string industry: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] location: type: string total_value_amount: type: number currency: type: string default: EGP expected_roi_pct: type: number nullable: true payback_years: type: number nullable: true revenue_range_min: type: number nullable: true revenue_range_max: type: number nullable: true cost_structure_note: type: string nullable: true growth_potential_note: type: string nullable: true figures_source: type: string enum: [seller_provided, estimate] default: seller_provided cover_url: type: string nullable: true responses: "201": description: Created investment id content: application/json: schema: type: object properties: data: type: object required: [id] properties: id: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/investments/mine: get: operationId: listMyInvestments summary: List investments owned by the caller (Task #40) tags: [investments] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated own investments (all statuses) content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/InvestmentSummary" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/investments/{id}: get: operationId: getInvestment summary: Investment detail with viewer-aware flags (Task #40) tags: [investments] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Investment detail content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/InvestmentDetail" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "404": description: Not found patch: operationId: updateInvestment summary: Update own investment (partial) (Task #40) tags: [investments] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: true content: application/json: schema: type: object properties: investment_type: type: string enum: [ factory_sale, business_sale, production_line_investment, franchise, partnership, ] title: type: string description: type: string industry: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] location: type: string total_value_amount: type: number currency: type: string expected_roi_pct: type: number nullable: true payback_years: type: number nullable: true revenue_range_min: type: number nullable: true revenue_range_max: type: number nullable: true cost_structure_note: type: string nullable: true growth_potential_note: type: string nullable: true figures_source: type: string enum: [seller_provided, estimate] cover_url: type: string nullable: true status: type: string enum: [draft, active, under_offer, closed] responses: "200": description: Updated content: application/json: schema: type: object properties: data: type: object required: [id, updated] properties: id: type: string updated: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "404": description: Not found /v1/investments/{id}/interest: post: operationId: submitInvestmentInterest summary: Express interest in an investment; notifies the owner (Task #40) tags: [investments] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: false content: application/json: schema: type: object properties: kind: type: string enum: [interest, request_details, contact] default: interest message: type: string contact_phone: type: string responses: "201": description: Interest submitted content: application/json: schema: type: object properties: data: type: object required: [id, submitted] properties: id: type: string submitted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/global-supply: get: operationId: listGlobalSupply summary: List open global sourcing / import-export requests (Task #40) tags: [global-supply] security: - {} - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 - in: query name: status schema: type: string enum: [open, fulfilled, closed, cancelled] - in: query name: industry schema: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] - in: query name: destination_country schema: type: string responses: "200": description: Paginated sourcing requests content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/GlobalSupplyRequest" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" post: operationId: createGlobalSupply summary: Create a global sourcing request (Task #40) tags: [global-supply] security: - ClerkAuth: [] requestBody: required: true content: application/json: schema: type: object required: [product_text, destination_country] properties: product_text: type: string category: type: string enum: [car, real_estate, industrial] industry: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] quantity: type: number nullable: true unit: type: string nullable: true destination_country: type: string budget_max: type: number nullable: true currency: type: string default: EGP incoterms: type: string enum: [exw, fca, fob, cfr, cif, dap, ddp] nullable: true notes: type: string nullable: true responses: "201": description: Created request id content: application/json: schema: type: object properties: data: type: object required: [id] properties: id: type: string error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/global-supply/mine: get: operationId: listMyGlobalSupply summary: List sourcing requests created by the caller (Task #40) tags: [global-supply] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated own sourcing requests content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/GlobalSupplyRequest" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/global-supply/{id}: get: operationId: getGlobalSupply summary: Sourcing request detail with responses + supplier matches (Task #40) tags: [global-supply] security: - {} - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Sourcing request detail content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/GlobalSupplyDetail" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" "404": description: Not found /v1/global-supply/{id}/responses: post: operationId: respondGlobalSupply summary: Submit (or update) a supplier quote on a request (Task #40) tags: [global-supply] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string requestBody: required: false content: application/json: schema: type: object properties: country_of_origin: type: string nullable: true moq: type: number nullable: true shipping_time_days: type: integer nullable: true incoterms: type: string enum: [exw, fca, fob, cfr, cif, dap, ddp] nullable: true delivery_estimate: type: string nullable: true price_quote: type: number nullable: true currency: type: string default: EGP message: type: string nullable: true responses: "201": description: Response submitted content: application/json: schema: type: object properties: data: type: object required: [id, submitted] properties: id: type: string submitted: type: boolean error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/market/trends: get: operationId: getMarketTrends summary: LIVE-computed market intelligence trends (Task #40) description: > Figures are derived LIVE from real listings, interactions and leads. Low-sample segments honestly report direction/data_quality "insufficient" — numbers are never fabricated. tags: [market] security: - {} - ClerkAuth: [] parameters: - in: query name: category schema: type: string enum: [car, real_estate, industrial] - in: query name: metric schema: type: string enum: [avg_price, listing_volume, demand, lead_volume] responses: "200": description: Market trends payload content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/MarketTrendsResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/companies: get: operationId: listCompanies summary: Suppliers directory with real listing & follower counts (Task #40) tags: [companies] security: - {} - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 - in: query name: q schema: type: string - in: query name: industry schema: type: string enum: [ food, beverage, plastic, textile, pharmaceutical, chemical, engineering, other, ] - in: query name: hq_country schema: type: string - in: query name: verified schema: type: boolean responses: "200": description: Paginated suppliers directory content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/CompanyDirectoryItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/companies/{id}/follow: post: operationId: followCompany summary: Follow a company / supplier (Task #40) tags: [companies] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Follow state after toggle content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FollowResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" delete: operationId: unfollowCompany summary: Unfollow a company / supplier (Task #40) tags: [companies] security: - ClerkAuth: [] parameters: - in: path name: id required: true schema: type: string responses: "200": description: Follow state after toggle content: application/json: schema: type: object properties: data: $ref: "#/components/schemas/FollowResult" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta" /v1/me/following: get: operationId: listMyFollowing summary: Companies the caller follows (Task #40) tags: [companies] security: - ClerkAuth: [] parameters: - in: query name: cursor schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Paginated followed companies content: application/json: schema: type: object properties: data: type: array items: $ref: "#/components/schemas/CompanyDirectoryItem" error: $ref: "#/components/schemas/ApiError" nullable: true meta: $ref: "#/components/schemas/Meta"