API Reference

Complete API reference for integrating Aslan payment infrastructure with your AI agents. All endpoints support both REST and SDK-based access.

Base URL

https://api.aslanpay.xyz/v1

Authentication

All API requests require authentication using an API key in the Authorization header.

curl -X POST https://aslanpay.xyz/api/v1/authorize \
  -H "Authorization: Bearer ak_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "description": "AWS credits"
  }'

🔑 API Key Formats

  • • Live: ak_live_... - For production transactions
  • • Test: ak_test_... - For sandbox testing
POST /api/v1/authorize

Create a payment authorization for an AI agent. This reserves funds but does not charge the payment method.

Request Body

{
  "amount": 2500,                    // Required: Amount in cents
  "description": "AWS credits",      // Required: Human-readable description
  "agentId": "agent_123",           // Optional: AI agent identifier
  "metadata": {                     // Optional: Custom metadata
    "project": "ai-research",
    "department": "engineering"
  }
}

Response

{
  "id": "auth_1NirD82eZvKYlo2CjQk6B8XK",
  "object": "authorization",
  "amount": 2500,
  "currency": "usd",
  "description": "AWS credits",
  "status": "authorized",
  "agentId": "agent_123",
  "created": 1640995200,
  "expiresAt": 1641002400,
  "metadata": {
    "project": "ai-research",
    "department": "engineering"
  }
}

cURL Example

curl -X POST https://aslanpay.xyz/api/v1/authorize \
  -H "Authorization: Bearer ak_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "description": "AWS credits for GPT-4 training",
    "agentId": "training_agent_001"
  }'
POST /api/v1/confirm

Confirm and execute a previously authorized payment. This charges the payment method.

Request Body

{
  "authorizationId": "auth_1NirD82eZvKYlo2CjQk6B8XK"
}

Response

{
  "id": "pay_1NirD82eZvKYlo2CjQkMBhXe",
  "object": "payment",
  "amount": 2500,
  "currency": "usd",
  "description": "AWS credits",
  "status": "succeeded",
  "authorizationId": "auth_1NirD82eZvKYlo2CjQk6B8XK",
  "created": 1640995800,
  "receiptUrl": "https://pay.stripe.com/receipts/..."
}

cURL Example

curl -X POST https://aslanpay.xyz/api/v1/confirm \
  -H "Authorization: Bearer ak_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "authorizationId": "auth_1NirD82eZvKYlo2CjQk6B8XK"
  }'
POST /api/v1/refund

Refund a completed payment, either partially or in full.

Request Body

{
  "paymentId": "pay_1NirD82eZvKYlo2CjQkMBhXe",
  "amount": 1000,                   // Optional: partial refund amount
  "reason": "Customer request"      // Optional: refund reason
}

Response

{
  "id": "re_1NirD82eZvKYlo2CjReFund1",
  "object": "refund",
  "amount": 1000,
  "currency": "usd",
  "paymentId": "pay_1NirD82eZvKYlo2CjQkMBhXe",
  "reason": "Customer request",
  "status": "succeeded",
  "created": 1640996400
}
GET /api/status

Get the current system status and health of all components.

Response

{
  "service": "Aslan Payment Infrastructure",
  "status": "operational",
  "timestamp": "2024-05-29T17:55:12.746Z",
  "version": "1.0.0",
  "environment": "production",
  "uptime": 124.777585657,
  "components": {
    "database": {
      "status": "operational",
      "responseTime": "15ms"
    },
    "stripe": {
      "status": "operational"
    },
    "authentication": {
      "status": "operational"
    },
    "api": {
      "status": "operational"
    }
  }
}

cURL Example

curl -X GET https://aslanpay.xyz/api/status

Error Codes

HTTP Status Codes

200 OK - Request succeeded
400 Bad Request - Invalid parameters
401 Unauthorized - Invalid API key
403 Forbidden - Insufficient permissions
404 Not Found - Resource doesn't exist
429 Too Many Requests - Rate limit exceeded
500 Internal Server Error

Error Response Format

{
  "error": {
    "type": "invalid_request_error",
    "code": "amount_too_small",
    "message": "Amount must be at least $0.50 USD",
    "param": "amount"
  }
}

SDKs & Libraries

Use our official SDKs for easier integration with your AI frameworks.

Node.js

npm install @aslanpay/sdk

Python

pip install aslanpay
curl
curl -X POST https://api.aslanpay.xyz/v1/purchase \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "description": "AWS credits",
    "agent_id": "gpt-4-assistant"
  }'
{
  "success": true,
  "transaction_id": "txn_1abc234def",
  "status": "authorized",
  "amount": 2500,
  "description": "AWS credits",
  "latency_ms": 127,
  "timestamp": "2024-01-15T10:30:00Z"
}