Create policy
curl --request POST \
--url https://api.privy.io/v1/policies \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '
{
"version": "1.0",
"name": "<string>",
"rules": [
{
"name": "<string>",
"conditions": [
{
"field_source": "ethereum_transaction",
"value": "<string>"
}
],
"id": "<string>"
}
],
"owner": {
"user_id": "<string>"
},
"owner_id": "<string>"
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/policies")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"version\": \"1.0\",\n \"name\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"value\": \"<string>\"\n }\n ],\n \"id\": \"<string>\"\n }\n ],\n \"owner\": {\n \"user_id\": \"<string>\"\n },\n \"owner_id\": \"<string>\"\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
version: '1.0',
name: '<string>',
rules: [
{
name: '<string>',
conditions: [{field_source: 'ethereum_transaction', value: '<string>'}],
id: '<string>'
}
],
owner: {user_id: '<string>'},
owner_id: '<string>'
})
};
fetch('https://api.privy.io/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.privy.io/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([
'version' => '1.0',
'name' => '<string>',
'rules' => [
[
'name' => '<string>',
'conditions' => [
[
'field_source' => 'ethereum_transaction',
'value' => '<string>'
]
],
'id' => '<string>'
]
],
'owner' => [
'user_id' => '<string>'
],
'owner_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-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.privy.io/v1/policies"
payload := strings.NewReader("{\n \"version\": \"1.0\",\n \"name\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"value\": \"<string>\"\n }\n ],\n \"id\": \"<string>\"\n }\n ],\n \"owner\": {\n \"user_id\": \"<string>\"\n },\n \"owner_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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))
}{
"id": "tb54eps4z44ed0jepousxi4n",
"name": "Allowlisted stablecoins",
"chain_type": "ethereum",
"rules": [
{
"id": "bdyfoa65pro1eez6iwtzanol",
"name": "Allowlist USDC contract on Base",
"method": "eth_sendTransaction",
"conditions": [
{
"field_source": "ethereum_transaction",
"field": "to",
"operator": "eq",
"value": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
],
"action": "ALLOW"
}
],
"owner_id": null,
"version": "1.0",
"created_at": 1741833088894
}Policies
Create policy
Create a new policy.
POST
/
v1
/
policies
Create policy
curl --request POST \
--url https://api.privy.io/v1/policies \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '
{
"version": "1.0",
"name": "<string>",
"rules": [
{
"name": "<string>",
"conditions": [
{
"field_source": "ethereum_transaction",
"value": "<string>"
}
],
"id": "<string>"
}
],
"owner": {
"user_id": "<string>"
},
"owner_id": "<string>"
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/policies")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"version\": \"1.0\",\n \"name\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"value\": \"<string>\"\n }\n ],\n \"id\": \"<string>\"\n }\n ],\n \"owner\": {\n \"user_id\": \"<string>\"\n },\n \"owner_id\": \"<string>\"\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
version: '1.0',
name: '<string>',
rules: [
{
name: '<string>',
conditions: [{field_source: 'ethereum_transaction', value: '<string>'}],
id: '<string>'
}
],
owner: {user_id: '<string>'},
owner_id: '<string>'
})
};
fetch('https://api.privy.io/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.privy.io/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([
'version' => '1.0',
'name' => '<string>',
'rules' => [
[
'name' => '<string>',
'conditions' => [
[
'field_source' => 'ethereum_transaction',
'value' => '<string>'
]
],
'id' => '<string>'
]
],
'owner' => [
'user_id' => '<string>'
],
'owner_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-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.privy.io/v1/policies"
payload := strings.NewReader("{\n \"version\": \"1.0\",\n \"name\": \"<string>\",\n \"rules\": [\n {\n \"name\": \"<string>\",\n \"conditions\": [\n {\n \"field_source\": \"ethereum_transaction\",\n \"value\": \"<string>\"\n }\n ],\n \"id\": \"<string>\"\n }\n ],\n \"owner\": {\n \"user_id\": \"<string>\"\n },\n \"owner_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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))
}{
"id": "tb54eps4z44ed0jepousxi4n",
"name": "Allowlisted stablecoins",
"chain_type": "ethereum",
"rules": [
{
"id": "bdyfoa65pro1eez6iwtzanol",
"name": "Allowlist USDC contract on Base",
"method": "eth_sendTransaction",
"conditions": [
{
"field_source": "ethereum_transaction",
"field": "to",
"operator": "eq",
"value": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
],
"action": "ALLOW"
}
],
"owner_id": null,
"version": "1.0",
"created_at": 1741833088894
}SDK methods
Learn more about creating policies using our SDKs here.Authorizations
Headers
Body
application/json
Response
200 - application/json
Created policy object.
A policy for controlling wallet operations.
Was this page helpful?

