दस्तावेज़ पर जाएँ
SDK

openemail.workspaces

इस नेमस्पेस का हर मेथड: उसका सिग्नेचर, उसके पैरामीटर, वह क्या लौटाता है और एक उदाहरण।

मेथड

The workspaces the person behind the key or the app can open: list them, create one, choose the one the app opens, and delete the workspace the key or the app belongs to. An API key acts for the workspace owner, and an app for the person who connected it.

workspaces.list()

List your workspaces

स्कोपaccount:read
सिग्नेचर
list(options?: RequestScope): Promise<WorkspaceListResource>

Resolves every workspace the person behind the client can open, the ones they own first, as the workspace switcher of the app lists them. It is about the person, not the workspace the key belongs to. An API key answers for the workspace owner, and an app for the person who connected it.

activeWorkspaceId is the workspace the app opens for them, primaryWorkspaceId the first one they made, which can never be deleted, and personalWorkspaceId their personal space, which holds their free address and is not in data.

पैरामीटर

options.signalAbortSignal

Cancels the request.

options.apiKeystring

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

लौटाता है

WorkspaceListResource with data, an array of WorkspaceResource, and activeWorkspaceId, primaryWorkspaceId and personalWorkspaceId.

उदाहरण

const { data, activeWorkspaceId } = await openemail.workspaces.list() for (const workspace of data) console.log(workspace.name, workspace.id === activeWorkspaceId ? '(open in the app)' : '')

टिप्पणियाँ

  • The key or the app still acts for its own workspace in every other call.

इनमें भी उपलब्ध

API
GET /workspaces
CLI
openemail workspaces list

workspaces.create()

Create a workspace

स्कोपaccount:write
सिग्नेचर
create(body: WorkspaceCreate, options?: RequestScope): Promise<CreatedWorkspaceResource>

Makes a new workspace owned by the person, on the Free plan, and makes it the workspace the app opens for them, as creating one in the app does. The key or the app making the call keeps acting for its own workspace.

An account can own one workspace on the Free plan. While it owns one, the call is refused with 403 workspace_allowance_reached and the message names that workspace: upgrade it first.

पैरामीटर

body.namestringआवश्यक

Up to 64 characters. Leading and trailing spaces are trimmed.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

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

लौटाता है

CreatedWorkspaceResource with id, name, slug and active: true.

उदाहरण

const workspace = await openemail.workspaces.create({ name: 'Acme Support' }) console.log(workspace.id, workspace.slug)

टिप्पणियाँ

  • Not retried automatically. The same name sent twice within ten seconds returns the workspace the first call made, so a retry right after a lost response is safe.

इनमें भी उपलब्ध

API
POST /workspaces
CLI
openemail workspaces create

workspaces.getActive()

Read the workspace the app opens

स्कोपaccount:read
सिग्नेचर
getActive(options?: RequestScope): Promise<ActiveWorkspaceResource>

Resolves the workspace the app opens for the person when they sign in, or the one it falls back to when they never chose one. It is not the workspace the key or the app acts on, which never changes.

पैरामीटर

options.signalAbortSignal

Cancels the request.

options.apiKeystring

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

लौटाता है

ActiveWorkspaceResource with id, name, slug, email, kind, isOwner and createdAt.

उदाहरण

const opened = await openemail.workspaces.getActive() console.log(opened.name, opened.kind)

टिप्पणियाँ

  • kind is personal when the app opens the personal space.

इनमें भी उपलब्ध

API
GET /workspaces/active
CLI
openemail workspaces get-active

workspaces.setActive()

Choose the workspace the app opens

स्कोपaccount:write
सिग्नेचर
setActive(workspaceId: string, options?: RequestScope): Promise<ActiveWorkspaceResource>

Switches the workspace the app opens for the person, as the workspace switcher does, to any workspace they can open. It changes nothing for the key or the app making the call, which keeps acting for its own workspace.

पैरामीटर

workspaceIdstringआवश्यक

A workspace id from list.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

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

लौटाता है

ActiveWorkspaceResource for the workspace the app opens now.

उदाहरण

await openemail.workspaces.setActive('10417196-e324-4283-af98-66ec62167c47')

टिप्पणियाँ

  • A workspace the person cannot open is a 404 resource_not_found.

  • Retried automatically on network failure, since choosing the same workspace twice changes nothing.

इनमें भी उपलब्ध

API
PUT /workspaces/active
CLI
openemail workspaces set-active

workspaces.delete()

Delete the workspace

स्कोपaccount:write
सिग्नेचर
delete(id: string, options: WorkspaceDeleteOptions): Promise<DeletedWorkspaceResource>

Deletes the workspace the key or the app belongs to, with its domains, addresses, mail and members, and cancels its plan. It cannot be undone. options.confirm has to be the name of the workspace, as list shows it, the same way the app asks the person to type it.

Only the owner may do it. An access token acting for a member is refused with 403 owner_only, and a key or an app limited to particular addresses or domains with 422 capability_unsupported. Any other workspace id is a 404, the first workspace an account made is refused with 409 first_workspace, and one with a domain being moved in or out with 409 domain_moving.

पैरामीटर

idstringआवश्यक

The id of the workspace the key or the app belongs to, which me.get reports as workspaceId.

options.confirmstringआवश्यक

The name of the workspace. Letter case and the spaces around it do not matter. Sent as a query parameter.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

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

लौटाता है

DeletedWorkspaceResource with id, deleted: true and activeWorkspaceId, the workspace the app opens from now on.

उदाहरण

const key = await openemail.me.get() await openemail.workspaces.delete(key.workspaceId, { confirm: 'Acme Support' })

टिप्पणियाँ

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. isStepUpRequired on the error says so. An API key is never asked for a code.

  • The key or the app loses its workspace with it, so every later call with it is refused.

  • Not retried automatically. A retry after a lost response is a 404, since the workspace is already gone.

इनमें भी उपलब्ध

API
DELETE /workspaces/{id}
CLI
openemail workspaces delete