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."
}Políticas
Crear política
Cree una nueva política y asóciela a un agente.
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."
}Las políticas controlan qué transacciones puede ejecutar un agente. Cada transacción se evalúa según las políticas del agente antes de la firma MPC.
Cuerpo de la solicitud
string
requerido
Agente al que se asociará esta política.
string
requerido
Tipo de política. Valores:
spending_limit, address_control, token_control, velocity_control, schedule, human_approval.object
requerido
Objeto de reglas de la política. La estructura depende de
type.Mostrar Reglas de límite de gasto
Mostrar Reglas de límite de gasto
Mostrar Reglas de control de direcciones
Mostrar Reglas de control de direcciones
Mostrar Reglas de control de tokens
Mostrar Reglas de control de tokens
string[]
Símbolos de tokens permitidos (por ejemplo,
["USDC", "USDT"]).Mostrar Reglas de control de frecuencia
Mostrar Reglas de control de frecuencia
Mostrar Reglas de horario
Mostrar Reglas de horario
Ejemplo
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"
}
}'
Autorizaciones
ApiKeyAuthBearerAuth
API key authentication. Keys are prefixed with awx_.
Cuerpo
application/json
Agent to attach this policy to.
Policy type.
Opciones disponibles:
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
Respuesta
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.
Opciones disponibles:
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