Create Policy
curl --request POST \
--url https://api.agentwallex.com/api/v1/policies \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "agent_abc123",
"type": "spending_limit",
"rules": {
"max_transaction_amount": "500",
"daily_limit": "5000",
"monthly_limit": "50000"
}
}
'import requests
url = "https://api.agentwallex.com/api/v1/policies"
payload = {
"agent_id": "agent_abc123",
"type": "spending_limit",
"rules": {
"max_transaction_amount": "500",
"daily_limit": "5000",
"monthly_limit": "50000"
}
}
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({
agent_id: 'agent_abc123',
type: 'spending_limit',
rules: {max_transaction_amount: '500', daily_limit: '5000', monthly_limit: '50000'}
})
};
fetch('https://api.agentwallex.com/api/v1/policies', 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/policies",
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([
'agent_id' => 'agent_abc123',
'type' => 'spending_limit',
'rules' => [
'max_transaction_amount' => '500',
'daily_limit' => '5000',
'monthly_limit' => '50000'
]
]),
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/policies"
payload := strings.NewReader("{\n \"agent_id\": \"agent_abc123\",\n \"type\": \"spending_limit\",\n \"rules\": {\n \"max_transaction_amount\": \"500\",\n \"daily_limit\": \"5000\",\n \"monthly_limit\": \"50000\"\n }\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/policies")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"agent_abc123\",\n \"type\": \"spending_limit\",\n \"rules\": {\n \"max_transaction_amount\": \"500\",\n \"daily_limit\": \"5000\",\n \"monthly_limit\": \"50000\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentwallex.com/api/v1/policies")
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 \"agent_id\": \"agent_abc123\",\n \"type\": \"spending_limit\",\n \"rules\": {\n \"max_transaction_amount\": \"500\",\n \"daily_limit\": \"5000\",\n \"monthly_limit\": \"50000\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"agent_id": "<string>",
"rules": {
"max_transaction_amount": "<string>",
"daily_limit": "<string>",
"monthly_limit": "<string>",
"allowed_addresses": [
"<string>"
],
"blocked_addresses": [
"<string>"
],
"allowed_tokens": [
"<string>"
],
"max_count": 123,
"window_seconds": 123,
"timezone": "<string>",
"allowed_hours": {
"start": 11,
"end": 11
},
"allowed_days": [
4
],
"threshold": "<string>",
"timeout_seconds": 123,
"approvers": [
"jsmith@example.com"
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"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": "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."
}策略
建立策略
建立新策略並將其附加到代理。
POST
/
api
/
v1
/
policies
Create Policy
curl --request POST \
--url https://api.agentwallex.com/api/v1/policies \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "agent_abc123",
"type": "spending_limit",
"rules": {
"max_transaction_amount": "500",
"daily_limit": "5000",
"monthly_limit": "50000"
}
}
'import requests
url = "https://api.agentwallex.com/api/v1/policies"
payload = {
"agent_id": "agent_abc123",
"type": "spending_limit",
"rules": {
"max_transaction_amount": "500",
"daily_limit": "5000",
"monthly_limit": "50000"
}
}
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({
agent_id: 'agent_abc123',
type: 'spending_limit',
rules: {max_transaction_amount: '500', daily_limit: '5000', monthly_limit: '50000'}
})
};
fetch('https://api.agentwallex.com/api/v1/policies', 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/policies",
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([
'agent_id' => 'agent_abc123',
'type' => 'spending_limit',
'rules' => [
'max_transaction_amount' => '500',
'daily_limit' => '5000',
'monthly_limit' => '50000'
]
]),
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/policies"
payload := strings.NewReader("{\n \"agent_id\": \"agent_abc123\",\n \"type\": \"spending_limit\",\n \"rules\": {\n \"max_transaction_amount\": \"500\",\n \"daily_limit\": \"5000\",\n \"monthly_limit\": \"50000\"\n }\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/policies")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"agent_abc123\",\n \"type\": \"spending_limit\",\n \"rules\": {\n \"max_transaction_amount\": \"500\",\n \"daily_limit\": \"5000\",\n \"monthly_limit\": \"50000\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentwallex.com/api/v1/policies")
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 \"agent_id\": \"agent_abc123\",\n \"type\": \"spending_limit\",\n \"rules\": {\n \"max_transaction_amount\": \"500\",\n \"daily_limit\": \"5000\",\n \"monthly_limit\": \"50000\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"agent_id": "<string>",
"rules": {
"max_transaction_amount": "<string>",
"daily_limit": "<string>",
"monthly_limit": "<string>",
"allowed_addresses": [
"<string>"
],
"blocked_addresses": [
"<string>"
],
"allowed_tokens": [
"<string>"
],
"max_count": 123,
"window_seconds": 123,
"timezone": "<string>",
"allowed_hours": {
"start": 11,
"end": 11
},
"allowed_days": [
4
],
"threshold": "<string>",
"timeout_seconds": 123,
"approvers": [
"jsmith@example.com"
]
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"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": "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."
}策略控制代理被允許執行的交易類型。每筆交易在 MPC 簽名之前都會根據代理的策略進行評估。
請求內容
string
必填
要附加此策略的代理。
string
必填
策略類型。值:
spending_limit、address_control、token_control、velocity_control、schedule、human_approval。object
必填
策略規則物件。結構取決於
type。顯示 代幣控制規則
顯示 代幣控制規則
string[]
允許的代幣符號(例如
["USDC", "USDT"])。顯示 時間排程規則
顯示 時間排程規則
範例
curl -X POST https://api.agentwallex.com/api/v1/policies \
-H "X-API-Key: awx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_abc123",
"type": "spending_limit",
"rules": {
"max_transaction_amount": "500",
"daily_limit": "5000",
"monthly_limit": "50000"
}
}'
授權
ApiKeyAuthBearerAuth
API key authentication. Keys are prefixed with awx_.
主體
application/json
回應
Policy created successfully.
A policy that controls what transactions an agent is allowed to execute.
Unique policy identifier (e.g., pol_abc123).
Agent this policy is attached to.
Policy type.
可用選項:
spending_limit, address_control, token_control, velocity_control, schedule, human_approval Policy rules object. Structure depends on the policy type.
Show child attributes
Show child attributes
ISO 8601 creation timestamp.
ISO 8601 last-update timestamp.
⌘I