Vai al contenuto

Invio con allegato POST A pagamento ​

Invia una notifica push con un file immagine allegato.

Funzionalità a pagamento

Questo endpoint è disponibile solo con i piani a pagamento.

Endpoint ​

POST https://api.pocketalert.app/v1/messages

Autenticazione ​

Obbligatorio

Includi uno di questi header nella tua richiesta:

  • Token: <your-api-key> — Ottienila da Chiavi API
  • Authorization: Bearer <jwt-token> — Da Login

Richiesta ​

HeaderObbligatorioDescrizione
Content-Type✅multipart/form-data
Token✅La tua chiave API

Parametri del body (multipart/form-data) ​

ParametroTipoObbligatorioDescrizione
titlestring✅Titolo della notifica
messagestring✅Testo del corpo della notifica
application_idstring❌TID dell'applicazione
device_idstring❌TID del dispositivo (ometti per tutti)
imagefile❌Allegato immagine (.png, .jpg, .jpeg, .gif)

Esempio di richiesta ​

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

Risposta ​

Risposta di successo ​

201 Created

Messaggio con allegato creato con successo

CampoTipoDescrizione
tidstringIdentificatore univoco del messaggio
titlestringTitolo del messaggio
messagestringCorpo del messaggio
attachmentobjectDettagli dell'allegato
attachment.tidstringIdentificatore dell'allegato
attachment.file_namestringNome del file salvato
attachment.content_typestringTipo MIME
attachment.file_sizeintegerDimensione del file in byte
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
  }
}

Risposte di errore ​

StatoDescrizione
401Non autorizzato — token non valido o mancante
403Vietato — la funzionalità richiede un piano a pagamento
400Richiesta non valida — title o message mancanti, oppure file non supportato
404Non trovato — application_id o device_id non esiste
429Limite giornaliero raggiunto — nulla viene salvato o caricato. Vedi Limiti giornalieri dei messaggi.

Documentazione di Pocket Alert