API documentation for the Movement x402 payment gateway server.
https://x402.leeduckgo.comhttp://localhost:4402GET /Get server information and pay-to address.
Response:
Hello from Movement x402 Server!
Pay-to address: <MOVEMENT_PAY_TO>GET /healthHealth check endpoint for monitoring and load balancers.
Response:
{
"status": "healthy",
"timestamp": "2025-01-04T12:00:00.000Z"
}GET /docsGet API documentation in Markdown format.
Response: Raw Markdown content of this documentation.
GET /v2/docs/htmlGet API documentation rendered as HTML with GitHub Flavored Markdown styling.
Response: HTML page with rendered documentation.
These endpoints require payment via the x402 protocol.
GET /api/premium-contentAccess premium content after successful payment.
| Field | Value |
|---|---|
| Network | movement |
| Asset | 0x1::aptos_coin::AptosCoin |
| Amount | 1 (minimal $MOVE) |
| Description | Pay token to get Coupon |
| Timeout | 600 seconds |
Step 1: Initial Request (No Payment)
curl -i http://localhost:4402/api/premium-contentResponse (402 Payment Required):
HTTP/1.1 402 Payment Required
Content-Type: application/json
X-PAYMENT-RESPONSE: {"network":"movement","payTo":"0x...","asset":"0x1::aptos_coin::AptosCoin","maxAmountRequired":"1","description":"pay token to get Coupon.","mimeType":"application/json","maxTimeoutSeconds":600,"facilitatorUrl":"https://facilitator.stableyard.fi"}{
"error": "Payment Required",
"message": "Please include X-PAYMENT header with payment proof"
}Step 2: Make Payment
Use the facilitator URL from X-PAYMENT-RESPONSE header to process payment:
https://facilitator.stableyard.fiStep 3: Request with Payment Proof
curl -i http://localhost:4402/api/premium-content \
-H "X-PAYMENT: {\"proof\":\"...payment_proof_data...\"}"Response (302 Redirect):
HTTP/1.1 302 Found
Location: https://www.youtube.com/watch?v=dQw4w9WgXcQThe x402 protocol enables HTTP-native micropayments on the Movement blockchain. When accessing protected resources:
X-PAYMENT-RESPONSE headerX-PAYMENT header| Header | Direction | Description |
|---|---|---|
X-PAYMENT-RESPONSE |
Server → Client | Payment requirements (JSON) |
X-PAYMENT |
Client → Server | Payment proof (JSON) |
{
"network": "movement",
"payTo": "0x...",
"asset": "0x1::aptos_coin::AptosCoin",
"maxAmountRequired": "1",
"description": "pay token to get Coupon.",
"mimeType": "application/json",
"maxTimeoutSeconds": 600,
"facilitatorUrl": "https://facilitator.stableyard.fi"
}| Field | Type | Description |
|---|---|---|
network |
string | Blockchain network (movement) |
payTo |
string | Recipient wallet address |
asset |
string | Token asset identifier |
maxAmountRequired |
string | Maximum payment amount in smallest unit |
description |
string | Human-readable payment description |
mimeType |
string | Response content type after payment |
maxTimeoutSeconds |
number | Payment timeout in seconds |
facilitatorUrl |
string | Payment facilitator service URL |
{
"error": "Unauthorized: Invalid password"
}{
"error": "Payment Required",
"message": "Please include X-PAYMENT header with payment proof"
}{
"error": "Payment verification failed",
"message": "Invalid or insufficient payment"
}{
"success": false,
"error": "Internal server error"
}| Variable | Required | Description |
|---|---|---|
PORT |
No | Server port (default: 4402) |
MOVEMENT_PAY_TO |
Yes | Wallet address to receive payments |
ADMIN_PWD |
No | Admin password for protected operations |
// Check if payment is required
const response = await fetch('http://localhost:4402/api/premium-content');
if (response.status === 402) {
// Get payment requirements
const paymentInfo = JSON.parse(
response.headers.get('X-PAYMENT-RESPONSE') || '{}'
);
console.log('Payment required:', paymentInfo);
// Process payment via facilitator...
const paymentProof = await processPayment(paymentInfo);
// Retry with payment proof
const paidResponse = await fetch('http://localhost:4402/api/premium-content', {
headers: {
'X-PAYMENT': JSON.stringify(paymentProof)
}
});
// Handle redirect or content
console.log('Access granted!', paidResponse.status);
}# Health check
curl http://localhost:4402/health
# Get server info
curl http://localhost:4402/
# Request premium content (will return 402)
curl -i http://localhost:4402/api/premium-content
# Request with payment proof
curl -i http://localhost:4402/api/premium-content \
-H 'X-PAYMENT: {"proof":"your_payment_proof"}'The facilitator (https://facilitator.stableyard.fi) handles:
POST https://facilitator.stableyard.fi/verifyRequest Body:
{
"payment": { /* payment proof data */ },
"payTo": "0x...",
"network": "movement",
"asset": "0x1::aptos_coin::AptosCoin",
"maxAmountRequired": "1"
}Built with ❤️ using Deno, Oak, and x402 Protocol