Skip to content
SpendScript

SpendScript

AI procurement with policy-bound spending.

Created on 2nd August 2026

•

SpendScript

SpendScript

AI procurement with policy-bound spending.

The problem SpendScript solves

Procurement agents need boundaries, not just intelligence

SpendScript is an authenticated procurement platform that turns an employee's plain-language buying request into a controlled, auditable purchase.

A requester describes what the organization needs. OpenAI Structured Outputs converts that intent into typed requirements—quantity, budget, specifications, compatibility, and delivery timing. The requester reviews every extracted field before anything is sourced.

SpendScript then:

  • Searches the organization's persisted, controlled supplier catalog
  • Applies deterministic procurement policy to every offer
  • Scores compliant offers using requirement match (35%), cost (25%), delivery (15%), merchant approval (10%), seller trust (10%), and return flexibility (5%)
  • Produces an explainable purchase recommendation
  • Requires a manager to approve a merchant-scoped spending contract
  • Creates a one-time Prava sandbox mandate with a fixed merchant, cap, charge count, and expiry
  • Proves the control by recording an over-limit attempt as blocked
  • Executes only the valid authorized checkout
  • Preserves safe transaction metadata and an immutable organization-scoped audit trail

The language model can structure and explain, but it cannot change budgets, merchant allowlists, quantities, approval thresholds, expiry, or payment limits. Supabase Auth and Row Level Security isolate each organization, while server-only payment handling prevents credentials from reaching the browser or database.

The result is a real product workflow for finance, operations, IT, and purchasing teams: employees get faster procurement, managers retain approval authority, and agents receive the least payment authority necessary to complete one specific mission.

Source: https://github.com/NotMe22221/sendscript

Challenges I ran into

The hardest parts were trust, state, and truthful integrations

Turning policy into executable controls. Natural-language policy is useful for authoring, but unsafe as the enforcement layer. We built shared Zod schemas and a deterministic policy engine, then restricted OpenAI to structured extraction and concise explanations.

Keeping an agentic workflow consistent across retries. The mission moves through an explicit persisted state machine from DRAFT to COMPLETED, including blocked, rejected, failed, cancelled, and expired paths. State transitions and audit events are inserted atomically, execution locks authorized missions, and unique idempotency references prevent duplicate checkout.

Making payment authorization safe. Prava credentials and checkout credentials must never reach the client, logs, analytics, or persistence. The server passes scoped credentials directly from the mandate charge response into a replaceable checkout adapter within one request, then stores only safe identifiers, statuses, response IDs, and failure codes.

Avoiding a misleading hackathon simulation. Early versions used fixed UI data to make the workflow easy to review. We replaced runtime fallbacks with authenticated Supabase data, mission-specific offer evaluation, dynamic approval caps, dynamic merchant scope, and fail-closed OpenAI/Prava connections. Starter records remain optional onboarding content, but newly created missions use the same persisted tables, RLS policies, APIs, and audit trail.

Operating around sandbox constraints. Prava currently requires synchronous confirmation rather than webhooks, so the authorization return flow polls for the active mandate before permitting checkout. Missing enrollment or credentials now surfaces as an actionable configuration error instead of fabricated success.

The final result passes TypeScript, ESLint, 20 automated tests, and an optimized Next.js production build.

Tracks Applied (3)

OpenAI

SpendScript uses the OpenAI Responses API with Structured Outputs as a constrained intelligence layer in a consequential...Read More
OpenAI

OpenAI

Best Agentic User Experience

SpendScript makes a complex, high-risk agentic purchase understandable in one guided workflow. Users move from natural-l...Read More

Agentic Commerce Hackathon

SpendScript is an end-to-end agentic commerce platform. An AI agent converts employee purchasing intent into structured ...Read More

Discussion

Builders also viewed

See more projects on Devfolio