Skip to content

Commit a0dde7d

Browse files
authored
Merge pull request #114 from Kit/add-tag-subscribers-method
Add `tag_subscribers` method
2 parents 058eb09 + 89c23bb commit a0dde7d

File tree

3 files changed

+241
-214
lines changed

3 files changed

+241
-214
lines changed

src/ConvertKit_API_Traits.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,43 @@ public function update_tag_name(int $tag_id, string $name)
602602
return $this->put(sprintf('tags/%s', $tag_id), ['name' => $name]);
603603
}
604604

605+
/**
606+
* Tags the given subscribers with the given existing Tags.
607+
*
608+
* @param array<int,array<string>> $taggings Taggings, in the format:
609+
* [
610+
* [
611+
* "tag_id" => 0,
612+
* "subscriber_id" => 0
613+
* ],
614+
* [
615+
* "tag_id" => 1,
616+
* "subscriber_id" => 1
617+
* ],
618+
* ].
619+
* @param string $callback_url URL to notify for large batch size when async processing complete.
620+
*
621+
* @since 2.2.1
622+
*
623+
* @see https://developers.kit.com/api-reference/tags/bulk-tag-subscribers
624+
*
625+
* @return false|mixed
626+
*/
627+
public function tag_subscribers(array $taggings, string $callback_url = '')
628+
{
629+
// Build parameters.
630+
$options = ['taggings' => $taggings];
631+
if (!empty($callback_url)) {
632+
$options['callback_url'] = $callback_url;
633+
}
634+
635+
// Send request.
636+
return $this->post(
637+
'bulk/tags/subscribers',
638+
$options
639+
);
640+
}
641+
605642
/**
606643
* Tags a subscriber with the given existing Tag.
607644
*

0 commit comments

Comments
 (0)