diff --git a/README.md b/README.md index b0f9596..68d45ec 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,24 @@ $subscriber = $novu->createSubscriber([ 'avatar' => '', // optional ])->toArray(); +// Bulk create subscribers +$response = $novu->bulkCreateSubscribers([ + [ + 'subscriberId' => 'SUBSCRIBER_IDENTIFIER>', + 'email' => '', // optional + 'firstName' => '', // optional + 'lastName' => '', // optional + 'avatar' => '', // optional + ], + [ + 'subscriberId' => 'SUBSCRIBER_IDENTIFIER>', + 'email' => '', // optional + 'firstName' => '', // optional + 'lastName' => '', // optional + 'avatar' => '', // optional + ], +]); + // Get subscriber $subscriber = $novu->getSubscriber($subscriberId)->toArray(); diff --git a/src/Actions/ManagesSubscribers.php b/src/Actions/ManagesSubscribers.php index d03772e..c8f2d1b 100644 --- a/src/Actions/ManagesSubscribers.php +++ b/src/Actions/ManagesSubscribers.php @@ -20,6 +20,18 @@ public function createSubscriber(array $data, $wait = true) return new Subscriber($subscriber, $this); } + /** + * Bulk creates subscribers. + * + * @param array $data + * + * @return array + */ + public function bulkCreateSubscribers(array $data): array + { + return $this->post('subscribers/bulk', ['subscribers' => $data])['data']; + } + /** * Update a given subscriber *