This is section is still under active development and not all endpoints are available yet.

Rampart provides two methods for sending spend data: direct API integration and file upload. This guide explains both approaches and their requirements.

Overview

You can send spend data to Rampart in two ways:

  1. Direct API integration for programmatic data submission
  2. File upload for bulk data processing

Base URL Configuration

The Rampart API base URL is https://api.rampartcorporation.com

All API endpoints should be prefixed with this base URL.

Direct API Integration

Endpoint

POST /developer/v1/spends

Headers

Authorization: Bearer {RAMPART_SECRET_TOKEN}
Content-Type: application/json

Request Body Structure

{
  vendorName: string;    // Name of the vendor
  spends: Array<{
    quantity: number;    // Quantity purchased
    unitPrice: number;   // Price per unit
    name: string;        // Item name
    itemId?: string;     // Optional item identifier
    purchaseDate?: Date; // Optional purchase date
    uom?: string;        // Optional unit of measure
  }>
}

Response

{
  success: boolean;
  data: Array<{
    spendId: string;    // Unique identifier for the spend record
    savingsId: string;  // Identifier for associated savings analysis
  }>;
}

File Upload Integration

Endpoint

POST /developer/v1/spends/upload

Headers

Authorization: Bearer {RAMPART_SECRET_TOKEN}
Content-Type: multipart/form-data

Request Body

  • File field name: file
  • Supported formats: CSV, XLSX
  • Maximum file size: 10MB

Response

{
  success: boolean;
  message: string;
  fileName: string;
  fileSize: number;
  partnerId: string;
  accountId: string;
}

Required Data Fields

Purchase Orders & Invoices

  • Vendor name
  • Order date
  • SKU numbers
  • Item names
  • Price paid
  • Quantity bought
  • Unit

Credit Card Transactions

  • Vendor name
  • Order date
  • Amount (excluding taxes ideally)

Implementation Steps

  1. Direct API Integration

    • Format your spend data according to the request structure
    • Send a POST request to /developer/v1/spends
    • Include your RAMPART_SECRET_TOKEN in the Authorization header
    • Process the response to track spend and savings IDs
  2. File Upload Integration

    • Prepare your CSV or XLSX file with the required fields
    • Create a FormData object with the file
    • Send a POST request to /developer/v1/spends/upload
    • Include your RAMPART_SECRET_TOKEN in the Authorization header
    • Process the response to confirm successful upload

Best Practices

Data Validation

  • Ensure all required fields are present
  • Validate data types and formats
  • Check for duplicate entries
  • Verify numerical values are positive

Error Handling

  • Implement proper error handling for failed requests
  • Validate file formats before upload
  • Check file size limits
  • Handle network errors gracefully

Security

  • Never expose your secret token in client-side code
  • Always use HTTPS in production
  • Store tokens securely in environment variables
  • Implement proper access controls

Example Usage

Direct API Integration

const spendData = {
  vendorName: "Example Vendor",
  spends: [
    {
      quantity: 10,
      unitPrice: 100,
      name: "Product A",
      itemId: "SKU123",
      purchaseDate: new Date(),
      uom: "units"
    }
  ]
};

const response = await axios.post('/developer/v1/spends', spendData, {
  headers: {
    Authorization: `Bearer ${RAMPART_SECRET_TOKEN}`
  }
});

File Upload

const formData = new FormData();
formData.append('file', fileObject);

const response = await axios.post('/developer/v1/spends/upload', formData, {
  headers: {
    Authorization: `Bearer ${RAMPART_SECRET_TOKEN}`,
    'Content-Type': 'multipart/form-data'
  }
});

Common Issues

Invalid Data Format

  • Ensure all required fields are present
  • Verify data types match the expected format
  • Check for proper date formatting
  • Validate numerical values

File Upload Issues

  • Check file size limits
  • Verify file format (CSV or XLSX)
  • Ensure proper file encoding
  • Validate file content structure

Authentication Failures

  • Verify your RAMPART_SECRET_TOKEN is valid
  • Check environment settings
  • Ensure proper headers are included