Skip to main content
POST
/
automation-rules
Create automation rule
curl --request POST \
  --url https://api.fernhq.com/automation-rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Sweep when over 5000 USDC",
  "customerId": "da1f853f-b083-40f3-b729-30c99826e4ed",
  "transactionTemplate": {
    "source": {
      "sourcePaymentAccountId": "072a8b7b-38c7-429a-a6cf-35dae7f2fb77",
      "sourcePaymentMethod": "ACH",
      "sourceCurrency": "USD"
    },
    "destination": {
      "destinationPaymentAccountId": "072a8b7b-38c7-429a-a6cf-35dae7f2fb77",
      "destinationPaymentMethod": "ETHEREUM",
      "destinationCurrency": "USD"
    },
    "amount": {
      "value": "<string>"
    }
  },
  "trigger": {
    "cronSchedule": "* * * * *",
    "thresholdAmount": "5000"
  }
}
'
import requests

url = "https://api.fernhq.com/automation-rules"

payload = {
"name": "Sweep when over 5000 USDC",
"customerId": "da1f853f-b083-40f3-b729-30c99826e4ed",
"transactionTemplate": {
"source": {
"sourcePaymentAccountId": "072a8b7b-38c7-429a-a6cf-35dae7f2fb77",
"sourcePaymentMethod": "ACH",
"sourceCurrency": "USD"
},
"destination": {
"destinationPaymentAccountId": "072a8b7b-38c7-429a-a6cf-35dae7f2fb77",
"destinationPaymentMethod": "ETHEREUM",
"destinationCurrency": "USD"
},
"amount": { "value": "<string>" }
},
"trigger": {
"cronSchedule": "* * * * *",
"thresholdAmount": "5000"
}
}
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({
name: 'Sweep when over 5000 USDC',
customerId: 'da1f853f-b083-40f3-b729-30c99826e4ed',
transactionTemplate: {
source: {
sourcePaymentAccountId: '072a8b7b-38c7-429a-a6cf-35dae7f2fb77',
sourcePaymentMethod: 'ACH',
sourceCurrency: 'USD'
},
destination: {
destinationPaymentAccountId: '072a8b7b-38c7-429a-a6cf-35dae7f2fb77',
destinationPaymentMethod: 'ETHEREUM',
destinationCurrency: 'USD'
},
amount: {value: '<string>'}
},
trigger: {cronSchedule: '* * * * *', thresholdAmount: '5000'}
})
};

