client.Me
Bu ad alanındaki her yöntem: imzası, parametreleri, döndürdüğü değer ve bir örnek.
Yöntemler
The API key or OAuth access token behind the client: its mode, scopes, role ceiling and workspace, and for a key its own request log, activity and stats.
Me.Get
Describe the API key or access token making the call
Get(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)Returns what the key is: its id, whether it is a live or test key, the workspace it belongs to, the scopes it can use and the allowlists that narrow who it may send as. It needs no scope, because a key may always describe itself, so it works with any valid key and is the first call to make when a request is refused.
scopes is the effective list and the only one that authorises anything. It is the scopes the key was created with intersected with the permissions of the role it was issued under, resolved on every request rather than frozen into the key. grantedScopes is what the key was created holding and roleId names the role that capped it, so a scope present in grantedScopes and missing from scopes was removed by that role. A 403 insufficient_scope on a key the console shows as holding the scope is almost always this, and the fix is to change the role rather than to mint another key.
A key can be narrowed by whole domains, by individual addresses, or by both. domainAllowlist holds whole domains, and the key may send as any address on one of them, including addresses created after the key was. addressAllowlist holds individual addresses and covers only those. Both null means the key may send as any address the workspace owns. When either is set the key is narrowed, and reads of sent mail, tracking and calendar narrow to the same set. An address whose domain is already in domainAllowlist is dropped from addressAllowlist when the key is saved, so the two lists never overlap.
Called with an OAuth access token it describes the token instead, and object tells the two apart. A key answers object: 'api_key' and kind: 'apiKey'. A token answers object: 'oauth_token' and kind: 'oauth', with id null, clientId naming the connected app, roleId null and mode always live. scopes and grantedScopes are the permissions the person approved for the app, and the allowlists are the addresses and domains the app may reach. expiresAt is when that approval runs out, or null when it never does. It is not the expiry of the access token, which the app renews with its refresh token.
Parametreler
openemail.WithAPIKeystringDescribes this key instead of the credential the client was built with.
Döndürür
An openemail.Object. For an API key it is an API key self object, with object set to api_key, kind, id, mode, scopes, grantedScopes, roleId, workspaceId, addressAllowlist and domainAllowlist. For an OAuth access token it is an OAuth token self object, with object set to oauth_token, the same fields with id and roleId null, plus clientId and expiresAt.
Örnek
key, err := client.Me.Get(ctx)if err != nil { return err} fmt.Println(key.String("mode"), key.String("workspaceId"), key.String("object"))Notlar
Narrowing a role takes effect on the next request without touching the key itself, so
scopescan shrink between two calls with the same secret. Replacing the secret is a separate act, andMe.Rotateis the call that does it.roleIdis null on a key with no ceiling, which is what every key issued before roles existed still has.A failure here is a 401 naming the credential problem:
missing_api_key,invalid_api_key,revoked_api_key,expired_api_keyorinactive_api_keyfor a key switched off in the console.An access token that has run out is a 401
expired_access_token, which the app answers by renewing it with its refresh token.invalid_access_tokenand thegrant_*codes mean the app has to be connected again.
Şurada da var
- API
GET /keys/self- TypeScript
me.get()- Python
me.get()- Ruby
me.get- PHP
me->get- Java
me().get- C#
Me.GetAsync- CLI
openemail me get
Me.Ping
Check that a key or access token authenticates
Ping(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)An authentication smoke test. It runs the same key check every other endpoint runs and answers ok: true with the key id, its mode, the workspace and the effective scopes. It needs no scope, so a key with none at all still gets a 200.
Use it in a health check or at process start to fail fast on a revoked, expired or mistyped key. The answer carries the same scope detail as Me.Get, scopes effective and grantedScopes as created with roleId naming the cap between them, but it leaves out both allowlists. Call Me.Get when you need to know which domains and which addresses the key may send as.
An OAuth access token gets the same answer with kind: 'oauth', keyId null, clientId naming the connected app, roleId null and mode always live. A key answers kind: 'apiKey'.
Parametreler
openemail.WithAPIKeystringChecks this key instead of the credential the client was built with.
Döndürür
An openemail.Object with ok set to true, kind, keyId, mode, scopes, grantedScopes, roleId and workspaceId, plus clientId for an OAuth access token.
Örnek
ping, err := client.Me.Ping(ctx)if err != nil { return err} fmt.Println(ping.String("keyId"))Notlar
The id is
keyIdhere andidonMe.Get, and there is noobjectfield on this response, so tell a key from a token bykind.A bad key never returns
ok: false. It returns an*openemail.Errorwith status 401, soopenemail.ErrAuthenticationis the check to make.
Şurada da var
- API
GET /ping- TypeScript
me.ping()- Python
me.ping()- Ruby
me.ping- PHP
me->ping- Java
me().ping- C#
Me.PingAsync- CLI
openemail me ping
Me.Rotate
Replace the calling key's own secret
Rotate(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)Mints a new secret for the key making the call and returns with the same body as Me.Get plus token, the new key in full. That is the only place the value appears, so store it before anything else.
Everything else about the key survives. The id, the mode, the scopes, the role ceiling, the address allowlist and the domain allowlist all come back unchanged, so token is the only thing your configuration has to change. Because the id is stable, an audit trail joined on it stays joined up across rotations.
There is no overlap window. The old secret stops authenticating the moment this call commits, and neither secret can be shown again. Write token to wherever the key is read from before the next request. A lost response is the bad case: the rotation may have committed to a secret nobody saw, which leaves the key unusable until someone mints it a new secret in the console.
Parametreler
openemail.WithAPIKeystringRotates this key instead of the one the client was built with.
Döndürür
An openemail.Object: the key object body plus token, the new key formatted oe_live_ or oe_test_ then the 24 character key id, an underscore and 43 base64url characters, plus rotationCount and rotatedAt.
Örnek
rotated, err := client.Me.Rotate(ctx)if err != nil { return err} fmt.Println(rotated.Int("rotationCount"), rotated.String("rotatedAt"), rotated.String("token"))Notlar
It needs
keys:write, and a key without it gets 403insufficient_scope. No key holds that scope unless somebody gave it one in the console, so a key that cannot reach this call has to be rotated from there.There is no request body and the success status is 200, not 201.
Not retried automatically. Repeating a rotation would invalidate the secret the first attempt returned, so a failure has to be judged rather than retried.
The 404 and the two 409s are races rather than everyday answers, because a key that is missing, revoked or expired cannot authenticate this call in the first place. They mean the key changed state between authenticating and rotating: 404 if the row went, 409
revokedor 409expiredotherwise. None of the three is rotatable, so the answer is a new key from the console.rotationCountis the count after this call, so the first rotation of a key answers 1, androtatedAtis when that rotation committed.
Şurada da var
- API
POST /keys/self/rotate- TypeScript
me.rotate()- Python
me.rotate()- Ruby
me.rotate- PHP
me->rotate- Java
me().rotate- C#
Me.RotateAsync- CLI
openemail me rotate
Me.ListRequests
List one page of the calling key's own request log
ListRequests(ctx context.Context, opts ...openemail.RequestOption) (*openemail.Page, error)Returns one page of the calls the key making the request made, newest first. It needs no scope: a key may always read its own log, and it reads no other key's here. Keys.ListRequests and Keys.ListWorkspaceRequests are the ones that reach other keys, behind keys:read.
The request log records every authenticated call the key made: method, path, status, error code, duration, IP and user agent, and never a body or a query string. Nothing is pruned, so the log reaches back to the key's first call, and it runs straight through a rotation because it hangs off the key id. openemail.WithFailedOnly, openemail.WithStatusCodes, openemail.WithPath, openemail.WithSince and openemail.WithUntil narrow it, and they combine.
Parametreler
openemail.WithFailedOnlyboolOnly calls answered with a status of 400 or more.
openemail.WithStatusCodes...intOnly calls answered with one of these HTTP status codes, such as
401and403. At most 20, each from 100 to 599, sent comma-separated asstatus.openemail.WithPathstringOnly calls to this route, whatever the method, such as
/emailsor/emails/:id. It matches the route, not the exact path: an id counts as:idand an email address as:address. End it with*to read every route that starts with it, such as/emails/*.openemail.WithSincetime.TimeOnly rows at or after this instant. A
time.Time, sent as an ISO 8601 instant.openemail.WithUntiltime.TimeOnly rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.openemail.WithLimitintRows per page, a whole number from 1 to 100. The server defaults to 25.
openemail.WithCursorstringThe
NextCursorfrom the previous page, passed back unchanged. Never build one yourself.openemail.WithAPIKeystringReads the log of this key instead of the one the client was built with.
Döndürür
A *openemail.Page with Items, HasMore and NextCursor. Each item has id, keyId, keyName, requestId, method, path, status, errorCode, durationMs, ip, userAgent and createdAt.
Örnek
page, err := client.Me.ListRequests( ctx, openemail.WithStatusCodes(429), openemail.WithSince(time.Date(2026, time.October, 1, 0, 0, 0, 0, time.UTC)),)if err != nil { return err} for _, request := range page.Items { fmt.Println(request.String("createdAt"), request.String("method"), request.String("path"), request.Int("status"))} fmt.Println(page.HasMore, page.NextCursor)Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.openemail.WithPathmatches the route rather than the exact path, because the log folds ids and addresses: every call to/emails/<id>is the one route/emails/:id. Each row still carries the exactpath.The call that reads the log is logged too.
The cursor is opaque and stays valid under the same filters. One this log did not hand out is a 400
invalid_cursor.
Şurada da var
Me.ListAllRequests
Collect the calling key's whole request log into one slice
ListAllRequests(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)Walks every page of Me.ListRequests under the same filters. The log is never pruned, so give it a window unless you mean to read the key's whole history, or use Me.IterateRequests to stop early.
Parametreler
openemail.WithFailedOnlyboolOnly calls answered with a status of 400 or more.
openemail.WithStatusCodes...intOnly calls answered with one of these HTTP status codes, such as
401and403. At most 20, each from 100 to 599, sent comma-separated asstatus.openemail.WithPathstringOnly calls to this route, whatever the method, such as
/emailsor/emails/:id. It matches the route, not the exact path: an id counts as:idand an email address as:address. End it with*to read every route that starts with it, such as/emails/*.openemail.WithSincetime.TimeOnly rows at or after this instant. A
time.Time, sent as an ISO 8601 instant.openemail.WithUntiltime.TimeOnly rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.openemail.WithLimitintPage size per request, 1 to 100. The server defaults to 25.
openemail.WithCursorstringStarts the walk from this cursor instead of the newest row.
openemail.WithAPIKeystringReads the log of this key instead of the one the client was built with, for every page of this walk.
Döndürür
A []openemail.Object, newest first. Each item has id, keyId, keyName, requestId, method, path, status, errorCode, durationMs, ip, userAgent and createdAt.
Örnek
failures, err := client.Me.ListAllRequests( ctx, openemail.WithFailedOnly(true), openemail.WithSince(time.Now().Add(-time.Hour)), openemail.WithLimit(100),)if err != nil { return err} fmt.Println(len(failures), "failed calls in the last hour")Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.
Şurada da var
Me.IterateRequests
Stream the calling key's own request log one call at a time
IterateRequests(ctx context.Context, opts ...openemail.RequestOption) *openemail.IteratorAn iterator over Me.ListRequests under the same filters, fetching a page only when the one before is drained.
Parametreler
openemail.WithFailedOnlyboolOnly calls answered with a status of 400 or more.
openemail.WithStatusCodes...intOnly calls answered with one of these HTTP status codes, such as
401and403. At most 20, each from 100 to 599, sent comma-separated asstatus.openemail.WithPathstringOnly calls to this route, whatever the method, such as
/emailsor/emails/:id. It matches the route, not the exact path: an id counts as:idand an email address as:address. End it with*to read every route that starts with it, such as/emails/*.openemail.WithSincetime.TimeOnly rows at or after this instant. A
time.Time, sent as an ISO 8601 instant.openemail.WithUntiltime.TimeOnly rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.openemail.WithLimitintPage size per request, 1 to 100. The server defaults to 25.
openemail.WithCursorstringStarts the walk from this cursor instead of the newest row.
openemail.WithAPIKeystringReads the log of this key instead of the one the client was built with, for every page of this walk.
Döndürür
An *openemail.Iterator yielding one call per step.
Örnek
for request, err := range client.Me.IterateRequests(ctx, openemail.WithPath("/emails"), openemail.WithStatusCodes(422)).All() { if err != nil { return err } fmt.Println(request.String("createdAt"), request.String("errorCode"), request.String("requestId"))}Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.
Şurada da var
Me.ListActivity
List one page of what happened to the calling key
ListActivity(ctx context.Context, opts ...openemail.RequestOption) (*openemail.Page, error)Returns one page of the audit log of the key making the request, newest first. It needs no scope, and it reads no other key's history: Keys.ListActivity and Keys.ListWorkspaceActivity do that, behind keys:read.
Every change to the key is a row: created, updated, rotated, deactivated and reactivated, 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 detail.source says where it came from: console, api, mcp or documentation.
Parametreler
openemail.WithSincetime.TimeOnly rows at or after this instant. A
time.Time, sent as an ISO 8601 instant.openemail.WithUntiltime.TimeOnly rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.openemail.WithLimitintRows per page, a whole number from 1 to 100. The server defaults to 25.
openemail.WithCursorstringThe
NextCursorfrom the previous page, passed back unchanged. Never build one yourself.openemail.WithAPIKeystringReads the log of this key instead of the one the client was built with.
Döndürür
A *openemail.Page with Items, HasMore and NextCursor. Each item has id, keyId, keyName, type, createdAt, actor and detail.
Örnek
page, err := client.Me.ListActivity(ctx)if err != nil { return err} for _, activity := range page.Items { fmt.Println(activity.String("createdAt"), activity.String("type"), activity.Object("actor").String("label"), activity.Object("detail").String("source"))} fmt.Println(page.HasMore, page.NextCursor)Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.A revoked or deleted key cannot authenticate, so
revokedanddeletedrows are only ever read by another key, throughKeys.ListActivity.
Şurada da var
Me.ListAllActivity
Collect everything that happened to the calling key into one slice
ListAllActivity(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)Walks every page of Me.ListActivity under the same window. Use Me.IterateActivity to stop early.
Parametreler
openemail.WithSincetime.TimeOnly rows at or after this instant. A
time.Time, sent as an ISO 8601 instant.openemail.WithUntiltime.TimeOnly rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.openemail.WithLimitintPage size per request, 1 to 100. The server defaults to 25.
openemail.WithCursorstringStarts the walk from this cursor instead of the newest row.
openemail.WithAPIKeystringReads the log of this key instead of the one the client was built with, for every page of this walk.
Döndürür
A []openemail.Object, newest first. Each item has id, keyId, keyName, type, createdAt, actor and detail.
Örnek
history, err := client.Me.ListAllActivity(ctx)if err != nil { return err} rotations := 0 for _, activity := range history { if activity.String("type") == "rotated" { rotations++ }} fmt.Println(rotations, "rotations")Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.
Şurada da var
Me.IterateActivity
Stream what happened to the calling key one change at a time
IterateActivity(ctx context.Context, opts ...openemail.RequestOption) *openemail.IteratorAn iterator over Me.ListActivity under the same window, fetching a page only when the one before is drained.
Parametreler
openemail.WithSincetime.TimeOnly rows at or after this instant. A
time.Time, sent as an ISO 8601 instant.openemail.WithUntiltime.TimeOnly rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.openemail.WithLimitintPage size per request, 1 to 100. The server defaults to 25.
openemail.WithCursorstringStarts the walk from this cursor instead of the newest row.
openemail.WithAPIKeystringReads the log of this key instead of the one the client was built with, for every page of this walk.
Döndürür
An *openemail.Iterator yielding one change per step.
Örnek
for activity, err := range client.Me.IterateActivity(ctx).All() { if err != nil { return err } if activity.String("type") == "auth_failed" { fmt.Println("last refused attempt at", activity.String("createdAt")) break }}Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.
Şurada da var
Me.Stats
Read what the calling key did inside a window
Stats(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)Returns the figures of the key making the request: the requests it made and how many failed, the calls refused because its secret was wrong, revoked or expired, the routes it called most with the median time each took, and the status codes it got back. It needs no scope, and it reads no other key's figures: Keys.Stats does that.
sends, the mail the key sent and what became of it, is filled only when the key holds emails:read. Without that scope it is null, never zeros, so a missing permission cannot read as a quiet week. Test it with Has first, because the readers of an openemail.Object return zero for a field that is null.
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 offsetMinutes shifts the boundaries so days break where the reader's day does.
Parametreler
openemail.WithSincetime.TimeThe start of the window, a
time.Time. Defaults to 30 days beforeuntil.openemail.WithUntiltime.TimeThe end of the window, not included. Defaults to now.
openemail.WithGrainstringBucket width:
minute,hourorday, defaulting today.openemail.WithOffsetMinutesintMinutes east of UTC to bucket in, from -840 to 840, defaulting to 0.
openemail.WithAPIKeystringReads the figures of this key instead of the one the client was built with.
Döndürür
An openemail.Object with the window it covered, keyIds holding the id of the key alone, sends or null, rejected, requests, routes and codes.
Örnek
stats, err := client.Me.Stats(ctx, openemail.WithGrain("hour"), openemail.WithSince(time.Now().Add(-24*time.Hour)))if err != nil { return err} failed := 0 for _, bucket := range stats.Objects("requests") { failed += bucket.Int("failed")} fmt.Println(failed, "failed calls today") if stats.Has("sends") { fmt.Println(stats.Object("sends").Object("totals").Int("sends"), "emails sent")} else { fmt.Println("this key cannot read its sends")}Notlar
An OAuth access token is refused with 403
api_key_only. Calls made with one are not logged, so there is nothing to read.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.
Şurada da var
- API
GET /keys/self/stats- TypeScript
me.stats()- Python
me.stats()- Ruby
me.stats- PHP
me->stats- Java
me().stats- C#
Me.StatsAsync- CLI
openemail me stats