This document provides the API reference for the Delego platform. The API is currently under development and will be expanded as features are implemented.
Note: This API reference will be automatically generated from the OpenAPI specification once the gateway routes are fully implemented. This document serves as a placeholder and planning reference.
The Delego API is a RESTful API that provides access to the platform's core functionality, including user management, delegation management, order processing, and wallet operations.
The API uses URL versioning to ensure backward compatibility:
- v1: Current stable version
- v2: Future versions (when needed)
API requests are rate-limited to prevent abuse:
- Default: 100 requests per minute per user
- Burst: 200 requests per minute per user
- Headers: Rate limit information included in response headers
Most API endpoints require authentication via JWT tokens.
POST /api/v1/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password"
}Include the JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>JWT tokens expire after 24 hours. Use the refresh endpoint to obtain a new token:
POST /api/v1/auth/refresh
Authorization: Bearer <your-jwt-token>Some endpoints support wallet-based authentication using Stellar wallet signatures.
POST /api/v1/wallet/connect
Content-Type: application/json
{
"stellarAddress": "GABCD...",
"signature": "..."
}http://localhost:3000
https://staging-api.delego.dev
https://api.delego.dev
All API responses follow a consistent format:
{
"data": {
// Response data
},
"error": null,
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-01T00:00:00.000Z"
}
}{
"data": null,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input",
"details": {
"field": "email",
"issue": "Invalid email format"
}
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2026-01-01T00:00:00.000Z"
}
}- 200 OK: Request successful
- 201 Created: Resource created successfully
- 400 Bad Request: Invalid request
- 401 Unauthorized: Authentication required
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Resource not found
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Server error
| Code | Description |
|---|---|
VALIDATION_ERROR |
Request validation failed |
BAD_REQUEST |
Bad request or invalid operation |
UNAUTHORIZED |
Authentication failed |
NOT_FOUND |
Resource not found |
RATE_LIMIT_EXCEEDED |
Rate limit exceeded |
INTERNAL_ERROR |
Internal server error |
BLOCKCHAIN_ERROR |
Blockchain operation failed |
Health check endpoint for monitoring.
Response:
{
"data": {
"status": "ok",
"service": "gateway",
"version": "0.0.1",
"timestamp": "2026-01-01T00:00:00.000Z"
},
"error": null
}Register a new user account.
Request Body:
{
"email": "user@example.com",
"password": "securePassword123",
"displayName": "John Doe"
}Request Schema:
email(string, required): User email in valid email formatpassword(string, required): Password with minimum 8 charactersdisplayName(string, optional): User's display name
Success Response (201 Created):
{
"data": {
"user": {
"id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"email": "user@example.com",
"displayName": "John Doe"
},
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 900
},
"error": null
}Set-Cookie Header:
refresh_token: HttpOnly, Secure, SameSite=Strict cookie with 7-day expiration
Error Responses:
- 400 Bad Request (VALIDATION_ERROR): Invalid email format or password too short
{
"data": null,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": [
{
"field": "password",
"message": "must be >= 8 characters"
}
]
}
}- 400 Bad Request (BAD_REQUEST): User already exists
{
"data": null,
"error": {
"code": "BAD_REQUEST",
"message": "User with this email already exists"
}
}Authenticate user with email and password.
Request Body:
{
"email": "user@example.com",
"password": "securePassword123"
}Request Schema:
email(string, required): User email in valid email formatpassword(string, required): User password
Success Response (200 OK):
{
"data": {
"user": {
"id": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
"email": "user@example.com",
"displayName": "John Doe"
},
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 900
},
"error": null
}Set-Cookie Header:
refresh_token: HttpOnly, Secure, SameSite=Strict cookie with 7-day expiration
Error Responses:
- 400 Bad Request (VALIDATION_ERROR): Invalid email format or missing password
{
"data": null,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body"
}
}- 401 Unauthorized: Invalid email or password
{
"data": null,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid email or password"
}
}Refresh access token using refresh token from cookies.
Headers:
- No Authorization header required
- Refresh token automatically sent in cookies by the browser
Request Body: No request body required. Refresh token comes from HttpOnly cookie.
Success Response (200 OK):
{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 900
},
"error": null
}Set-Cookie Header:
refresh_token: New refresh token with 7-day expiration
Error Responses:
- 401 Unauthorized: Missing refresh token
{
"data": null,
"error": {
"code": "UNAUTHORIZED",
"message": "Refresh token missing"
}
}- 401 Unauthorized: Invalid or expired refresh token
{
"data": null,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid refresh token"
}
}- 401 Unauthorized: Refresh token expired
{
"data": null,
"error": {
"code": "UNAUTHORIZED",
"message": "Refresh token expired"
}
}- 401 Unauthorized: Token reuse detected (security violation)
{
"data": null,
"error": {
"code": "UNAUTHORIZED",
"message": "Token reuse detected"
}
}Logout user and clear refresh token.
Headers:
Authorization: Bearer <access-token>Request Body: No request body required.
Success Response (200 OK):
{
"data": {
"success": true
},
"error": null
}Set-Cookie Header:
refresh_token: Cleared with past expiration date
Error Responses:
- 401 Unauthorized: Missing Authorization header
{
"data": null,
"error": {
"code": "UNAUTHORIZED",
"message": "Missing Authorization header"
}
}- 500 Internal Server Error: Logout operation failed
{
"data": null,
"error": {
"code": "INTERNAL_ERROR",
"message": "Logout failed"
}
}Connect Stellar wallet.
Request Body:
{
"stellarAddress": "GABCD...",
"signature": "signature_here"
}Response:
{
"data": {
"walletId": "wallet_123",
"stellarAddress": "GABCD...",
"connected": true
},
"error": null
}Get wallet balance.
Headers:
Authorization: Bearer <token>
Response:
{
"data": {
"balance": 10000000,
"currency": "XLM"
},
"error": null
}List user delegations.
Headers:
Authorization: Bearer <token>
Query Parameters:
status: Filter by status (optional)limit: Number of results (default: 50)offset: Pagination offset (default: 0)
Response:
{
"data": {
"delegations": [
{
"id": "del_123",
"agentType": "buyer",
"spendingLimit": 10000000,
"status": "active",
"createdAt": "2026-01-01T00:00:00.000Z"
}
],
"total": 1,
"limit": 50,
"offset": 0
},
"error": null
}Create new delegation.
Headers:
Authorization: Bearer <token>
Request Body:
{
"agentType": "buyer",
"spendingLimit": 10000000,
"approvalThreshold": 5000000
}Response:
{
"data": {
"id": "del_123",
"agentType": "buyer",
"spendingLimit": 10000000,
"approvalThreshold": 5000000,
"status": "active",
"createdAt": "2026-01-01T00:00:00.000Z"
},
"error": null
}Get delegation details.
Headers:
Authorization: Bearer <token>
Response:
{
"data": {
"id": "del_123",
"agentType": "buyer",
"spendingLimit": 10000000,
"approvalThreshold": 5000000,
"status": "active",
"createdAt": "2026-01-01T00:00:00.000Z"
},
"error": null
}Revoke delegation.
Headers:
Authorization: Bearer <token>
Response:
{
"data": {
"success": true
},
"error": null
}List user orders.
Headers:
Authorization: Bearer <token>
Query Parameters:
status: Filter by status (optional)limit: Number of results (default: 50)offset: Pagination offset (default: 0)
Response:
{
"data": {
"orders": [
{
"id": "order_123",
"status": "initiated",
"totalAmount": 10000000,
"currency": "XLM",
"createdAt": "2026-01-01T00:00:00.000Z"
}
],
"total": 1,
"limit": 50,
"offset": 0
},
"error": null
}Create new order.
Headers:
Authorization: Bearer <token>
Request Body:
{
"delegationId": "del_123",
"items": [
{
"productId": "prod_456",
"quantity": 1
}
]
}Response:
{
"data": {
"id": "order_123",
"status": "initiated",
"totalAmount": 10000000,
"currency": "XLM",
"createdAt": "2026-01-01T00:00:00.000Z"
},
"error": null
}Get order details.
Headers:
Authorization: Bearer <token>
Response:
{
"data": {
"id": "order_123",
"status": "initiated",
"totalAmount": 10000000,
"currency": "XLM",
"items": [...],
"createdAt": "2026-01-01T00:00:00.000Z"
},
"error": null
}Approve order for execution.
Headers:
Authorization: Bearer <token>
Response:
{
"data": {
"success": true,
"orderStatus": "approved"
},
"error": null
}Cancel order.
Headers:
Authorization: Bearer <token>
Response:
{
"data": {
"success": true,
"orderStatus": "cancelled"
},
"error": null
}Delego sends webhook events to notify your application of important events:
order.created: New order createdorder.approved: Order approvedorder.completed: Order completedorder.cancelled: Order cancelleddelegation.created: New delegation createddelegation.revoked: Delegation revoked
Configure webhooks via the API or dashboard:
POST /api/v1/webhooks
Authorization: Bearer <token>
{
"url": "https://your-app.com/webhook",
"events": ["order.created", "order.completed"],
"secret": "webhook_secret"
}Webhook requests include a signature header for verification:
X-Delego-Signature: sha256=signature_here
import { DelegoClient } from "@delego/sdk";
const client = new DelegoClient({
apiKey: "your-api-key",
baseURL: "https://api.delego.dev",
});
// Get delegations
const delegations = await client.delegations.list();
// Create delegation
const delegation = await client.delegations.create({
agentType: "buyer",
spendingLimit: 10000000,
});from delego import DelegoClient
client = DelegoClient(api_key='your-api-key')
# Get delegations
delegations = client.delegations.list()
# Create delegation
delegation = client.delegations.create(
agent_type='buyer',
spending_limit=10000000
)The full OpenAPI specification will be available at:
https://api.delego.dev/openapi.json
This can be used to generate client SDKs in various languages.
- Initial API release
- Authentication endpoints
- Wallet endpoints
- Delegation endpoints
- Order endpoints
Last Updated: June 2026