Skip to main content
This reference documents the Swig Developer Portal REST API endpoints.

Base URLs

EnvironmentURL
Portal APIhttps://dashboard.onswig.com
Paymaster APIhttps://api.onswig.com

Authentication

All API requests require authentication via API key:
Authorization: Bearer sk_your_api_key
API keys are created in the Developer Portal and have the format sk_<64-hex-characters>.

Endpoints

Policies

Get Policy

Retrieve a policy by ID. Request:
GET /api/v1/policies/{policyId}
Headers:
Authorization: Bearer sk_your_api_key
Path Parameters:
ParameterTypeDescription
policyIdstringThe policy ID (CUID format)
Response:
{
  "id": "clx1234567890abcdef",
  "name": "user-wallet-policy",
  "description": "Standard user wallet with transfer limits",
  "authority": {
    "type": "Ed25519",
    "publicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"
  },
  "actions": [
    { "type": "SolLimit", "amount": "1000000000" },
    { "type": "TokenLimit", "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "amount": "1000000" }
  ]
}
cURL Example:
curl -X GET "https://dashboard.onswig.com/api/v1/policies/clx1234567890abcdef" \
  -H "Authorization: Bearer sk_your_api_key"

Wallets

Create Wallet

Create a new Swig wallet using a policy. Request:
POST /api/v1/wallet/create
Headers:
Authorization: Bearer sk_your_api_key
Content-Type: application/json
Request Body:
FieldTypeRequiredDescription
policyIdstringYesPolicy ID to use
networkstringYes"mainnet" or "devnet"
paymasterPubkeystringYesPaymaster public key
swigIdstringNoCustom Swig ID (auto-generated if omitted)
signerIdstringNoSigner ID override
Request Example:
{
  "policyId": "clx1234567890abcdef",
  "network": "devnet",
  "paymasterPubkey": "A1dBRAaYUHyUzyQLGYzHrQzpYy9xTVXCaMnHx4RuEGY5"
}
Response:
{
  "swigId": "a1b2c3d4e5f67890",
  "swigAddress": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
  "signature": "5wHu1qwD7g4p3zWxF..."
}
cURL Example:
curl -X POST "https://dashboard.onswig.com/api/v1/wallet/create" \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "policyId": "clx1234567890abcdef",
    "network": "devnet",
    "paymasterPubkey": "A1dBRAaYUHyUzyQLGYzHrQzpYy9xTVXCaMnHx4RuEGY5"
  }'

Paymaster

Submit a transaction for sponsorship. Request:
POST /sponsor
Base URL: https://api.onswig.com Headers:
Authorization: Bearer sk_your_api_key
Content-Type: application/json
Request Body:
FieldTypeRequiredDescription
base58_encoded_transactionstringYesBase58-encoded transaction
networkstringNo"mainnet" or "devnet"
Request Example:
{
  "base58_encoded_transaction": "BASE58_ENCODED_TX_HERE",
  "network": "devnet"
}
Response:
{
  "request_id": "req_abc123",
  "signature": "5wHu1qwD7g4p3zWxF...",
  "spent_by_paymaster": 5000
}
Response Fields:
FieldTypeDescription
request_idstringUnique request identifier
signaturestringTransaction signature
spent_by_paymasternumberLamports spent by paymaster

Sign Transaction

Sign a transaction without sending. Request:
POST /sign
Base URL: https://api.onswig.com Headers:
Authorization: Bearer sk_your_api_key
Content-Type: application/json
Request Body:
FieldTypeRequiredDescription
base58_encoded_transactionstringYesBase58-encoded transaction
networkstringNo"mainnet" or "devnet"
Response:
{
  "request_id": "req_abc123",
  "signed_transaction": "BASE58_ENCODED_SIGNED_TX"
}

Health Check

Check paymaster service health. Request:
GET /health
Base URL: https://api.onswig.com Response:
{
  "status": "healthy",
  "timestamp": "2024-01-15T12:00:00Z"
}

Data Types

Policy

interface Policy {
  id: string;
  name: string;
  description: string | null;
  authority: AuthorityConfig | null;
  actions: ActionConfig[];
}

AuthorityConfig

type AuthorityConfig =
  | { type: 'Ed25519'; publicKey: string }
  | { type: 'Ed25519Session'; publicKey: string; maxDurationSlots: string }
  | { type: 'Secp256k1'; publicKey: string }
  | { type: 'Secp256k1Session'; publicKey: string; maxDurationSlots: string }
  | { type: 'Secp256r1'; publicKey: string }
  | { type: 'Secp256r1Session'; publicKey: string; maxDurationSlots: string };

ActionConfig

type ActionConfig =
  // General
  | { type: 'All' }
  | { type: 'AllButManageAuthority' }
  | { type: 'ManageAuthority' }

  // SOL
  | { type: 'SolLimit'; amount: string }
  | { type: 'SolRecurringLimit'; recurringAmount: string; window: string }
  | { type: 'SolDestinationLimit'; amount: string; destination: string }
  | { type: 'SolRecurringDestinationLimit'; recurringAmount: string; window: string; destination: string }

  // Token
  | { type: 'TokenLimit'; mint: string; amount: string }
  | { type: 'TokenRecurringLimit'; mint: string; recurringAmount: string; window: string }
  | { type: 'TokenDestinationLimit'; mint: string; amount: string; destination: string }
  | { type: 'TokenRecurringDestinationLimit'; mint: string; recurringAmount: string; window: string; destination: string }

  // Program
  | { type: 'Program'; programId: string }
  | { type: 'ProgramAll' }
  | { type: 'ProgramCurated' }

  // Staking
  | { type: 'StakeLimit'; amount: string }
  | { type: 'StakeRecurringLimit'; recurringAmount: string; window: string }
  | { type: 'StakeAll' }

  // Sub-accounts
  | { type: 'SubAccount' };

CreateWalletRequest

interface CreateWalletRequest {
  policyId: string;
  network: 'mainnet' | 'devnet';
  paymasterPubkey: string;
  swigId?: string;
  signerId?: string;
}

CreateWalletResponse

interface CreateWalletResponse {
  swigId: string;
  swigAddress: string;
  signature: string;
}

Error Responses

All errors follow this format:
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message",
    "details": {}
  }
}
See Error Codes for a complete list.

Rate Limits

API requests are rate-limited based on your subscription tier:
TierRequests/Minute
FREE60
PRO300
ULTRA600
ENTERPRISECustom
Rate limit headers are included in responses:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1642520400

SDKs

Use our SDKs for easier integration:
npm install @swig-wallet/api
import { SwigApiClient } from '@swig-wallet/api';

const client = new SwigApiClient({
  apiKey: 'sk_your_api_key',
  portalUrl: 'https://dashboard.onswig.com',
});

Next Steps