Payment intents
curl --request POST \
--url https://api.compose.market/api/payments/prepare \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-chain-id: <x-chain-id>' \
--data '
{
"service": "<string>",
"action": "<string>",
"resource": "<string>",
"method": "<string>",
"maxAmountWei": "<string>",
"meter": {},
"runId": "<string>",
"idempotencyKey": "<string>",
"modelId": "<string>",
"provider": "<string>",
"modality": "<string>",
"usage": {},
"media": {}
}
'import requests
url = "https://api.compose.market/api/payments/prepare"
payload = {
"service": "<string>",
"action": "<string>",
"resource": "<string>",
"method": "<string>",
"maxAmountWei": "<string>",
"meter": {},
"runId": "<string>",
"idempotencyKey": "<string>",
"modelId": "<string>",
"provider": "<string>",
"modality": "<string>",
"usage": {},
"media": {}
}
headers = {
"Authorization": "<authorization>",
"x-chain-id": "<x-chain-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: '<authorization>',
'x-chain-id': '<x-chain-id>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
service: '<string>',
action: '<string>',
resource: '<string>',
method: '<string>',
maxAmountWei: '<string>',
meter: {},
runId: '<string>',
idempotencyKey: '<string>',
modelId: '<string>',
provider: '<string>',
modality: '<string>',
usage: {},
media: {}
})
};
fetch('https://api.compose.market/api/payments/prepare', 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.compose.market/api/payments/prepare",
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([
'service' => '<string>',
'action' => '<string>',
'resource' => '<string>',
'method' => '<string>',
'maxAmountWei' => '<string>',
'meter' => [
],
'runId' => '<string>',
'idempotencyKey' => '<string>',
'modelId' => '<string>',
'provider' => '<string>',
'modality' => '<string>',
'usage' => [
],
'media' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"x-chain-id: <x-chain-id>"
],
]);
$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.compose.market/api/payments/prepare"
payload := strings.NewReader("{\n \"service\": \"<string>\",\n \"action\": \"<string>\",\n \"resource\": \"<string>\",\n \"method\": \"<string>\",\n \"maxAmountWei\": \"<string>\",\n \"meter\": {},\n \"runId\": \"<string>\",\n \"idempotencyKey\": \"<string>\",\n \"modelId\": \"<string>\",\n \"provider\": \"<string>\",\n \"modality\": \"<string>\",\n \"usage\": {},\n \"media\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("x-chain-id", "<x-chain-id>")
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.compose.market/api/payments/prepare")
.header("Authorization", "<authorization>")
.header("x-chain-id", "<x-chain-id>")
.header("Content-Type", "application/json")
.body("{\n \"service\": \"<string>\",\n \"action\": \"<string>\",\n \"resource\": \"<string>\",\n \"method\": \"<string>\",\n \"maxAmountWei\": \"<string>\",\n \"meter\": {},\n \"runId\": \"<string>\",\n \"idempotencyKey\": \"<string>\",\n \"modelId\": \"<string>\",\n \"provider\": \"<string>\",\n \"modality\": \"<string>\",\n \"usage\": {},\n \"media\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compose.market/api/payments/prepare")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["x-chain-id"] = '<x-chain-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"service\": \"<string>\",\n \"action\": \"<string>\",\n \"resource\": \"<string>\",\n \"method\": \"<string>\",\n \"maxAmountWei\": \"<string>\",\n \"meter\": {},\n \"runId\": \"<string>\",\n \"idempotencyKey\": \"<string>\",\n \"modelId\": \"<string>\",\n \"provider\": \"<string>\",\n \"modality\": \"<string>\",\n \"usage\": {},\n \"media\": {}\n}"
response = http.request(request)
puts response.read_bodyPayments & x402
Payment intents
Prepare, settle, abort, and price metered payment intents.
POST
/
api
/
payments
/
prepare
Payment intents
curl --request POST \
--url https://api.compose.market/api/payments/prepare \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-chain-id: <x-chain-id>' \
--data '
{
"service": "<string>",
"action": "<string>",
"resource": "<string>",
"method": "<string>",
"maxAmountWei": "<string>",
"meter": {},
"runId": "<string>",
"idempotencyKey": "<string>",
"modelId": "<string>",
"provider": "<string>",
"modality": "<string>",
"usage": {},
"media": {}
}
'import requests
url = "https://api.compose.market/api/payments/prepare"
payload = {
"service": "<string>",
"action": "<string>",
"resource": "<string>",
"method": "<string>",
"maxAmountWei": "<string>",
"meter": {},
"runId": "<string>",
"idempotencyKey": "<string>",
"modelId": "<string>",
"provider": "<string>",
"modality": "<string>",
"usage": {},
"media": {}
}
headers = {
"Authorization": "<authorization>",
"x-chain-id": "<x-chain-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: '<authorization>',
'x-chain-id': '<x-chain-id>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
service: '<string>',
action: '<string>',
resource: '<string>',
method: '<string>',
maxAmountWei: '<string>',
meter: {},
runId: '<string>',
idempotencyKey: '<string>',
modelId: '<string>',
provider: '<string>',
modality: '<string>',
usage: {},
media: {}
})
};
fetch('https://api.compose.market/api/payments/prepare', 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.compose.market/api/payments/prepare",
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([
'service' => '<string>',
'action' => '<string>',
'resource' => '<string>',
'method' => '<string>',
'maxAmountWei' => '<string>',
'meter' => [
],
'runId' => '<string>',
'idempotencyKey' => '<string>',
'modelId' => '<string>',
'provider' => '<string>',
'modality' => '<string>',
'usage' => [
],
'media' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"x-chain-id: <x-chain-id>"
],
]);
$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.compose.market/api/payments/prepare"
payload := strings.NewReader("{\n \"service\": \"<string>\",\n \"action\": \"<string>\",\n \"resource\": \"<string>\",\n \"method\": \"<string>\",\n \"maxAmountWei\": \"<string>\",\n \"meter\": {},\n \"runId\": \"<string>\",\n \"idempotencyKey\": \"<string>\",\n \"modelId\": \"<string>\",\n \"provider\": \"<string>\",\n \"modality\": \"<string>\",\n \"usage\": {},\n \"media\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("x-chain-id", "<x-chain-id>")
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.compose.market/api/payments/prepare")
.header("Authorization", "<authorization>")
.header("x-chain-id", "<x-chain-id>")
.header("Content-Type", "application/json")
.body("{\n \"service\": \"<string>\",\n \"action\": \"<string>\",\n \"resource\": \"<string>\",\n \"method\": \"<string>\",\n \"maxAmountWei\": \"<string>\",\n \"meter\": {},\n \"runId\": \"<string>\",\n \"idempotencyKey\": \"<string>\",\n \"modelId\": \"<string>\",\n \"provider\": \"<string>\",\n \"modality\": \"<string>\",\n \"usage\": {},\n \"media\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compose.market/api/payments/prepare")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["x-chain-id"] = '<x-chain-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"service\": \"<string>\",\n \"action\": \"<string>\",\n \"resource\": \"<string>\",\n \"method\": \"<string>\",\n \"maxAmountWei\": \"<string>\",\n \"meter\": {},\n \"runId\": \"<string>\",\n \"idempotencyKey\": \"<string>\",\n \"modelId\": \"<string>\",\n \"provider\": \"<string>\",\n \"modality\": \"<string>\",\n \"usage\": {},\n \"media\": {}\n}"
response = http.request(request)
puts response.read_bodyPayment intent routes are used by gateway surfaces that reserve a budget before work and settle the final metered amount after work.
Amounts are USDC atomic units with 6 decimals.
Routes
| Method | Path | Description |
|---|---|---|
POST | /api/payments/prepare | Authorize a payment intent from a Compose Key. |
POST | /api/payments/settle | Settle a prepared intent. |
POST | /api/payments/abort | Abort a prepared intent without settlement. |
POST | /api/payments/meter/model | Compute metered cost for a model output. |
Prepare body
string
required
Service namespace, such as
agent, workflow, or inference.string
required
Action name within the service.
string
required
Resource URL or identifier being paid for.
string
required
HTTP method being paid for.
string
Maximum authorized USDC atomic amount.
object
Metered settlement shape:
subject plus lineItems.string
Optional caller run ID.
string
Optional caller idempotency key.
Headers
string
required
Bearer compose-....number
required
Chain ID used for the payment intent.
Meter body
string
required
Public catalog model ID.
string
Optional provider override for exact provider billing resolution.
string
required
Output modality to bill.
object
Token or provider usage metadata.
object
Media evidence for image, audio, video, or other non-token billing.
⌘I