 +    my $updatedpatron = eval {
 +        $patron->set($body);
 +    };
++
++    # Do a live-sync with NL. Will be retried by cron-job if it fails.
++    if ($nlsync) {
++        NLSync({ 'borrowernumber' => $args->{borrowernumber} });
++    }
 +
 +    if ($updatedpatron) {
 +        if ($updatedpatron->is_changed) {

+    } else {
+        $patrons = Koha::Patrons->search;
+    }
 
     $c->$cb($patrons->unblessed, 200);
 }
@@ -34,8 +44,6 @@ sub list {
 sub get {
     my ($c, $args, $cb) = @_;
 
-    my $user = $c->stash('koha.user');
-
     my $patron = Koha::Patrons->find($args->{borrowernumber});
     unless ($patron) {
         return $c->$cb({error => "Patron not found"}, 404);
@@ -44,4 +52,127 @@ sub get {
     return $c->$cb($patron->unblessed, 200);
 }
 
+sub add {
+    my ($c, $args, $cb) = @_;
+

index b97a154..1e2f4f8 100644
--- a/Koha/REST/V1/Patron.pm
+++ b/Koha/REST/V1/Patron.pm
@@ -18,15 +18,30 @@ package Koha::REST::V1::Patron;
 use Modern::Perl;

 use Mojo::Base 'Mojolicious::Controller';
-
+use Koha::AuthUtils qw(hash_password);
 use Koha::Patrons;
+use Koha::Patron::Categories;
+use Koha::Libraries;
+
+use Module::Load;
+if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
+    load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber NLEncryptPIN NLSync);
+}

 sub list {
     my ($c, $args, $cb) = @_;

-    my $user = $c->stash('koha.user');
-
-    my $patrons = Koha::Patrons->search;
