تخطَّ إلى المستندات
Ruby

client.keys

كل دالّة في مساحة الأسماء هذه: توقيعها ومعلماتها وما تُرجعه ومثال عليها.

الدوالّ

Every key in the workspace: list, create, change, rotate, switch off and revoke them, never wider than the calling key, and read their request log and activity.

keys.list

List one page of the workspace's API keys

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list(limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of the workspace's keys, newest first, with what the Settings, API keys page shows: status, scopes, role, send scope, when each was last used, how often, and who made and last changed it. Revoked and expired keys stay listed until somebody deletes them. No secret is ever returned; maskedKey is enough to tell two keys apart.

A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

المعلمات

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 25.

cursorString

The next_cursor from the previous page, passed back unchanged. Never build one yourself.

api_keyString

Overrides the client API key for this call only.

يُرجع

An OpenEmail::Page of Hashes, with items, has_more? and next_cursor. Each item has id, name, mode, maskedKey, keyLast4, status, scopes, roleId, roleName, addressAllowlist, domainAllowlist, expiresAt, lastUsedAt, totalUses, rotatedAt, rotationCount, deactivatedAt, revokedAt, revokedReason, createdAt, createdBy, updatedAt, updatedBy, lastChangeAt and lastChangeType. Never a secret.

مثال

page = client.keys.list page.items.each do |key|  puts key.values_at(:maskedKey, :name, :status, :lastUsedAt).join(" ")end

ملاحظات

  • It needs keys:read, which no key holds unless somebody gave it one.

  • The cursor is opaque: pass next_cursor back as it came.

متاح أيضًا في

API
GET /keys
TypeScript
keys.list()
Python
keys.list()
CLI
openemail keys list

keys.list_all

Collect every API key into one array

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_all(limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Walks every page of list and returns every key the caller can see, newest first, in one Array.

المعلمات

limitInteger

Page size for each request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Array of Hashes, one per key with the fields list returns, newest first.

مثال

keys = client.keys.list_all idle = keys.select { |key| key[:status] == "active" && key[:lastUsedAt].nil? } p idle.map { |key| key[:name] }

متاح أيضًا في

API
GET /keys
TypeScript
keys.listAll()
Python
keys.list_all()

keys.iterate

Stream the workspace's API keys one at a time

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
iterate(limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

An Enumerator over list, fetching a page only when the one before is drained. Given a block, it yields each key to the block instead.

المعلمات

limitInteger

Page size per request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Enumerator of Hashes, one key per step (or yields each one to a block).

مثال

week_from_now = Time.now + (7 * 24 * 60 * 60) client.keys.iterate do |key|  puts "#{key[:name]} expires soon" if key[:expiresAt] && Time.iso8601(key[:expiresAt]) < week_from_nowend

متاح أيضًا في

API
GET /keys
TypeScript
keys.iterate()
Python
keys.iterate()

keys.get

Read one API key, without its secret

الصلاحياتkeys:read
التوقيع
get(id, api_key: nil) -> Hash

Returns one key as list shows it. A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

client.me.get describes the calling key itself and needs no scope; this reads any key the caller can see.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with id, name, mode, maskedKey, keyLast4, status, scopes, roleId, roleName, addressAllowlist, domainAllowlist, expiresAt, lastUsedAt, totalUses, rotatedAt, rotationCount, deactivatedAt, revokedAt, revokedReason, createdAt, createdBy, updatedAt, updatedBy, lastChangeAt and lastChangeType. Never a secret.

مثال

key = client.keys.get("4c1b257a66287fd113bd89d0") puts key[:status]p key[:scopes], key[:domainAllowlist]

متاح أيضًا في

API
GET /keys/{id}
TypeScript
keys.get()
Python
keys.get()
CLI
openemail keys get

keys.create

Mint a new API key and receive its secret once

الصلاحياتkeys:manage
التوقيع
create(body = nil, api_key: nil, **fields) -> Hash

Creates a live key and returns it plus token, the whole secret. That is the only time it appears, so store it before doing anything else.

Left out, scopes is ["emails:send"], the role is the caller's own or none, the send scope is the caller's own or none (none means every address the workspace owns), and the expiry is the caller's own or none. The workspace cap on live keys applies, as a 422 workspace_limit_reached.

A key never makes or reaches a key wider than itself. The target has to sit inside the caller on every axis: scopes the caller holds after its own role has narrowed them, the same role when the caller has one, an expiry no later than the caller's when the caller expires, the caller's mode, and a send scope inside the caller's own, where one address never covers its whole domain. Anything wider is 403 beyond_caller_authority, and param names the axis.

Step-up verification, which the app asks for before it mints a key, cannot apply to a call made with a key, so keys:manage is a credential that makes credentials. Give it only to automation that provisions keys, narrow that key to the role and send scope it needs, and give it an expiry.

المعلمات

nameStringمطلوب

A name, 1 to 60 characters.

scopesArray<String>

The scopes the key holds, at least one, each held by the caller. Defaults to ["emails:send"].

roleIdString or nil

A role to cap the key. Left out, the caller's own role. A caller with a role can only give its own, and nil is refused for it.

addressAllowlistArray<String>

Single addresses the key may send as, at most 50, each owned by the workspace.

domainAllowlistArray<String>

Whole domains the key may send as, at most 25, including addresses added to them later. Leave both lists out to inherit the caller's own; send both empty for none.

expiresInMinutesInteger

Minutes until the key expires, 5 to 5,256,000 (ten years). Left out, the caller's own expiry.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with every field get returns: id, name, mode, maskedKey, keyLast4, status, scopes, roleId, roleName, addressAllowlist, domainAllowlist, expiresAt, lastUsedAt, totalUses, rotatedAt, rotationCount, deactivatedAt, revokedAt, revokedReason, createdAt, createdBy, updatedAt, updatedBy, lastChangeAt and lastChangeType, none of them a secret. Plus token, oe_live_ followed by the id, an underscore and the secret.

مثال

key = client.keys.create(  name: "Billing sender",  scopes: ["emails:send", "emails:read"],  domainAllowlist: ["billing.acme.com"],  expiresInMinutes: 60 * 24 * 90) File.write(".openemail-billing-key", key[:token])

ملاحظات

  • Not retried automatically: a retry after a lost response would mint a second key.

  • The new key is recorded in the activity log as made by the calling key, source: "api".

  • The success status is 201.

متاح أيضًا في

API
POST /keys
TypeScript
keys.create()
Python
keys.create()
CLI
openemail keys create

keys.update

Rename a key, change its scopes or send scope, or switch it off and on

الصلاحياتkeys:manage
التوقيع
update(id, patch = nil, api_key: nil, **fields) -> Hash

Applies a partial change and returns the key as it now stands. scopes, addressAllowlist and domainAllowlist REPLACE what the key had, and a field left out stays as it was. enabled: false switches the key off: every call with it is refused with inactive_api_key and it keeps its secret, scopes, role and send scope, so enabled: true restores it exactly. That is the reversible alternative to revoke. A revoked key cannot be changed, and answers 409 revoked.

A key never makes or reaches a key wider than itself. The target has to sit inside the caller on every axis: scopes the caller holds after its own role has narrowed them, the same role when the caller has one, an expiry no later than the caller's when the caller expires, the caller's mode, and a send scope inside the caller's own, where one address never covers its whole domain. Anything wider is 403 beyond_caller_authority, and param names the axis. A key changing itself may only narrow itself.

A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

nameString

A new name, 1 to 60 characters.

scopesArray<String>

The whole new list of scopes, at least one.

addressAllowlistArray<String>

The whole new list of single addresses.

domainAllowlistArray<String>

The whole new list of whole domains.

enabledBoolean

False switches the key off, true switches it back on.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with id, name, mode, maskedKey, keyLast4, status, scopes, roleId, roleName, addressAllowlist, domainAllowlist, expiresAt, lastUsedAt, totalUses, rotatedAt, rotationCount, deactivatedAt, revokedAt, revokedReason, createdAt, createdBy, updatedAt, updatedBy, lastChangeAt and lastChangeType. Never a secret.

مثال

client.keys.update("4c1b257a66287fd113bd89d0", enabled: false) key = client.keys.update("4c1b257a66287fd113bd89d0", name: "Billing sender (paused)") puts key[:status]

ملاحظات

  • An empty patch is a 422. A PATCH is retried on network failure because applying the same patch twice leaves the same key.

متاح أيضًا في

API
PATCH /keys/{id}
TypeScript
keys.update()
Python
keys.update()
CLI
openemail keys update

keys.delete

Remove a revoked key from the list

الصلاحياتkeys:manage
التوقيع
delete(id, api_key: nil) -> Hash

Deletes a key that has already been revoked. Its request log and activity stay, under Deleted key, so the history of what it did is not lost with it. A key that has not been revoked is refused with 409 not_revoked, so nothing still calling with it loses its credential without somebody deciding that first.

A key never makes or reaches a key wider than itself. The target has to sit inside the caller on every axis: scopes the caller holds after its own role has narrowed them, the same role when the caller has one, an expiry no later than the caller's when the caller expires, the caller's mode, and a send scope inside the caller's own, where one address never covers its whole domain. Anything wider is 403 beyond_caller_authority, and param names the axis.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with object set to api_key, the id, and deleted set to true.

مثال

client.keys.revoke("4c1b257a66287fd113bd89d0", reason: "Leaked in a build log")client.keys.delete("4c1b257a66287fd113bd89d0")

متاح أيضًا في

API
DELETE /keys/{id}
TypeScript
keys.delete()
Python
keys.delete()
CLI
openemail keys delete

keys.rotate

Give a key a new secret and receive it once

الصلاحياتkeys:manage
التوقيع
rotate(id, api_key: nil) -> Hash

Mints a new secret for a key and returns the key plus token, rotationCount and rotatedAt. The id, name, scopes, role, send scope, expiry and request history all carry on; only the secret and keyLast4 change. There is no overlap window: the old secret stops working the instant this returns.

Rotating the calling key itself is what client.me.rotate does, and here it is allowed with keys:write as well as keys:manage. A revoked or expired key cannot be rotated, and answers 409 revoked or expired.

A key never makes or reaches a key wider than itself. The target has to sit inside the caller on every axis: scopes the caller holds after its own role has narrowed them, the same role when the caller has one, an expiry no later than the caller's when the caller expires, the caller's mode, and a send scope inside the caller's own, where one address never covers its whole domain. Anything wider is 403 beyond_caller_authority, and param names the axis. Rotation hands the caller a working secret for the key, which is why the ceiling is checked against the key as it stands.

A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with every field get returns: id, name, mode, maskedKey, keyLast4, status, scopes, roleId, roleName, addressAllowlist, domainAllowlist, expiresAt, lastUsedAt, totalUses, rotatedAt, rotationCount, deactivatedAt, revokedAt, revokedReason, createdAt, createdBy, updatedAt, updatedBy, lastChangeAt and lastChangeType, none of them a secret. Plus token, rotationCount and rotatedAt.

مثال

rotated = client.keys.rotate("4c1b257a66287fd113bd89d0") File.write(".openemail-billing-key", rotated[:token]) puts rotated[:rotationCount], rotated[:rotatedAt]

ملاحظات

  • Not retried automatically. Repeating a rotation would invalidate the secret the first attempt returned.

متاح أيضًا في

API
POST /keys/{id}/rotate
TypeScript
keys.rotate()
Python
keys.rotate()
CLI
openemail keys rotate

keys.revoke

Revoke a key for good

الصلاحياتkeys:manage
التوقيع
revoke(id, body = nil, api_key: nil, **fields) -> Hash

Revokes a key: every later call with it is refused with revoked_api_key, and it can never be switched back on, rotated or changed. reason is kept on the key and in the activity log. Revoking a key that is already revoked changes nothing and returns it as it is. A key may revoke itself, which is how an integration that believes its secret leaked retires it at once.

A key never makes or reaches a key wider than itself. The target has to sit inside the caller on every axis: scopes the caller holds after its own role has narrowed them, the same role when the caller has one, an expiry no later than the caller's when the caller expires, the caller's mode, and a send scope inside the caller's own, where one address never covers its whole domain. Anything wider is 403 beyond_caller_authority, and param names the axis.

A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

reasonString

Why, at most 200 characters.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with id, name, mode, maskedKey, keyLast4, status, scopes, roleId, roleName, addressAllowlist, domainAllowlist, expiresAt, lastUsedAt, totalUses, rotatedAt, rotationCount, deactivatedAt, revokedAt, revokedReason, createdAt, createdBy, updatedAt, updatedBy, lastChangeAt and lastChangeType. Never a secret. status is revoked.

مثال

key = client.keys.revoke("4c1b257a66287fd113bd89d0", reason: "Contractor offboarded") puts key[:status], key[:revokedAt]

ملاحظات

  • Retried on network failure, because revoking twice leaves the same key. Prefer update(id, enabled: false) while you find out whether anything still depends on a key.

متاح أيضًا في

API
POST /keys/{id}/revoke
TypeScript
keys.revoke()
Python
keys.revoke()
CLI
openemail keys revoke

keys.list_requests

List one page of one key's request log

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_requests(id, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of the calls one key made, newest first, the Requests tab of the key in the app. The request log records every authenticated call a key made: method, path, status, error code, duration, IP and user agent, and never a body or a query string. A call refused before a key could be identified is not in it, and neither is a call made with an OAuth access token. Nothing is pruned, so the log reaches back to a key's first call. failed_only:, since: and until: are the filters the app offers.

A deleted key's log stays readable to a key that is not narrowed. A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

failed_onlyBoolean

Only calls answered with a status of 400 or more.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 25.

cursorString

The next_cursor from the previous page, passed back unchanged. Never build one yourself.

api_keyString

Overrides the client API key for this call only.

يُرجع

An OpenEmail::Page of Hashes, with items, has_more? and next_cursor. Each item has id, keyId, keyName, requestId, method, path, status, errorCode, durationMs, ip, userAgent and createdAt.

مثال

page = client.keys.list_requests("4c1b257a66287fd113bd89d0", failed_only: true, limit: 50) page.items.each do |call|  puts call.values_at(:createdAt, :method, :path, :status, :errorCode).join(" ")end

ملاحظات

  • The cursor is opaque and stays valid under the same filters. One this log did not hand out is a 400 invalid_cursor.

متاح أيضًا في

API
GET /keys/{id}/requests
TypeScript
keys.listRequests()
Python
keys.list_requests()
CLI
openemail keys list-requests

keys.list_all_requests

Collect one key's whole request log into one array

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_all_requests(id, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Walks every page of list_requests under the same filters. The log is never pruned, so give it a window unless you mean to read a busy key's whole history, or use iterate_requests to stop early.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

failed_onlyBoolean

Only calls answered with a status of 400 or more.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size for each request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Array of Hashes, one per call with the fields list_requests returns, newest first.

مثال

today = client.keys.list_all_requests("4c1b257a66287fd113bd89d0", since: Time.now - (24 * 60 * 60), limit: 100) puts "#{today.size} calls today"

ملاحظات

  • If any page fails, the error is raised and the rows already fetched are discarded.

متاح أيضًا في

API
GET /keys/{id}/requests
TypeScript
keys.listAllRequests()
Python
keys.list_all_requests()

keys.iterate_requests

Stream one key's request log one call at a time

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
iterate_requests(id, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

An Enumerator over list_requests under the same filters, fetching a page only when the one before is drained. Given a block, it yields each call to the block instead.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

failed_onlyBoolean

Only calls answered with a status of 400 or more.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size per request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Enumerator of Hashes, one call per step (or yields each one to a block).

مثال

refused = client.keys.iterate_requests("4c1b257a66287fd113bd89d0", failed_only: true).find do |call|  call[:errorCode] == "from_address_forbidden"end puts "first refused send at #{refused[:createdAt]}" if refused

متاح أيضًا في

API
GET /keys/{id}/requests
TypeScript
keys.iterateRequests()
Python
keys.iterate_requests()

keys.list_activity

List one page of what happened to one key

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of one key's audit log, newest first, the Activity tab of the key in the app. Every change to a key is a row: created, updated, rotated, deactivated, reactivated, revoked and deleted, plus auth_failed for every call that presented the key and was refused. actor names who made the change, a person as @username or a key as API key <name> in label, and source in detail says where it came from: console, api, mcp or documentation.

A deleted key keeps its history, readable to a key that is not narrowed. A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 25.

cursorString

The next_cursor from the previous page, passed back unchanged. Never build one yourself.

api_keyString

Overrides the client API key for this call only.

يُرجع

An OpenEmail::Page of Hashes, with items, has_more? and next_cursor. Each item has id, keyId, keyName, type, createdAt, actor and detail.

مثال

page = client.keys.list_activity("4c1b257a66287fd113bd89d0") page.items.each do |change|  puts [change[:createdAt], change[:type], change.dig(:actor, :label), change.dig(:detail, :source)].join(" ")end

متاح أيضًا في

API
GET /keys/{id}/activity
TypeScript
keys.listActivity()
Python
keys.list_activity()
CLI
openemail keys list-activity

keys.list_all_activity

Collect one key's whole audit log into one array

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_all_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Walks every page of list_activity under the same window and returns every change, newest first.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size for each request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Array of Hashes, one per change with the fields list_activity returns, newest first.

مثال

history = client.keys.list_all_activity("4c1b257a66287fd113bd89d0") refused = history.count { |change| change[:type] == "auth_failed" } puts "#{refused} refused attempts"

ملاحظات

  • If any page fails, the error is raised and the rows already fetched are discarded.

متاح أيضًا في

API
GET /keys/{id}/activity
TypeScript
keys.listAllActivity()
Python
keys.list_all_activity()

keys.iterate_activity

Stream one key's audit log one change at a time

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
iterate_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

An Enumerator over list_activity under the same window, fetching a page only when the one before is drained. Given a block, it yields each change to the block instead.

المعلمات

idStringمطلوب

Key id, the 24 hex characters after oe_live_.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size per request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Enumerator of Hashes, one change per step (or yields each one to a block).

مثال

client.keys.iterate_activity("4c1b257a66287fd113bd89d0") do |change|  next unless change[:type] == "rotated"   puts "last rotated by #{change.dig(:actor, :label)} at #{change[:createdAt]}"  breakend

متاح أيضًا في

API
GET /keys/{id}/activity
TypeScript
keys.iterateActivity()
Python
keys.iterate_activity()

keys.list_workspace_requests

List one page of the request log of every key

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_workspace_requests(key_ids: nil, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of every call the workspace's keys made, newest first, the Requests tab of Settings, API keys. The request log records every authenticated call a key made: method, path, status, error code, duration, IP and user agent, and never a body or a query string. A call refused before a key could be identified is not in it, and neither is a call made with an OAuth access token. Nothing is pruned, so the log reaches back to a key's first call. key_ids:, failed_only:, since: and until: are the filters the app offers, and key_ids: may name a deleted key.

A narrowed key reads only the log of the keys it can see, so naming another key in key_ids: matches nothing.

المعلمات

key_idsArray<String>

Key ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.

failed_onlyBoolean

Only calls answered with a status of 400 or more.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 25.

cursorString

The next_cursor from the previous page, passed back unchanged. Never build one yourself.

api_keyString

Overrides the client API key for this call only.

يُرجع

An OpenEmail::Page of Hashes, with items, has_more? and next_cursor. Each item has id, keyId, keyName, requestId, method, path, status, errorCode, durationMs, ip, userAgent and createdAt.

مثال

page = client.keys.list_workspace_requests(failed_only: true, since: "2026-09-22T00:00:00Z") page.items.each do |call|  puts call.values_at(:keyName, :method, :path, :status).join(" ")end

متاح أيضًا في

API
GET /keys/requests
TypeScript
keys.listWorkspaceRequests()
Python
keys.list_workspace_requests()
CLI
openemail keys list-workspace-requests

keys.list_all_workspace_requests

Collect the request log of every key into one array

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_all_workspace_requests(key_ids: nil, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Walks every page of list_workspace_requests under the same filters. The log is never pruned, so give it a window, or use iterate_workspace_requests to stop early.

المعلمات

key_idsArray<String>

Key ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.

failed_onlyBoolean

Only calls answered with a status of 400 or more.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size for each request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Array of Hashes, one per call with the fields list_workspace_requests returns, newest first.

مثال

failures = client.keys.list_all_workspace_requests(failed_only: true, since: Time.now - (60 * 60), limit: 100) puts "#{failures.size} failed calls in the last hour"

ملاحظات

  • If any page fails, the error is raised and the rows already fetched are discarded.

متاح أيضًا في

API
GET /keys/requests
TypeScript
keys.listAllWorkspaceRequests()
Python
keys.list_all_workspace_requests()

keys.iterate_workspace_requests

Stream the request log of every key one call at a time

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
iterate_workspace_requests(key_ids: nil, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

An Enumerator over list_workspace_requests under the same filters, fetching a page only when the one before is drained. Given a block, it yields each call to the block instead.

المعلمات

key_idsArray<String>

Key ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.

failed_onlyBoolean

Only calls answered with a status of 400 or more.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size per request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Enumerator of Hashes, one call per step (or yields each one to a block).

مثال

client.keys.iterate_workspace_requests(failed_only: true) do |call|  puts "#{call[:requestId]} #{call[:path]}" if call[:status] >= 500end

متاح أيضًا في

API
GET /keys/requests
TypeScript
keys.iterateWorkspaceRequests()
Python
keys.iterate_workspace_requests()

keys.list_workspace_activity

List one page of what happened to every key

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of the audit log of every key in the workspace, newest first, the Activity tab of Settings, API keys. Every change to a key is a row: created, updated, rotated, deactivated, reactivated, revoked and deleted, plus auth_failed for every call that presented the key and was refused. actor names who made the change, a person as @username or a key as API key <name> in label, and source in detail says where it came from: console, api, mcp or documentation.

key_ids: narrows it, deleted keys included, and since: and until: keep a window. A narrowed key reads only the activity of the keys it can see.

المعلمات

key_idsArray<String>

Key ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 25.

cursorString

The next_cursor from the previous page, passed back unchanged. Never build one yourself.

api_keyString

Overrides the client API key for this call only.

يُرجع

An OpenEmail::Page of Hashes, with items, has_more? and next_cursor. Each item has id, keyId, keyName, type, createdAt, actor and detail.

مثال

page = client.keys.list_workspace_activity(since: "2026-09-01T00:00:00Z") page.items.each do |change|  puts [change[:keyName], change[:type], change.dig(:actor, :label)].join(" ")end

متاح أيضًا في

API
GET /keys/activity
TypeScript
keys.listWorkspaceActivity()
Python
keys.list_workspace_activity()
CLI
openemail keys list-workspace-activity

keys.list_all_workspace_activity

Collect the audit log of every key into one array

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
list_all_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Walks every page of list_workspace_activity under the same filters and returns every change, newest first.

المعلمات

key_idsArray<String>

Key ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size for each request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Array of Hashes, one per change with the fields list_workspace_activity returns, newest first.

مثال

changes = client.keys.list_all_workspace_activity(since: Time.utc(2026, 9, 1)) over_api = changes.count { |change| change.dig(:detail, :source) == "api" } puts "#{over_api} changes made over the API"

ملاحظات

  • If any page fails, the error is raised and the rows already fetched are discarded.

متاح أيضًا في

API
GET /keys/activity
TypeScript
keys.listAllWorkspaceActivity()
Python
keys.list_all_workspace_activity()

keys.iterate_workspace_activity

Stream the audit log of every key one change at a time

الصلاحياتkeys:readيتصفح النتائج صفحةً صفحة
التوقيع
iterate_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

An Enumerator over list_workspace_activity under the same filters, fetching a page only when the one before is drained. Given a block, it yields each change to the block instead.

المعلمات

key_idsArray<String>

Key ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.

sinceTime, Date or String

Only rows at or after this instant. A Time is sent as ISO 8601 in UTC, and a String must already be ISO 8601.

untilTime, Date or String

Only rows before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

limitInteger

Page size per request, 1 to 100. The server defaults to 25.

cursorString

Starts the walk from this cursor instead of the newest row.

api_keyString

Overrides the client API key for every page of this walk.

يُرجع

An Enumerator of Hashes, one change per step (or yields each one to a block).

مثال

client.keys.iterate_workspace_activity do |change|  next unless change[:type] == "auth_failed"   puts [change[:keyName], change.dig(:detail, :reason), change[:createdAt]].join(" ")end

متاح أيضًا في

API
GET /keys/activity
TypeScript
keys.iterateWorkspaceActivity()
Python
keys.iterate_workspace_activity()

keys.stats

Read what the keys did inside a window

الصلاحياتkeys:reademails:read
التوقيع
stats(key_ids: nil, since: nil, until: nil, grain: nil, offset_minutes: nil, api_key: nil) -> Hash

Returns the numbers behind the Analytics tab of the API keys page: the mail the keys sent and what became of it, the calls refused because a secret was wrong, revoked or expired, the requests they made and how many failed, the routes they called most with the median time each took, and the status codes they got back.

It covers every key you can see, or the ones key_ids: names. The window runs from since: to until:, and left out it is the 30 days before now. grain: sets the bucket width of the series and offset_minutes: shifts the boundaries so days break where the reader's day does.

المعلمات

key_idsArray<String>

Only these keys, at most 50. Left out, every key you can see.

sinceTime, Date or String

The start of the window, a Time or an ISO 8601 instant. Defaults to 30 days before until.

untilTime, Date or String

The end of the window, not included. Defaults to now.

grainString

Bucket width: minute, hour or day, defaulting to day.

offset_minutesInteger

Minutes east of UTC to bucket in, from -840 to 840, defaulting to 0.

api_keyString

Overrides the client API key for this call only.

يُرجع

A Hash with the window it covered, sends, rejected, requests, routes and codes.

مثال

stats = client.keys.stats(grain: "day") puts "#{stats.dig(:sends, :totals, :sends)} sent"p stats[:routes].first(3)

ملاحظات

  • A key narrowed to some domains or addresses only counts the keys whose send scope sits inside its own, and an access token is refused with 403 owner_only unless it acts for the owner of the workspace.

  • The series are sparse: a bucket with nothing in it has no entry, so a chart must fill the gaps.

  • Retried automatically on network failure, since it only reads.

متاح أيضًا في

API
GET /keys/stats
TypeScript
keys.stats()
Python
keys.stats()
CLI
openemail keys stats