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."
}Chính sách
Tạo chính sách
Tạo chính sách mới và gắn vào một agent.
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."
}Chính sách kiểm soát các giao dịch mà agent được phép thực hiện. Mọi giao dịch đều được đánh giá theo các chính sách của agent trước khi ký MPC.
Nội dung yêu cầu
string
bắt buộc
Agent để gắn chính sách này.
string
bắt buộc
Loại chính sách. Giá trị:
spending_limit, address_control, token_control, velocity_control, schedule, human_approval.object
bắt buộc
Đối tượng quy tắc chính sách. Cấu trúc phụ thuộc vào
type.Hiện Quy tắc giới hạn chi tiêu
Hiện Quy tắc giới hạn chi tiêu
Hiện Quy tắc kiểm soát địa chỉ
Hiện Quy tắc kiểm soát địa chỉ
Hiện Quy tắc kiểm soát token
Hiện Quy tắc kiểm soát token
string[]
Các ký hiệu token được phép (ví dụ:
["USDC", "USDT"]).Hiện Quy tắc kiểm soát tần suất
Hiện Quy tắc kiểm soát tần suất
Hiện Quy tắc lịch trình
Hiện Quy tắc lịch trình
Ví dụ
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"
}
}'
Ủy quyền
ApiKeyAuthBearerAuth
API key authentication. Keys are prefixed with awx_.
Nội dung
application/json
Phản hồi
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.
Tùy chọn có sẵn:
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