MillionSend.Contacts (MillionSend v0.1.0)

Copy Markdown View Source

Contacts, addressable by id or email — email wins when both are given. Pass :audience_id to scope a call to an audience; omit it for the top-level contact routes.

MillionSend.Contacts.create(%{audience_id: aud, email: "ada@acme.dev", first_name: "Ada"})
MillionSend.Contacts.get(%{audience_id: aud, email: "ada@acme.dev"})
MillionSend.Contacts.get("contact-uuid")
MillionSend.Contacts.update(%{id: id, unsubscribed: true, first_name: nil}) # nil clears

Summary

Functions

POST /audiences/:audience_id/contacts. The API requires :audience_id — without it the request goes to /contacts, which always answers 422 "audience_id is required" (mirrors Resend).

GET a contact by id/email map or a bare id string.

GET contacts. Accepts audience_id:, limit:, after:, before:.

DELETE a contact by id/email map or a bare id string.

PATCH a contact. Include a key with nil to clear it; omit to leave unchanged.

PATCH /contacts/:id_or_email/topics — set per-topic subscriptions (always a top-level route). params carries the address plus topics: as a list of %{id: ..., subscription: :opt_in | :opt_out}.

Types

address()

@type address() :: String.t() | map()

Functions

create(client \\ MillionSend.client(), params)

@spec create(MillionSend.Client.t(), map()) ::
  {:ok, MillionSend.Contacts.Contact.t()} | {:error, MillionSend.Error.t()}

POST /audiences/:audience_id/contacts. The API requires :audience_id — without it the request goes to /contacts, which always answers 422 "audience_id is required" (mirrors Resend).

get(client \\ MillionSend.client(), address)

@spec get(MillionSend.Client.t(), address()) ::
  {:ok, MillionSend.Contacts.Contact.t()} | {:error, MillionSend.Error.t()}

GET a contact by id/email map or a bare id string.

list()

GET contacts. Accepts audience_id:, limit:, after:, before:.

list(client)

@spec list(MillionSend.Client.t() | keyword()) ::
  {:ok, MillionSend.List.t()} | {:error, MillionSend.Error.t()}

list(client, opts)

@spec list(
  MillionSend.Client.t(),
  keyword()
) :: {:ok, MillionSend.List.t()} | {:error, MillionSend.Error.t()}

remove(client \\ MillionSend.client(), address)

@spec remove(MillionSend.Client.t(), address()) ::
  {:ok, MillionSend.Contacts.Contact.t()} | {:error, MillionSend.Error.t()}

DELETE a contact by id/email map or a bare id string.

update(client \\ MillionSend.client(), params)

@spec update(MillionSend.Client.t(), map()) ::
  {:ok, MillionSend.Contacts.Contact.t()} | {:error, MillionSend.Error.t()}

PATCH a contact. Include a key with nil to clear it; omit to leave unchanged.

update_topics(client \\ MillionSend.client(), params)

@spec update_topics(MillionSend.Client.t(), map()) ::
  {:ok, MillionSend.Contacts.Contact.t()} | {:error, MillionSend.Error.t()}

PATCH /contacts/:id_or_email/topics — set per-topic subscriptions (always a top-level route). params carries the address plus topics: as a list of %{id: ..., subscription: :opt_in | :opt_out}.