curl --request POST \
--url https://api.sandbox.nevermined.app/api/v1/x402/settle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"paymentRequired": {
"x402Version": 2,
"error": "Payment required to access resource",
"resource": {
"url": "/api/v1/agents/tasks",
"description": "AI agent task execution"
},
"accepts": [
{
"scheme": "nvm:erc4337",
"network": "eip155:84532",
"planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
"extra": {
"version": "1"
}
}
],
"extensions": {}
},
"x402AccessToken": "eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=",
"maxAmount": "2",
"agentRequestId": "arId-123e4567-e89b-12d3-a456-426614174000"
}
'import requests
url = "https://api.sandbox.nevermined.app/api/v1/x402/settle"
payload = {
"paymentRequired": {
"x402Version": 2,
"error": "Payment required to access resource",
"resource": {
"url": "/api/v1/agents/tasks",
"description": "AI agent task execution"
},
"accepts": [
{
"scheme": "nvm:erc4337",
"network": "eip155:84532",
"planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
"extra": { "version": "1" }
}
],
"extensions": {}
},
"x402AccessToken": "eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=",
"maxAmount": "2",
"agentRequestId": "arId-123e4567-e89b-12d3-a456-426614174000"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
paymentRequired: {
x402Version: 2,
error: 'Payment required to access resource',
resource: {url: '/api/v1/agents/tasks', description: 'AI agent task execution'},
accepts: [
{
scheme: 'nvm:erc4337',
network: 'eip155:84532',
planId: '44742763076047497640080230236781474129970992727896593861997347135613135571071',
extra: {version: '1'}
}
],
extensions: {}
},
x402AccessToken: 'eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=',
maxAmount: '2',
agentRequestId: 'arId-123e4567-e89b-12d3-a456-426614174000'
})
};
fetch('https://api.sandbox.nevermined.app/api/v1/x402/settle', 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.sandbox.nevermined.app/api/v1/x402/settle",
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([
'paymentRequired' => [
'x402Version' => 2,
'error' => 'Payment required to access resource',
'resource' => [
'url' => '/api/v1/agents/tasks',
'description' => 'AI agent task execution'
],
'accepts' => [
[
'scheme' => 'nvm:erc4337',
'network' => 'eip155:84532',
'planId' => '44742763076047497640080230236781474129970992727896593861997347135613135571071',
'extra' => [
'version' => '1'
]
]
],
'extensions' => [
]
],
'x402AccessToken' => 'eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=',
'maxAmount' => '2',
'agentRequestId' => 'arId-123e4567-e89b-12d3-a456-426614174000'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.sandbox.nevermined.app/api/v1/x402/settle"
payload := strings.NewReader("{\n \"paymentRequired\": {\n \"x402Version\": 2,\n \"error\": \"Payment required to access resource\",\n \"resource\": {\n \"url\": \"/api/v1/agents/tasks\",\n \"description\": \"AI agent task execution\"\n },\n \"accepts\": [\n {\n \"scheme\": \"nvm:erc4337\",\n \"network\": \"eip155:84532\",\n \"planId\": \"44742763076047497640080230236781474129970992727896593861997347135613135571071\",\n \"extra\": {\n \"version\": \"1\"\n }\n }\n ],\n \"extensions\": {}\n },\n \"x402AccessToken\": \"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=\",\n \"maxAmount\": \"2\",\n \"agentRequestId\": \"arId-123e4567-e89b-12d3-a456-426614174000\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.sandbox.nevermined.app/api/v1/x402/settle")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"paymentRequired\": {\n \"x402Version\": 2,\n \"error\": \"Payment required to access resource\",\n \"resource\": {\n \"url\": \"/api/v1/agents/tasks\",\n \"description\": \"AI agent task execution\"\n },\n \"accepts\": [\n {\n \"scheme\": \"nvm:erc4337\",\n \"network\": \"eip155:84532\",\n \"planId\": \"44742763076047497640080230236781474129970992727896593861997347135613135571071\",\n \"extra\": {\n \"version\": \"1\"\n }\n }\n ],\n \"extensions\": {}\n },\n \"x402AccessToken\": \"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=\",\n \"maxAmount\": \"2\",\n \"agentRequestId\": \"arId-123e4567-e89b-12d3-a456-426614174000\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nevermined.app/api/v1/x402/settle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"paymentRequired\": {\n \"x402Version\": 2,\n \"error\": \"Payment required to access resource\",\n \"resource\": {\n \"url\": \"/api/v1/agents/tasks\",\n \"description\": \"AI agent task execution\"\n },\n \"accepts\": [\n {\n \"scheme\": \"nvm:erc4337\",\n \"network\": \"eip155:84532\",\n \"planId\": \"44742763076047497640080230236781474129970992727896593861997347135613135571071\",\n \"extra\": {\n \"version\": \"1\"\n }\n }\n ],\n \"extensions\": {}\n },\n \"x402AccessToken\": \"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=\",\n \"maxAmount\": \"2\",\n \"agentRequestId\": \"arId-123e4567-e89b-12d3-a456-426614174000\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"errorReason": "<string>",
"payer": "<string>",
"transaction": "<string>",
"network": "eip155:84532",
"billingModel": "credits",
"creditsRedeemed": "2",
"remainingBalance": "98",
"orderTx": "pi_3TUrvfBYvSRKcV420xCBjHb1"
}Settle
Finalizes and records delegated permission usage after service delivery.
curl --request POST \
--url https://api.sandbox.nevermined.app/api/v1/x402/settle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"paymentRequired": {
"x402Version": 2,
"error": "Payment required to access resource",
"resource": {
"url": "/api/v1/agents/tasks",
"description": "AI agent task execution"
},
"accepts": [
{
"scheme": "nvm:erc4337",
"network": "eip155:84532",
"planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
"extra": {
"version": "1"
}
}
],
"extensions": {}
},
"x402AccessToken": "eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=",
"maxAmount": "2",
"agentRequestId": "arId-123e4567-e89b-12d3-a456-426614174000"
}
'import requests
url = "https://api.sandbox.nevermined.app/api/v1/x402/settle"
payload = {
"paymentRequired": {
"x402Version": 2,
"error": "Payment required to access resource",
"resource": {
"url": "/api/v1/agents/tasks",
"description": "AI agent task execution"
},
"accepts": [
{
"scheme": "nvm:erc4337",
"network": "eip155:84532",
"planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
"extra": { "version": "1" }
}
],
"extensions": {}
},
"x402AccessToken": "eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=",
"maxAmount": "2",
"agentRequestId": "arId-123e4567-e89b-12d3-a456-426614174000"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
paymentRequired: {
x402Version: 2,
error: 'Payment required to access resource',
resource: {url: '/api/v1/agents/tasks', description: 'AI agent task execution'},
accepts: [
{
scheme: 'nvm:erc4337',
network: 'eip155:84532',
planId: '44742763076047497640080230236781474129970992727896593861997347135613135571071',
extra: {version: '1'}
}
],
extensions: {}
},
x402AccessToken: 'eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=',
maxAmount: '2',
agentRequestId: 'arId-123e4567-e89b-12d3-a456-426614174000'
})
};
fetch('https://api.sandbox.nevermined.app/api/v1/x402/settle', 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.sandbox.nevermined.app/api/v1/x402/settle",
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([
'paymentRequired' => [
'x402Version' => 2,
'error' => 'Payment required to access resource',
'resource' => [
'url' => '/api/v1/agents/tasks',
'description' => 'AI agent task execution'
],
'accepts' => [
[
'scheme' => 'nvm:erc4337',
'network' => 'eip155:84532',
'planId' => '44742763076047497640080230236781474129970992727896593861997347135613135571071',
'extra' => [
'version' => '1'
]
]
],
'extensions' => [
]
],
'x402AccessToken' => 'eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=',
'maxAmount' => '2',
'agentRequestId' => 'arId-123e4567-e89b-12d3-a456-426614174000'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.sandbox.nevermined.app/api/v1/x402/settle"
payload := strings.NewReader("{\n \"paymentRequired\": {\n \"x402Version\": 2,\n \"error\": \"Payment required to access resource\",\n \"resource\": {\n \"url\": \"/api/v1/agents/tasks\",\n \"description\": \"AI agent task execution\"\n },\n \"accepts\": [\n {\n \"scheme\": \"nvm:erc4337\",\n \"network\": \"eip155:84532\",\n \"planId\": \"44742763076047497640080230236781474129970992727896593861997347135613135571071\",\n \"extra\": {\n \"version\": \"1\"\n }\n }\n ],\n \"extensions\": {}\n },\n \"x402AccessToken\": \"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=\",\n \"maxAmount\": \"2\",\n \"agentRequestId\": \"arId-123e4567-e89b-12d3-a456-426614174000\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.sandbox.nevermined.app/api/v1/x402/settle")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"paymentRequired\": {\n \"x402Version\": 2,\n \"error\": \"Payment required to access resource\",\n \"resource\": {\n \"url\": \"/api/v1/agents/tasks\",\n \"description\": \"AI agent task execution\"\n },\n \"accepts\": [\n {\n \"scheme\": \"nvm:erc4337\",\n \"network\": \"eip155:84532\",\n \"planId\": \"44742763076047497640080230236781474129970992727896593861997347135613135571071\",\n \"extra\": {\n \"version\": \"1\"\n }\n }\n ],\n \"extensions\": {}\n },\n \"x402AccessToken\": \"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=\",\n \"maxAmount\": \"2\",\n \"agentRequestId\": \"arId-123e4567-e89b-12d3-a456-426614174000\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.nevermined.app/api/v1/x402/settle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"paymentRequired\": {\n \"x402Version\": 2,\n \"error\": \"Payment required to access resource\",\n \"resource\": {\n \"url\": \"/api/v1/agents/tasks\",\n \"description\": \"AI agent task execution\"\n },\n \"accepts\": [\n {\n \"scheme\": \"nvm:erc4337\",\n \"network\": \"eip155:84532\",\n \"planId\": \"44742763076047497640080230236781474129970992727896593861997347135613135571071\",\n \"extra\": {\n \"version\": \"1\"\n }\n }\n ],\n \"extensions\": {}\n },\n \"x402AccessToken\": \"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiL2FwaS92MS9hZ2VudHMvdGFza3MifSwiYWNjZXB0ZWQiOnsic2NoZW1lIjoibnZtOmVyYzQzMzciLCJuZXR3b3JrIjoiZWlwMTU1Ojg0NTMyIiwicGxhbklkIjoiNDQ3NDI3NjMwNzYwNDc0OTc2NDAwODAyMzAyMzY3ODE0NzQxMjk5NzA5OTI3Mjc4OTY1OTM4NjE5OTczNDcxMzU2MTMxMzU1NzEwNzEiLCJleHRyYSI6eyJ2ZXJzaW9uIjoiMSJ9fSwicGF5bG9hZCI6eyJzaWduYXR1cmUiOiIweDEyMzQiLCJhdXRob3JpemF0aW9uIjp7ImZyb20iOiIweGYzOUZkNmU1MWFhZDg4RjZGNGNlNmFCODgyNzI3OWNmZkZiOTIyNjYiLCJzZXNzaW9uS2V5c1Byb3ZpZGVyIjoiemVyb2RldiIsInNlc3Npb25LZXlzIjpbXX19LCJleHRlbnNpb25zIjp7fX0=\",\n \"maxAmount\": \"2\",\n \"agentRequestId\": \"arId-123e4567-e89b-12d3-a456-426614174000\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"errorReason": "<string>",
"payer": "<string>",
"transaction": "<string>",
"network": "eip155:84532",
"billingModel": "credits",
"creditsRedeemed": "2",
"remainingBalance": "98",
"orderTx": "pi_3TUrvfBYvSRKcV420xCBjHb1"
}Authorizations
Your Nevermined API Key (starts with 'nvm:'). Get one at nevermined.app under Settings > API Keys.
Body
Settlement request
Body of POST /x402/settle — the same SettlePermissionsDto as verify. paymentRequired and x402AccessToken are both required and the handler runs a ValidationPipe, so a body missing either is rejected with 400 before settlement runs. planId, subscriberAddress, agentId, the endpoint and the HTTP verb are read out of the token — never sent alongside it.
The server's 402 PaymentRequired response. The facilitator validates that the scheme accepted inside the token matches one of accepts.
Show child attributes
Show child attributes
The x402 payment payload, base64-encoded — the token minted by POST /x402/permissions.
"eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiaHR0cHM6Ly9teWFnZW50LmFpL2FwaS92MS90YXNrcyJ9LCJhY2NlcHRlZCI6eyJzY2hlbWUiOiJudm06ZXJjNDMzNyIsIm5ldHdvcmsiOiJlaXAxNTU6ODQ1MzIiLCJwbGFuSWQiOiI0NDc0Mjc2MzA3NjA0NzQ5NzY0MDA4MDIzMDIzNjc4MTQ3NDEyOTk3MDk5MjcyNzg5NjU5Mzg2MTk5NzM0NzEzNTYxMzEzNTU3MTA3MSIsImV4dHJhIjp7InZlcnNpb24iOiIxIiwiYWdlbnRJZCI6IjgwOTE4NDI3MDIzMTcwNDI4MDI5NTQwMjYxMTE3MTk4MTU0NDY0NDk3ODc5MTQ1MjY3NzIwMjU5NDg4NTI5Njg1MDg5MTA0NTI5MDE1IiwiaHR0cFZlcmIiOiJQT1NUIn19LCJwYXlsb2FkIjp7InNpZ25hdHVyZSI6IjB4MTIzNCIsImF1dGhvcml6YXRpb24iOnsiZnJvbSI6IjB4ZjM5RmQ2ZTUxYWFkODhGNkY0Y2U2YUI4ODI3Mjc5Y2ZmRmI5MjI2NiIsInNlc3Npb25LZXlzUHJvdmlkZXIiOiJ6ZXJvZGV2Iiwic2Vzc2lvbktleXMiOltdfX0sImV4dGVuc2lvbnMiOnt9fQ=="
Maximum credits to redeem during settlement. Send it as a decimal STRING: the value is parsed with BigInt() and then required to be a bigint, so a JSON number is rejected with 400.
"2"
Agent request id for observability, as returned by POST /x402/verify. Bounded to 1–128 URL-safe ASCII characters because the value is interpolated into a Helicone filter and persisted to agent_tasks.
128^[a-zA-Z0-9\-_]{1,128}$"arId-123e4567-e89b-12d3-a456-426614174000"
Whether this settles a batch — several LLM calls made under one agentRequestId.
true
Margin percentage used for credit calculation. Mutually exclusive with maxAmount when agentRequestId is supplied.
0 <= x <= 100.2
Response
Settlement complete
Settlement receipt. success alone tells you the settle worked; what to check in addition depends on billingModel. On credits plans the payment shows up as creditsRedeemed > 0. On pay-as-you-go plans there is no credit balance, so creditsRedeemed and remainingBalance are always the string "0" even on a charge that succeeded — the proof there is success: true plus a non-empty orderTx (fiat rails) or transaction (crypto rails). Do not gate on creditsRedeemed without reading billingModel first: on a card rail that reports a real charge as a decline and invites a retry of a payment that already went through. Note the credit fields are strings, so "0" is truthy while Number("0") > 0 is false.
Whether settlement was successful.
Reason for settlement failure (only present if success is false).
Address of the payer's wallet.
Blockchain transaction hash. On crypto pay-as-you-go plans this is also the reference for the per-request charge.
Network identifier. The discriminator is the rail, not the billing model: a CAIP-2 chain id (eip155:84532) for crypto rails under both billing models, or the settling payment provider (stripe, braintree, visa) for fiat card-delegation rails.
"eip155:84532"
Which billing model this settle was priced under. Present regardless of success — check success before treating it as evidence of a charge. Read it before the two credit fields.
credits, pay-as-you-go Number of credits redeemed. Always "0" for pay-as-you-go plans, which hold no credit balance — including on a settle that charged the buyer successfully.
"2"
Subscriber's remaining credit balance. Always "0" for pay-as-you-go plans — the per-request charge is referenced by orderTx (fiat) or transaction (crypto), not here.
"98"
Reference for the order or per-request charge, if one occurred. On fiat pay-as-you-go this is the per-request charge (a Stripe PaymentIntent id, a Braintree transaction id); crypto pay-as-you-go reports its on-chain order in transaction instead. On credits plans it is set only when the settle had to order credits first (auto top-up).
"pi_3TUrvfBYvSRKcV420xCBjHb1"
Was this page helpful?