Pay with x402 Session
curl --request POST \
--url https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"target_url": "https://paid-api.example.com/v1/data"
}
'import requests
url = "https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay"
payload = { "target_url": "https://paid-api.example.com/v1/data" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({target_url: 'https://paid-api.example.com/v1/data'})
};
fetch('https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'target_url' => 'https://paid-api.example.com/v1/data'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay"
payload := strings.NewReader("{\n \"target_url\": \"https://paid-api.example.com/v1/data\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"target_url\": \"https://paid-api.example.com/v1/data\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"target_url\": \"https://paid-api.example.com/v1/data\"\n}"
response = http.request(request)
puts response.read_body{
"ledger_id": "<string>",
"amount": "<string>",
"fee_amount": "<string>",
"fee_rate": "<string>",
"token": "<string>",
"chain": "<string>",
"payment_signature": "<string>"
}{
"code": "invalid_request",
"type": "invalid_request_error",
"message": "The request body is missing required fields."
}{
"code": "authentication_failed",
"type": "authentication_error",
"message": "The provided API key is invalid or expired."
}{
"code": "insufficient_permissions",
"type": "authorization_error",
"message": "You do not have permission to perform this action."
}{
"code": "resource_not_found",
"type": "not_found_error",
"message": "The requested resource was not found."
}{
"code": "rate_limit_exceeded",
"type": "rate_limit_error",
"message": "Too many requests. Please retry after a short delay."
}{
"code": "server_error",
"type": "internal_error",
"message": "An unexpected error occurred. Please try again later."
}x402
Pay with x402 Session
Make a payment using an existing session budget.
POST
/
api
/
v1
/
x402
/
sessions
/
{id}
/
pay
Pay with x402 Session
curl --request POST \
--url https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"target_url": "https://paid-api.example.com/v1/data"
}
'import requests
url = "https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay"
payload = { "target_url": "https://paid-api.example.com/v1/data" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({target_url: 'https://paid-api.example.com/v1/data'})
};
fetch('https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'target_url' => 'https://paid-api.example.com/v1/data'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay"
payload := strings.NewReader("{\n \"target_url\": \"https://paid-api.example.com/v1/data\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"target_url\": \"https://paid-api.example.com/v1/data\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentwallex.com/api/v1/x402/sessions/{id}/pay")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"target_url\": \"https://paid-api.example.com/v1/data\"\n}"
response = http.request(request)
puts response.read_body{
"ledger_id": "<string>",
"amount": "<string>",
"fee_amount": "<string>",
"fee_rate": "<string>",
"token": "<string>",
"chain": "<string>",
"payment_signature": "<string>"
}{
"code": "invalid_request",
"type": "invalid_request_error",
"message": "The request body is missing required fields."
}{
"code": "authentication_failed",
"type": "authentication_error",
"message": "The provided API key is invalid or expired."
}{
"code": "insufficient_permissions",
"type": "authorization_error",
"message": "You do not have permission to perform this action."
}{
"code": "resource_not_found",
"type": "not_found_error",
"message": "The requested resource was not found."
}{
"code": "rate_limit_exceeded",
"type": "rate_limit_error",
"message": "Too many requests. Please retry after a short delay."
}{
"code": "server_error",
"type": "internal_error",
"message": "An unexpected error occurred. Please try again later."
}Path Parameters
string
required
The session ID to pay from (e.g.,
sess_xyz789).Request Body
string
required
The x402-enabled URL to pay for.
Example
curl -X POST https://api.agentwallex.com/api/v1/x402/sessions/sess_xyz789/pay \
-H "X-API-Key: awx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"target_url": "https://paid-api.example.com/v1/data"
}'
await aw.x402.sessionPay("sess_xyz789", {
targetUrl: "https://paid-api.example.com/v1/data",
});
Authorizations
ApiKeyAuthBearerAuth
API key authentication. Keys are prefixed with awx_.
Path Parameters
The session ID to pay from (e.g., sess_xyz789).
Body
application/json
The x402-enabled URL to pay for.
Response
Session payment completed successfully.
Result of an x402 payment negotiation.
Internal ledger entry ID for this payment.
Payment amount.
Platform fee deducted.
Fee percentage applied (based on tiered pricing).
Token used for payment (e.g., USDC).
Chain used for settlement.
Payment status.
Available options:
completed, pending, failed The PAYMENT-SIGNATURE value to include in the retry request to the target URL.
⌘I