Aslan Documentation

Aslan is the universal payment infrastructure for AI agents. Enable any AI agent to make autonomous purchases with enterprise-grade security, real-time spending controls, and sub-400ms authorization.

Getting Started

Quick Start

Get your AI agent making purchases in under 5 minutes.

Try Interactive Demo

Installation

terminal
# Install Aslan SDK
npm install @aslanpay/sdk

# Or using yarn
yarn add @aslanpay/sdk

Basic Setup

const { Aslan } = require('@aslanpay/sdk');

const aslan = new Aslan({
  apiKey: process.env.ASLAN_API_KEY,
  environment: 'production' // or 'sandbox'
});

// Enable AI agent to make purchases
async function enableAIPurchases() {
  const result = await aslan.purchase({
    amount: 2500, // $25.00
    description: 'AWS credits for AI training',
    agentId: 'gpt-4-assistant'
  });
  
  console.log('Purchase successful:', result);
}

Authentication

Aslan uses API keys for authentication. You can get your API key from the dashboard.

Keep your API keys secure

  • • Never commit API keys to version control
  • • Use environment variables in production
  • • Rotate keys regularly
  • • Use different keys for development and production

API Reference

authorize()

Authorize a payment for an AI agent.

await aslan.authorize({
  amount: 2500,           // Required: Amount in cents
  description: 'string',  // Required: Purchase description
  agentId: 'string',     // Optional: Agent identifier
  metadata: {}           // Optional: Additional data
})

Response

{
  "id": "auth_1234567890",
  "amount": 2500,
  "status": "authorized",
  "description": "AWS credits for computation",
  "created_at": "2024-01-15T10:30:00Z"
}

confirm()

Confirm and execute an authorized payment.

await aslan.confirm({
  authorizationId: 'auth_1234567890'
})

refund()

Refund a completed payment.

await aslan.refund({
  paymentId: 'pay_1234567890',
  amount: 2500, // Optional: partial refund
  reason: 'Customer request'
})

Examples

OpenAI Integration

import OpenAI from 'openai'
import { Aslan } from '@aslanpay/sdk'

const openai = new OpenAI()
const aslan = new Aslan({ apiKey: process.env.ASLAN_API_KEY })

const completion = await openai.chat.completions.create({
  model: "gpt-4",
  messages: [{ role: "user", content: "Buy AWS credits" }],
  tools: [{
    type: "function",
    function: {
      name: "purchase",
      description: "Make a purchase",
      parameters: {
        type: "object",
        properties: {
          amount: { type: "number" },
          description: { type: "string" }
        }
      }
    }
  }]
})

// If AI decides to make a purchase
if (completion.choices[0].message.tool_calls) {
  const purchase = await aslan.authorize({
    amount: 2500,
    description: "AWS credits"
  })
}

LangChain Integration

from langchain.tools import Tool
from aslanpay import Aslan

aslan = Aslan(api_key="your_api_key")

def purchase_tool(amount: int, description: str):
    """Make a purchase with AI agent"""
    return aslan.authorize(
        amount=amount,
        description=description
    )

purchase = Tool(
    name="purchase",
    description="Make purchases for the AI agent",
    func=purchase_tool
)

Integrations

OpenAI

Integrate with GPT-4, function calling, and assistants.

View Example →

LangChain

Add payment tools to LangChain agents.

View Example →

CrewAI

Enable multi-agent teams to make purchases.

View Example →

Custom Frameworks

REST API works with any framework.

View Example →

Security

🔒 Enterprise Security

  • • JWT-based authentication with rotating secrets
  • • Rate limiting and DDoS protection
  • • Complete audit trails for all transactions
  • • Granular spending controls and velocity limits
  • • Real-time fraud detection

Spending Controls

const aslan = new Aslan({
  apiKey: 'your_api_key',
  limits: {
    daily: 10000,        // $100 daily limit
    perTransaction: 5000, // $50 per transaction
    velocity: {
      count: 10,         // Max 10 transactions
      window: 3600       // Per hour
    }
  }
})

Need Help?

Get support from our team of AI and payments experts.

🔧 Troubleshooting Guide

🌐 Domain Confusion

Issue: Tried aslanpay.com instead of aslanpay.xyz

Solution: Always use aslanpay.xyz for live demo

Local: localhost:3000 for development

🔑 API Key Issues

Invalid Key: Ensure format is ak_live_... or ak_test_...

Test Your Key:

curl -X GET http://localhost:3000/api/v1/test \
  -H "Authorization: Bearer ak_live_your_key"

📡 Endpoint Discovery

Correct Endpoints:

  • POST /api/v1/authorize - Start payment
  • POST /api/v1/confirm - Complete payment
  • POST /api/v1/refund - Process refund
  • GET /api/v1/test - Test API key

⚡ Two-Step Flow

Always: authorize → confirm (never single purchase)

Why: Gives AI agents time to validate before charging

// 1. Authorize
const auth = await aslan.authorize({amount: 2500, description: "..."});

// 2. Confirm  
const payment = await aslan.confirm({authorizationId: auth.id});

🔄 Mock vs Real SDK

Development: Use MockAslanSDK.js for testing

Production: Use real API endpoints with authentication

How to tell: Mock responses include "mock": true

🚨 Common Errors

401Missing/invalid API key
400Invalid request format
404Wrong endpoint URL
429Rate limit exceeded

⚡ Quick Test Sequence

  1. Health Check: GET /health
  2. API Key Test: GET /api/v1/test
  3. Test Payment: POST /api/v1/authorize
  4. Complete Flow: Run node test-api-keys.js