# Quick Start

Wuf is the easiest way to send and receive mobile push notifications, both on iOS and Android devices. We support wearable devices too!

To send a mobile notification, you need an **API key** and a **User key**. Let's see how to obtain them.<br>

## Get the API key

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can generate an API key by creating a new app on the [Wuf Dashboard](https://usewuf.com/app), by clicking on the **Create app** button.

## Install the mobile apps

We have mobile apps for [iOS devices](https://apps.apple.com/us/app/wuf-push/id6462699610) (iPhone, and iPad) and for [Android devices](https://play.google.com/store/apps/details?id=com.pushtarget.app).

Once installed, you'll get a **User Key**.

## Get the User Key

A User key identifies a Wuf receiver account, and it is shared across different devices if the user logs in with the same account.

You and the users can get the User Key by installing the mobile app for [iOS](https://apps.apple.com/us/app/wuf-push/id6462699610) or [Android](https://play.google.com/store/apps/details?id=com.pushtarget.app).

The User Key will appear just after the Sign-in page on the first installation.

After that, the User Key will be accessible from the settings page, by clicking on the three dots icon.<br>

## Make your first request

To make your first request, send an authenticated request to the push endpoint.

## 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);

?>

```

PHP
{% endtab %}
{% endtabs %}
