 +use Modern::Perl;
 +
 +use Mojo::Base 'Mojolicious::Controller';
-+use C4::Letters qw( GetPreparedLetter );
-+use Koha::NorwegianPatronDB qw( NLDecodePin );
-+use Mail::Sendmail;
++use C4::Letters;
++use C4::Context;
++
 +use Koha::Libraries;
 +use Koha::Patrons;
-+use Koha::Email;
 +
-+use Data::Dumper;
-+
-+sub send_patron_account_details {
-+	my ($c, $args, $cb) = @_;
++sub add {
++     my ($c, $args, $cb) = @_;
 +
 +    my $patron = Koha::Patrons->find($args->{borrowernumber});
++
 +    unless ($patron) {
 +        return $c->$cb({error => "Patron not found"}, 404);
 +    }
 +
-+	unless ($patron->email) {
-+		return $c->$cb({error => "Invalid or no email address"}, 400);
-+	}
++    unless ($patron->email) {
++        return $c->$cb({error => "Invalid or no email address"}, 500);
++    }
 +
-+	my $library = Koha::Libraries->find( $patron->branchcode );
++    my $library = Koha::Libraries->find( $patron->branchcode );
 +
-+	#https://github.com/Koha-Community/Koha/blob/master/C4/Letters.pm#L596
-+    my $letter = GetPreparedLetter (
++    #https://github.com/Koha-Community/Koha/blob/master/C4/Letters.pm#L596
++    my $letter = C4::Letters::GetPreparedLetter (
 +        module => 'members',
 +        letter_code => 'ACCTDETAILS',
 +        branchcode => $patron->branchcode, # override default letter with branchcode letter if existing


diff --git a/Koha/REST/V1/Messaging.pm b/Koha/REST/V1/Messaging.pm
new file mode 100644
index 0000000..513a059
--- /dev/null
+++ b/Koha/REST/V1/Messaging.pm
@@ -0,0 +1,93 @@
+package Koha::REST::V1::Messaging;
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR

+        "200": {
+          "description": "Patron account details sent"
+        },
+        "500": {
+          "description": "Error sending patron account details",
+          "schema": {
+            "$ref": "../definitions.json#/error"