fetch('https://api.fernhq.com/automation-rules', 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.fernhq.com/automation-rules",
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([
'name' => 'Sweep when over 5000 USDC',
'customerId' => 'da1f853f-b083-40f3-b729-30c99826e4ed',
'transactionTemplate' => [
'source' => [
'sourcePaymentAccountId' => '072a8b7b-38c7-429a-a6cf-35dae7f2fb77',
'sourcePaymentMethod' => 'ACH',
'sourceCurrency' => 'USD'
],
'destination' => [
'destinationPaymentAccountId' => '072a8b7b-38c7-429a-a6cf-35dae7f2fb77',
'destinationPaymentMethod' => 'ETHEREUM',
'destinationCurrency' => 'USD'
],
'amount' => [
'value' => '<string>'
]
],
'trigger' => [
'cronSchedule' => '* * * * *',
'thresholdAmount' => '5000'
]
]),
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.fernhq.com/automation-rules"

payload := strings.NewReader("{\n \"name\": \"Sweep when over 5000 USDC\",\n \"customerId\": \"da1f853f-b083-40f3-b729-30c99826e4ed\",\n \"transactionTemplate\": {\n \"source\": {\n \"sourcePaymentAccountId\": \"072a8b7b-38c7-429a-a6cf-35dae7f2fb77\",\n \"sourcePaymentMethod\": \"ACH\",\n \"sourceCurrency\": \"USD\"\n },\n \"destination\": {\n \"destinationPaymentAccountId\": \"072a8b7b-38c7-429a-a6cf-35dae7f2fb77\",\n \"destinationPaymentMethod\": \"ETHEREUM\",\n \"destinationCurrency\": \"USD\"\n },\n \"amount\": {\n \"value\": \"<string>\"\n }\n },\n \"trigger\": {\n \"cronSchedule\": \"* * * * *\",\n \"thresholdAmount\": \"5000\"\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.fernhq.com/automation-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sweep when over 5000 USDC\",\n \"customerId\": \"da1f853f-b083-40f3-b729-30c99826e4ed\",\n \"transactionTemplate\": {\n \"source\": {\n \"sourcePaymentAccountId\": \"072a8b7b-38c7-429a-a6cf-35dae7f2fb77\",\n \"sourcePaymentMethod\": \"ACH\",\n \"sourceCurrency\": \"USD\"\n },\n \"destination\": {\n \"destinationPaymentAccountId\": \"072a8b7b-38c7-429a-a6cf-35dae7f2fb77\",\n \"destinationPaymentMethod\": \"ETHEREUM\",\n \"destinationCurrency\": \"USD\"\n },\n \"amount\": {\n \"value\": \"<string>\"\n }\n },\n \"trigger\": {\n \"cronSchedule\": \"* * * * *\",\n \"thresholdAmount\": \"5000\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.fernhq.com/automation-rules")

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 \"name\": \"Sweep when over 5000 USDC\",\n \"customerId\": \"da1f853f-b083-40f3-b729-30c99826e4ed\",\n \"transactionTemplate\": {\n \"source\": {\n \"sourcePaymentAccountId\": \"072a8b7b-38c7-429a-a6cf-35dae7f2fb77\",\n \"sourcePaymentMethod\": \"ACH\",\n \"sourceCurrency\": \"USD\"\n },\n \"destination\": {\n \"destinationPaymentAccountId\": \"072a8b7b-38c7-429a-a6cf-35dae7f2fb77\",\n \"destinationPaymentMethod\": \"ETHEREUM\",\n \"destinationCurrency\": \"USD\"\n },\n \"amount\": {\n \"value\": \"<string>\"\n }\n },\n \"trigger\": {\n \"cronSchedule\": \"* * * * *\",\n \"thresholdAmount\": \"5000\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "rule_ghi789",
  "name": "Sweep when over 5000 USDC",
  "customerId": "da1f853f-b083-40f3-b729-30c99826e4ed",
  "transactionTemplate": {
    "source": {
      "sourcePaymentAccountId": "072a8b7b-38c7-429a-a6cf-35dae7f2fb77",
      "sourcePaymentMethod": "ACH",
      "sourceCurrency": {
        "label": "USDC",
        "chain": "ETHEREUM",
        "contractAddress": "0x123456789abcd123456789abcd123456789abcd",
        "currencyDecimals": 18
      }
    },
    "destination": {
      "destinationPaymentAccountId": "072a8b7b-38c7-429a-a6cf-35dae7f2fb77",
      "destinationPaymentMethod": "ETHEREUM",
      "destinationCurrency": {
        "label": "USDC",
        "chain": "ETHEREUM",
        "contractAddress": "0x123456789abcd123456789abcd123456789abcd",
        "currencyDecimals": 18
      }
    },
    "amount": {
      "value": "<string>"
    },
    "developerFee": {
      "developerFeeAmount": "5.45"
    }
  },
  "trigger": {
    "cronSchedule": "* * * * *",
    "thresholdAmount": "5000"
  },
  "createdAt": "2025-09-12T12:00:00Z"
}

Authorizations

Authorization
string
header
required

To authenticate server-side requests

Body

application/json

Request schema for creating a new automation rule

Request schema for creating a new automation rule

name
string
required

Human-readable name for the automation rule

Example:

"Sweep when over 5000 USDC"

customerId
string<uuid>
required

ID of the customer who owns this automation rule

Example:

"da1f853f-b083-40f3-b729-30c99826e4ed"

transactionTemplate
Transaction Template Schema · object
required

Template configuration for transactions created by automation rule

trigger
Trigger Schema · object
required

Trigger configuration for automation rules

Response

Response schema for retrieving an automation rule

Configuration for automated transaction execution

id
string
required

Unique identifier for the automation rule

Example:

"rule_ghi789"

name
string
required

Human-readable name for the automation rule

Example:

"Sweep when over 5000 USDC"

customerId
string<uuid>
required

ID of the customer who owns this automation rule

Example:

"da1f853f-b083-40f3-b729-30c99826e4ed"

transactionTemplate
Transaction Template Response Schema · object
required

Template configuration for transactions created by automation rule

trigger
Trigger Schema · object
required

Trigger configuration for automation rules

createdAt
string

ISO timestamp when this automation rule was created

Example:

"2025-09-12T12:00:00Z"