openemail.branding
이 네임스페이스의 모든 메서드: 시그니처, 매개변수, 반환값과 예시.
메서드
The brand of the workspace: its mark, its logo and its logo for dark mode, its primary and secondary fonts, and the background of the sign-in page of its web app address. Read it, change the fonts and the background, and upload or remove each image.
branding.get()
Read the brand of the workspace
get(options?: RequestScope): Promise<BrandingResource>Returns the brand of the workspace, as its Customisations page shows it: a link to each brand image in images, the primary and secondary fonts in fonts, and the background of the sign-in page in loginBackground.
The mark shows in the workspace switcher. The logo shows at the top of the sidebar, and it is what brands the web app address and, on a paid plan, the emails OpenEmail sends for the workspace, at their top and foot. Without a logo, both look like OpenEmail. The fonts apply in the web app for everyone in the workspace, the primary font to its text and the secondary font to page headings, and the sign-in background shows on the web app address, either way.
A personal space carries no brand, so every image and font reads as null there and editable is false.
매개변수
options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
반환값
BrandingResource, { object: 'branding', editable, images, fonts, loginBackground }. images holds mark, wordmark, wordmarkDark and loginBackground, each a URL or null. fonts holds primary and secondary, each a BrandFontId or null for the default. loginBackground is { kind, preset, color, logo }, or null for the default, where logo is dark, light or null to match the background.
예시
const branding = await openemail.branding.get() console.log(branding.images.wordmark ?? 'no logo', branding.fonts.primary ?? 'the default font')참고
editablesays whether this key may change the brand. It is false in a personal space, for a key withoutsettings:write, and for a key limited to particular addresses or domains.A
loginBackgroundof kindimagenever reads back without its photo: once the photo is removed it reads as the preset or colour kept with it, or as null.
다른 사용처
branding.update()
Change the fonts and the sign-in background of the brand
update(body: BrandingUpdate, options?: RequestScope): Promise<BrandingResource>Changes the fonts, the sign-in page background or both, and returns the brand in the same shape as get. A field left out keeps its value, and so does a font left out of fonts. loginBackground replaces the background there was, and null sets the default.
With kind: 'image' the sign-in page shows the photo uploaded with uploadImage('login-background', ...), so upload that first: without it the call is refused. Uploading one switches the page to it on its own, so most callers never send kind: 'image' themselves.
매개변수
body.fontsBrandingFontsUpdateThe fonts to change. Leave it out to keep both.
body.fonts.primaryBrandFontId | nullThe primary font: one of the ids in
BRAND_FONT_IDS, such asinterorgeorgia, or null for the default. Left out, it keeps its value.body.fonts.secondaryBrandFontId | nullThe secondary font, an id from
BRAND_FONT_IDSor null for the default. Left out, it keeps its value.body.loginBackgroundLoginBackgroundInput | nullThe sign-in page background, replacing the one there was, or null for the default. Leave it out to keep it.
body.loginBackground.kindLoginBackgroundKindpreset,colororimage. Required onceloginBackgroundis given.body.loginBackground.presetLoginBackgroundPreset | nulldusk,mist,sandornight. Required whenkindispreset, and kept for later otherwise.body.loginBackground.colorstring | nullA colour as
#and six hex digits, such as#1f2937, stored lowercased. Required whenkindiscolor, and kept for later otherwise.body.loginBackground.logoLoginLogo | nulldarkshows your logo andlightyour logo for dark mode. Null, the default, picks the one that stands out against the background.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
반환값
BrandingResource as the call left it.
예시
const branding = await openemail.branding.update({ fonts: { primary: 'inter', secondary: 'georgia' }, loginBackground: { kind: 'color', color: '#1f2937' }}) console.log(branding.fonts, branding.loginBackground)참고
A font that is not on the list, a
presetbackground with no preset, animagebackground while no sign-in photo is uploaded, or a colour that is not#and six hex digits is refused with 422invalid_parameter, andparamnames the field, such asfonts.primaryorloginBackground.kind. Any other field is 422unknown_parameter.A personal space carries no brand, so the call is refused there with 409
branding_unavailable.The brand applies to the whole workspace, so a key or app limited to particular addresses or domains is refused with 422
capability_unsupportedondomainAllowlist. Such a key can still read it withget.Retried automatically on network failure and retryable statuses, since sending the same change twice leaves the same brand.
다른 사용처
branding.uploadImage()
Upload one of the brand images
uploadImage(variant: BrandImageVariant, data: RawBody, options?: BrandImageOptions): Promise<BrandingResource>Sends the image bytes as the request body, replacing the image there was, and returns the brand. variant names the image: mark, the square icon, wordmark, the logo, wordmark-dark, the logo for dark mode, or login-background, the photo behind the sign-in page of the web app address.
Up to 5 MB goes in, and it is fitted and stored as WebP: the mark into 512 by 512 pixels, the two logos into 1024 by 256, and the sign-in photo into 2560 by 1600. The mark and the logos take SVG, PNG, JPEG or WebP, and the sign-in photo PNG, JPEG, WebP or GIF. An SVG is turned into a picture, and an animated image keeps its first frame.
Uploading the sign-in photo also switches the sign-in page to it. The type is read from options.contentType, or from a Blob's own type when that is left out, and without either the server refuses the bytes with 422 invalid_image.
매개변수
variantBrandImageVariant필수mark,wordmark,wordmark-darkorlogin-background.dataRawBody필수The image: a
Blob,ArrayBufferorUint8Array.options.contentTypeBrandImageTypeimage/svg+xml,image/png,image/jpeg,image/webporimage/gif. Required unlessdatais aBlobwith a type.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
반환값
BrandingResource with the new image in images.
예시
const file = Bun.file('logo.svg') const branding = await openemail.branding.uploadImage('wordmark', await file.arrayBuffer(), { contentType: 'image/svg+xml' }) console.log(branding.images.wordmark)참고
An image of a type that variant does not take, one over 5 MB, or one that cannot be read is refused with 422
invalid_image, and a variant that is not one of the four with 422invalid_parameteronvariant.A personal space carries no brand, so the call is refused there with 409
branding_unavailable.The brand applies to the whole workspace, so a key or app limited to particular addresses or domains is refused with 422
capability_unsupportedondomainAllowlist. Such a key can still read it withget.A busy image service answers 503
image_busyand a failed save 502image_not_stored, which the SDK retries like any other retryable status.
다른 사용처
branding.removeImage()
Remove one of the brand images
removeImage(variant: BrandImageVariant, options?: RequestScope): Promise<BrandingResource>Removes one brand image, deletes the stored file and returns the brand, so the default shows in its place. Removing the sign-in photo while the sign-in page shows it switches the page back to the preset or colour chosen before it, or to the default. Removing an image that is not set changes nothing.
매개변수
variantBrandImageVariant필수mark,wordmark,wordmark-darkorlogin-background.options.signalAbortSignalCancels the request.
options.apiKeystringOverrides the client's API key for this call only.
반환값
BrandingResource without that image.
예시
const branding = await openemail.branding.removeImage('login-background') console.log(branding.images.loginBackground, branding.loginBackground)참고
A personal space carries no brand, so the call is refused there with 409
branding_unavailable.The brand applies to the whole workspace, so a key or app limited to particular addresses or domains is refused with 422
capability_unsupportedondomainAllowlist. Such a key can still read it withget.Retried automatically on network failure and retryable statuses, since a second attempt after one that went through finds nothing to remove.