Create order
curl --request POST \
--url https://api-sandbox.sohopay.xyz/v1/orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"merchant_id": "mch_3f2a1b0c",
"agent_id": "agt_7d1e5b2f",
"amount": "25.00",
"metadata": {
"sku": "api-credits-1000"
}
}
'import requests
url = "https://api-sandbox.sohopay.xyz/v1/orders"
payload = {
"merchant_id": "mch_3f2a1b0c",
"agent_id": "agt_7d1e5b2f",
"amount": "25.00",
"metadata": { "sku": "api-credits-1000" }
}
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({
merchant_id: 'mch_3f2a1b0c',
agent_id: 'agt_7d1e5b2f',
amount: '25.00',
metadata: {sku: 'api-credits-1000'}
})
};
fetch('https://api-sandbox.sohopay.xyz/v1/orders', 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.sohopay.xyz/v1/orders",
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([
'merchant_id' => 'mch_3f2a1b0c',
'agent_id' => 'agt_7d1e5b2f',
'amount' => '25.00',
'metadata' => [
'sku' => 'api-credits-1000'
]
]),
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.sohopay.xyz/v1/orders"
payload := strings.NewReader("{\n \"merchant_id\": \"mch_3f2a1b0c\",\n \"agent_id\": \"agt_7d1e5b2f\",\n \"amount\": \"25.00\",\n \"metadata\": {\n \"sku\": \"api-credits-1000\"\n }\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.sohopay.xyz/v1/orders")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"merchant_id\": \"mch_3f2a1b0c\",\n \"agent_id\": \"agt_7d1e5b2f\",\n \"amount\": \"25.00\",\n \"metadata\": {\n \"sku\": \"api-credits-1000\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.sohopay.xyz/v1/orders")
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 \"merchant_id\": \"mch_3f2a1b0c\",\n \"agent_id\": \"agt_7d1e5b2f\",\n \"amount\": \"25.00\",\n \"metadata\": {\n \"sku\": \"api-credits-1000\"\n }\n}"
response = http.request(request)
puts response.read_body{
"order_id": "ord_9f8e7d6c",
"merchant_id": "mch_3f2a1b0c",
"agent_id": "agt_7d1e5b2f",
"amount": "25.00",
"status": "pending",
"settlement_address": "0x2f3a4b5c6d7e8f901a2b3c4d5e6f7a8b9c0d1e2f",
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "INSUFFICIENT_CREDIT",
"message": "Agent agt_7d1e5b2f has 12.50 USDC available; order requires 25.00 USDC.",
"request_id": "req_01j8x9y2z3"
}
}{
"error": {
"code": "INSUFFICIENT_CREDIT",
"message": "Agent agt_7d1e5b2f has 12.50 USDC available; order requires 25.00 USDC.",
"request_id": "req_01j8x9y2z3"
}
}{
"error": {
"code": "INSUFFICIENT_CREDIT",
"message": "Agent agt_7d1e5b2f has 12.50 USDC available; order requires 25.00 USDC.",
"request_id": "req_01j8x9y2z3"
}
}Orders
Create order
Creates a payment order that an agent can fulfill. Orders expire after 10 minutes. The response includes the x402 payment requirements the agent uses to construct its signature.
POST
/
orders
Create order
curl --request POST \
--url https://api-sandbox.sohopay.xyz/v1/orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"merchant_id": "mch_3f2a1b0c",
"agent_id": "agt_7d1e5b2f",
"amount": "25.00",
"metadata": {
"sku": "api-credits-1000"
}
}
'import requests
url = "https://api-sandbox.sohopay.xyz/v1/orders"
payload = {
"merchant_id": "mch_3f2a1b0c",
"agent_id": "agt_7d1e5b2f",
"amount": "25.00",
"metadata": { "sku": "api-credits-1000" }
}
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({
merchant_id: 'mch_3f2a1b0c',
agent_id: 'agt_7d1e5b2f',
amount: '25.00',
metadata: {sku: 'api-credits-1000'}
})
};
fetch('https://api-sandbox.sohopay.xyz/v1/orders', 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.sohopay.xyz/v1/orders",
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([
'merchant_id' => 'mch_3f2a1b0c',
'agent_id' => 'agt_7d1e5b2f',
'amount' => '25.00',
'metadata' => [
'sku' => 'api-credits-1000'
]
]),
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.sohopay.xyz/v1/orders"
payload := strings.NewReader("{\n \"merchant_id\": \"mch_3f2a1b0c\",\n \"agent_id\": \"agt_7d1e5b2f\",\n \"amount\": \"25.00\",\n \"metadata\": {\n \"sku\": \"api-credits-1000\"\n }\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.sohopay.xyz/v1/orders")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"merchant_id\": \"mch_3f2a1b0c\",\n \"agent_id\": \"agt_7d1e5b2f\",\n \"amount\": \"25.00\",\n \"metadata\": {\n \"sku\": \"api-credits-1000\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.sohopay.xyz/v1/orders")
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 \"merchant_id\": \"mch_3f2a1b0c\",\n \"agent_id\": \"agt_7d1e5b2f\",\n \"amount\": \"25.00\",\n \"metadata\": {\n \"sku\": \"api-credits-1000\"\n }\n}"
response = http.request(request)
puts response.read_body{
"order_id": "ord_9f8e7d6c",
"merchant_id": "mch_3f2a1b0c",
"agent_id": "agt_7d1e5b2f",
"amount": "25.00",
"status": "pending",
"settlement_address": "0x2f3a4b5c6d7e8f901a2b3c4d5e6f7a8b9c0d1e2f",
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "INSUFFICIENT_CREDIT",
"message": "Agent agt_7d1e5b2f has 12.50 USDC available; order requires 25.00 USDC.",
"request_id": "req_01j8x9y2z3"
}
}{
"error": {
"code": "INSUFFICIENT_CREDIT",
"message": "Agent agt_7d1e5b2f has 12.50 USDC available; order requires 25.00 USDC.",
"request_id": "req_01j8x9y2z3"
}
}{
"error": {
"code": "INSUFFICIENT_CREDIT",
"message": "Agent agt_7d1e5b2f has 12.50 USDC available; order requires 25.00 USDC.",
"request_id": "req_01j8x9y2z3"
}
}Authorizations
API key as Bearer token. Sandbox keys start with sk_test_, mainnet keys with sk_live_.
Headers
Unique key to make retries safe. Strongly recommended for all write requests.
Body
application/json
Response
Order created
Example:
"ord_9f8e7d6c"
Example:
"mch_3f2a1b0c"
Example:
"agt_7d1e5b2f"
Example:
"25.00"
Available options:
pending, paid, expired, failed Example:
"pending"
Example:
"0x2f3a4b5c6d7e8f901a2b3c4d5e6f7a8b9c0d1e2f"
Orders expire 10 minutes after creation
⌘I

