Skip to main content

Delete Push Notification

This endpoint allows administrators to delete a scheduled push notification that has not yet been sent. This is useful for canceling notifications that are no longer relevant or were created in error.

Endpoint

  • URL: /api/push-notification/:id
  • Method: DELETE
  • Authentication: Required (Admin access)

URL Parameters

ParameterTypeRequiredDescription
idintegerYesThe ID of the notification to delete

Response

Success Response

  • Code: 200 OK
  • Content: "Notification deleted"

Error Responses

Notification Not Found

  • Code: 404 Not Found
  • Content:
{
"error": "Notification not found"
}

Notification Already Sent

  • Code: 400 Bad Request
  • Content:
{
"error": "Cannot delete a notification that's already sent"
}

Other Errors

  • Code: 400 Bad Request
  • Content:
{
"error": "Something went wrong"
}

Notes

  • This endpoint can only delete notifications that have a scheduledFor date in the future
  • Notifications that have already been sent (or have a scheduledFor date in the past) cannot be deleted
  • When a notification is deleted, it is removed from both the database and the Firebase collection
  • This operation is permanent and cannot be undone

Example

curl -X DELETE "https://api.example.com/api/push-notification/123" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN"