문서로 건너뛰기
SDK

openemail.subscriptions

이 네임스페이스의 모든 메서드: 시그니처, 매개변수, 반환값과 예시.

메서드

The newsletters and mailing lists the mailbox receives: list them by sender or by domain, unsubscribe, and move what they send.

subscriptions.list()

List subscriptions

범위threads:read
시그니처
list(options?: SubscriptionListOptions): Promise<SubscriptionListResource>

Resolves the newsletters and mailing lists the mailbox receives, as the Subscriptions page of the app shows them: one row per sender and the address it writes to, found from the List-Unsubscribe header of the mail it sends. Each row says how much mail the sender sent, how much of it is unread and how much arrived in the last 30 days, how it lets you unsubscribe, and the rule that keeps moving its new mail when there is one.

status is active, the default, or unsubscribed. q searches the sender, and sort is recent, most, unread or name. Paging is by offset: total counts every match and hasMore says whether another page follows.

A key limited to particular addresses lists only the subscriptions delivered to them, and address narrows the list to one address.

매개변수

options.statusSubscriptionStatus

active or unsubscribed. Defaults to active.

options.qstring

Searches the sender name and address.

options.sortSubscriptionSort

recent, most, unread or name. Defaults to recent.

options.limitnumber

Rows per page, 1 to 200, defaulting to 50.

options.offsetnumber

How many rows to skip.

options.addressstring

Only the subscriptions delivered to this address.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

반환값

SubscriptionListResource, { object: 'list', data, total, counts, hasMore }, where counts holds how many are active and unsubscribed.

예시

const page = await openemail.subscriptions.list({ sort: 'most', limit: 20 }) for (const row of page.data) console.log(row.senderEmail, row.total, row.method)

참고

  • Read only, so the SDK retries it after a network failure like any other read.

다른 사용처

API
GET /subscriptions
CLI
openemail subscriptions list

subscriptions.listDomains()

List subscriptions by domain

범위threads:read
시그니처
listDomains(options?: SubscriptionListOptions): Promise<SubscriptionDomainListResource>

Resolves the same subscriptions as list, one row per sender domain with the counts of its senders added up, so a company that writes from several addresses is one row. unsubscribable counts the senders on the domain that can be unsubscribed without a person opening a page, which is what unsubscribeDomain acts on.

It takes the same filters as list.

매개변수

options.statusSubscriptionStatus

active or unsubscribed. Defaults to active.

options.qstring

Searches the sender name and address.

options.sortSubscriptionSort

recent, most, unread or name. Defaults to recent.

options.limitnumber

Rows per page, 1 to 200, defaulting to 50.

options.offsetnumber

How many rows to skip.

options.addressstring

Only the subscriptions delivered to this address.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

반환값

SubscriptionDomainListResource, { object: 'list', data, total, counts, hasMore }.

예시

const page = await openemail.subscriptions.listDomains({ sort: 'most' }) for (const row of page.data) console.log(row.domain, row.senders, row.unsubscribable)

참고

  • Read only, so the SDK retries it after a network failure like any other read.

다른 사용처

API
GET /subscriptions/domains
CLI
openemail subscriptions list-domains

subscriptions.unsubscribe()

Unsubscribe from a sender

범위threads:write
시그니처
unsubscribe(id: string, body?: SubscriptionUnsubscribe, options?: RequestScope): Promise<UnsubscribeResultResource>

Unsubscribes the way the sender asks for it: a one-click request to its unsubscribe address when it offers one, otherwise an unsubscribe email sent from the address the mail arrived at. A sender that only offers a page cannot be unsubscribed by a program, so method is link and url is the page a person has to open. bin also moves every conversation from the sender to the Bin.

A sender that gives no way to unsubscribe is a 422 unsubscribe_unsupported, and one whose one-click request failed with no address to write to is a 502 unsubscribe_refused. A subscription delivered to an address the key does not reach is a 404.

매개변수

idstring필수

The subscription, from list.

body.binboolean

Also move every conversation from the sender to the Bin. Defaults to false.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

반환값

UnsubscribeResultResource, { object: 'unsubscribe', subscriptionId, method, url, binned }.

예시

const result = await openemail.subscriptions.unsubscribe('sub_7d2c1f0a9b3e4c5d6e7f8a9b', { bin: true }) if (result.method === 'link') console.log('Open', result.url)

참고

  • The SDK does not retry it, because a second call can send a second unsubscribe email.

다른 사용처

API
POST /subscriptions/{id}/unsubscribe
CLI
openemail subscriptions unsubscribe

subscriptions.unsubscribeDomain()

Unsubscribe from a whole domain

범위threads:write
시그니처
unsubscribeDomain(domain: string, body?: SubscriptionDomainUnsubscribe, options?: RequestScope): Promise<DomainUnsubscribeResultResource>

Unsubscribes from every sender on a domain that can be unsubscribed without a person opening a page, with a one-click request or an unsubscribe email, as the domain view of the Subscriptions page does. unsubscribed counts the senders it worked for, skipped the senders that only offer a page and failed the ones that did not accept it.

bin also moves their conversations to the Bin, and address keeps it to the subscriptions delivered to one address. A key limited to particular addresses acts only on the subscriptions delivered to them.

매개변수

domainstring필수

The sender domain, from listDomains.

body.binboolean

Also move the conversations to the Bin. Defaults to false.

body.addressstring

Only the subscriptions delivered to this address.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

반환값

DomainUnsubscribeResultResource, { object: 'domain_unsubscribe', domain, unsubscribed, skipped, failed, binned }.

예시

const result = await openemail.subscriptions.unsubscribeDomain('news.acme.com') console.log(`${result.unsubscribed} unsubscribed, ${result.skipped} need a person`)

참고

  • The SDK does not retry it, because a second call can send unsubscribe emails again.

다른 사용처

API
POST /subscriptions/domains/{domain}/unsubscribe
CLI
openemail subscriptions unsubscribe-domain

subscriptions.move()

Move what a sender sent

범위threads:write
시그니처
move(id: string, body: SubscriptionMove, options?: RequestScope): Promise<SubscriptionMoveResultResource>

Moves every conversation from the sender to the archive, the Bin or a label, as the Subscriptions page does. destination is archive, bin or label, and label needs labelId, or the call is a 422 label_not_found.

With future, the default, a rule keeps doing it to new mail from the sender to that address, which also needs rules:write. ruleName names that rule. future: false drops a rule made that way before, when the key holds rules:write.

매개변수

idstring필수

The subscription, from list.

body.destinationSubscriptionDestination필수

archive, bin or label.

body.labelIdstring

The label to file under, for label.

body.futureboolean

Keep doing it to new mail with a rule. Defaults to true.

body.ruleNamestring

A name for that rule.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

반환값

SubscriptionMoveResultResource, { object: 'subscription_move', subscriptionId, moved, ruleId }.

예시

const result = await openemail.subscriptions.move('sub_7d2c1f0a9b3e4c5d6e7f8a9b', { destination: 'archive' }) console.log(result.moved, result.ruleId)

참고

  • The SDK retries it after a network failure, which is safe because moving the same mail again changes nothing and the rule is updated rather than added twice.

다른 사용처

API
POST /subscriptions/{id}/move
CLI
openemail subscriptions move