Créer avec une pièce jointe POST Payant
Envoyez une notification push avec un fichier image en pièce jointe.
Fonctionnalité payante
Ce point de terminaison n’est disponible que pour les offres payantes.
Point de terminaison
POST https://api.pocketalert.app/v1/messagesAuthentification
Obligatoire
Incluez l’un de ces en-têtes dans votre requête :
Requête
En-têtes
| En-tête | Obligatoire | Description |
|---|---|---|
Content-Type | ✅ | multipart/form-data |
Token | ✅ | Votre clé API |
Paramètres du corps (multipart/form-data)
| Paramètre | Type | Obligatoire | Description |
|---|---|---|---|
title | string | ✅ | Titre de la notification |
message | string | ✅ | Texte du corps de la notification |
application_id | string | ❌ | TID de l’application |
device_id | string | ❌ | TID de l’appareil (à omettre pour tous) |
image | file | ❌ | Image en pièce jointe (.png, .jpg, .jpeg, .gif) |
Exemple de requête
bash
curl -X POST "https://api.pocketalert.app/v1/messages" \
-H "Token: your-api-key" \
-F "title=Screenshot Alert" \
-F "message=New screenshot captured" \
-F "image=@/path/to/screenshot.png"javascript
const formData = new FormData();
formData.append('title', 'Screenshot Alert');
formData.append('message', 'New screenshot captured');
formData.append('image', fileInput.files[0]);
const response = await fetch('https://api.pocketalert.app/v1/messages', {
method: 'POST',
headers: { 'Token': 'your-api-key' },
body: formData
});python
import requests
with open('screenshot.png', 'rb') as f:
response = requests.post(
'https://api.pocketalert.app/v1/messages',
headers={'Token': 'your-api-key'},
data={
'title': 'Screenshot Alert',
'message': 'New screenshot captured'
},
files={'image': f}
)
print(response.json())php
$response = Http::withHeaders([
'Token' => 'your-api-key',
])->attach(
'image', file_get_contents('/path/to/screenshot.png'), 'screenshot.png'
)->post('https://api.pocketalert.app/v1/messages', [
'title' => 'Screenshot Alert',
'message' => 'New screenshot captured',
]);
return $response->json();Réponse
Réponse en cas de succès
201 Created
Message avec pièce jointe créé avec succès
| Champ | Type | Description |
|---|---|---|
tid | string | Identifiant unique du message |
title | string | Titre du message |
message | string | Corps du message |
attachment | object | Détails de la pièce jointe |
attachment.tid | string | Identifiant de la pièce jointe |
attachment.file_name | string | Nom du fichier stocké |
attachment.content_type | string | Type MIME |
attachment.file_size | integer | Taille du fichier en octets |
json
{
"tid": "zvtfxzk55fpqugz7ueslmse2a",
"title": "Screenshot Alert",
"message": "New screenshot captured",
"application": "Monitoring",
"device": "iPhone",
"created_at": "04.01.2025 09:12:08",
"attachment": {
"tid": "i6k4b8un79otbcbdkmavmf4ha",
"file_name": "5bd64bb3b76df1be1fc7f41eeb5078ca.jpg",
"content_type": "image/jpeg",
"file_size": 247421
}
}Réponses d’erreur
| Statut | Description |
|---|---|
401 | Non autorisé — Jeton invalide ou manquant |
403 | Interdit — La fonctionnalité nécessite une offre payante |
400 | Requête incorrecte — title ou message manquant, ou fichier non pris en charge |
404 | Introuvable — application_id ou device_id n’existe pas |
429 | Limite quotidienne atteinte — rien n’est stocké ni envoyé. Voir Limites quotidiennes de messages. |