Saltar al contenido

Crear con adjunto POST De pago ​

Envía una notificación push con un archivo de imagen adjunto.

Función de pago

Este endpoint solo está disponible en los planes de pago.

Endpoint ​

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

Autenticación ​

Obligatorio

Incluye uno de estos headers en tu solicitud:

Solicitud ​

Headers ​

HeaderObligatorioDescripción
Content-Type✅multipart/form-data
Token✅Tu clave de API

Parámetros del cuerpo (multipart/form-data) ​

ParámetroTipoObligatorioDescripción
titlestring✅Título de la notificación
messagestring✅Texto del cuerpo de la notificación
application_idstring❌TID de la aplicación
device_idstring❌TID del dispositivo (omítelo para todos)
imagefile❌Imagen adjunta (.png, .jpg, .jpeg, .gif)

Ejemplo de solicitud ​

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

Respuesta ​

Respuesta correcta ​

201 Created

Mensaje con adjunto creado correctamente

CampoTipoDescripción
tidstringIdentificador único del mensaje
titlestringTítulo del mensaje
messagestringCuerpo del mensaje
attachmentobjectDetalles del adjunto
attachment.tidstringIdentificador del adjunto
attachment.file_namestringNombre del archivo almacenado
attachment.content_typestringTipo MIME
attachment.file_sizeintegerTamaño del archivo en bytes
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
  }
}

Respuestas de error ​

EstadoDescripción
401No autorizado — token inválido o ausente
403Prohibido — la función requiere un plan de pago
400Solicitud incorrecta — falta title o message, o el archivo no es compatible
404No encontrado — application_id o device_id no existe
429Límite diario alcanzado — no se almacena ni se sube nada. Consulta Límites diarios de mensajes.

Documentación de Pocket Alert