> For the complete documentation index, see [llms.txt](https://docs.usewuf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usewuf.com/reference/api-reference/push.md).

# Push

## Send a push notification to a user

## Send push notification

<mark style="color:green;">`POST`</mark> `https://api.usewuf.com/v1/push`

#### Request Body

| Name                                           | Type   | Description                                                          |
| ---------------------------------------------- | ------ | -------------------------------------------------------------------- |
| apiKey<mark style="color:red;">\*</mark>       | string | Your app API key                                                     |
| userKey<mark style="color:red;">\*</mark>      | string | The User key (one between userKey or userGroupKey is required)       |
| title<mark style="color:red;">\*</mark>        | string | Notification title                                                   |
| body<mark style="color:red;">\*</mark>         | string | Notification body                                                    |
| emoji                                          | String | Emoji to be shown in the title and as icon in the Wuf app            |
| image                                          | String | Optional image to be included in the notification                    |
| url                                            | String | Optional URL, shown in the Wuf app                                   |
| userGroupKey<mark style="color:red;">\*</mark> | String | The User Group Key (one between userKey or userGroupKey is required) |

{% tabs %}
{% tab title="200 Notification successfully sent" %}

```json
{
    "id": "cllld08g00001ky08yqf5qdozson"
}
```

{% endtab %}

{% tab title="401 Permission denied" %}

{% endtab %}
{% endtabs %}

Take a look at how you might call this method using different languages, or via `curl`:

{% tabs %}
{% tab title="curl" %}

```bash
curl https://api.usewuf.com/v1/push  
    -d apiKey='aeZVV0aaUA8y0Dqij_ptna'  
    -d userKey='uswXhaoDan2maAerZK9HZV'  
    -d title='New message received'  
    -d description='Hey, how are you doing?'
    -d emoji='💬'
    -d url='https://mychat.app/user/john'  
```

{% endtab %}

{% tab title="Node" %}

```javascript
const axios = require('axios');

const data = JSON.stringify({
  "apiKey": "aeZVV0aaUA8y0Dqij_ptna",
  "userKey": "uswXhaoDan2maAerZK9HZV",
  "title": "New report",
  "body": "Read the latest news",
  "emoji": "📈",
  "url": "https://mysite.com/report-2023",
});

var config = {
  method: 'post',
  url: 'https://api.usewuf.com/v1/push',
  headers: { 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import http.client
import json

# Setup connection
conn = http.client.HTTPSConnection("api.usewuf.com")

# Define the endpoint
endpoint = "/v1/push"

# Create payload
payload = {
    "apiKey": "aeZVV0aaUA8y0Dqij_ptna",
    "userKey": "uswXhaoDan2maAerZK9HZV",
    "title": "New report",
    "body": "Read the latest news",
    "emoji": "📈",
    "url": "https://mysite.com/report-2023",
}

# Convert the payload to a JSON string
headers = {
    'Content-Type': 'application/json'
}

# Send the POST request
conn.request("POST", endpoint, body=json.dumps(payload), headers=headers)

# Get the response
response = conn.getresponse()
data = response.read()

print(data.decode("utf-8"))

# Close the connection
conn.close()
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'
require 'json'

# Setup URI and HTTP
uri = URI.parse("https://api.usewuf.com/v1/push")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

# Create payload
payload = {
  "apiKey" => "aeZVV0aaUA8y0Dqij_ptna",
  "userKey" => "uswXhaoDan2maAerZK9HZV",
  "title" => "New report",
  "body" => "Read the latest news",
  "emoji" => "📈",
  "url" => "https://mysite.com/report-2023"
}

# Setup request
request = Net::HTTP::Post.new(uri.request_uri, {
  'Content-Type' => 'application/json'
})
request.body = payload.to_json

# Make the request
response = http.request(request)

puts response.body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://api.usewuf.com/v1/push"

    payload := map[string]interface{}{
        "apiKey":  "aeZVV0aaUA8y0Dqij_ptna",
        "userKey": "uswXhaoDan2maAerZK9HZV",
        "title":   "New report",
        "body":    "Read the latest news",
        "emoji":   "📈",
        "url":     "https://mysite.com/report-2023",
    }

    // Convert map to JSON
    data, err := json.Marshal(payload)
    if err != nil {
        fmt.Println("Error encoding payload:", err)
        return
    }

    req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }

    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error sending request:", err)
        return
    }
    defer resp.Body.Close()

    // Read the response body
    body, _ := ioutil.ReadAll(resp.Body)

    fmt.Println("Response:", string(body))
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$url = 'https://api.usewuf.com/v1/push';

// Payload
$data = array(
    "apiKey" => "aeZVV0aaUA8y0Dqij_ptna",
    "userKey" => "uswXhaoDan2maAerZK9HZV",
    "title" => "New report",
    "body" => "Read the latest news",
    "emoji" => "📈",
    "url" => "https://mysite.com/report-2023"
);

// Initialize cURL session
$ch = curl_init($url);

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json'
));

// Execute cURL session and get the response
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    echo $response;
}

// Close cURL session
curl_close($ch);

?>

```

{% endtab %}
{% endtabs %}
