Neynar Documentation
Send notifications
cURL
curl --request POST \
--url https://api.neynar.com/v2/farcaster/frame/notifications/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: NEYNAR_API_DOCS' \
--data '
{
"notification": {
"body": "You have received a new message in your inbox.",
"target_url": "https://example.com/notifications",
"title": "New Message",
"uuid": "123e4567-e89b-12d3-a456-426614174000"
},
"filters": {
"exclude_fids": [
2,
8988
],
"following_fid": 3,
"minimum_user_score": 0.5,
"near_location": {
"latitude": 37.774929,
"longitude": -122.419418,
"radius": 1000
}
},
"target_fids": [
1,
2,
3
]
}
'
Python
import requests
url = "https://api.neynar.com/v2/farcaster/frame/notifications/"
payload = {
"notification": {
"body": "You have received a new message in your inbox.",
"target_url": "https://example.com/notifications",
"title": "New Message",
"uuid": "123e4567-e89b-12d3-a456-426614174000"
},
"filters": {
"exclude_fids": [2, 8988],
"following_fid": 3,
"minimum_user_score": 0.5,
"near_location": {
"latitude": 37.774929,
"longitude": -122.419418,
"radius": 1000
}
},
"target_fids": [1, 2, 3]
}
headers = {
"x-api-key": "NEYNAR_API_DOCS",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {'x-api-key': 'NEYNAR_API_DOCS', 'Content-Type': 'application/json'},
body: JSON.stringify({
notification: {
body: JSON.stringify('You have received a new message in your inbox.'),
target_url: 'https://example.com/notifications',
title: 'New Message',
uuid: '123e4567-e89b-12d3-a456-426614174000'
},
filters: {
exclude_fids: [2, 8988],
following_fid: 3,
minimum_user_score: 0.5,
near_location: {latitude: 37.774929, longitude: -122.419418, radius: 1000}
},
target_fids: [1, 2, 3]
})
};
fetch('https://api.neynar.com/v2/farcaster/frame/notifications/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.neynar.com/v2/farcaster/frame/notifications/",
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([
'notification' => [
'body' => 'You have received a new message in your inbox.',
'target_url' => 'https://example.com/notifications',
'title' => 'New Message',
'uuid' => '123e4567-e89b-12d3-a456-426614174000'
],
'filters' => [
'exclude_fids' => [
2,
8988
],
'following_fid' => 3,
'minimum_user_score' => 0.5,
'near_location' => [
'latitude' => 37.774929,
'longitude' => -122.419418,
'radius' => 1000
]
],
'target_fids' => [
1,
2,
3
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: NEYNAR_API_DOCS"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Response
Success Response
Status Code: 200
{
"campaign_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"failure_count": 123,
"not_attempted_count": 123,
"success_count": 123,
"retryable_fids": [
3
]
}
Error Responses
{
"code": "InvalidField",
"errors": [
{
"code": "<string>",
"expected": "<string>",
"message": "<string>",
"path": [
"<string>"
],
"received": "<string>"
}
],
"message": "Invalid query parameters"
}