> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # GetOrCreateSenderEmail # Package: emails # Namespace: SenderEmailService # Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/emails/sender-emails/get-or-create-sender-email.md ## Permission Scopes: Access Verticals by Automations: SCOPE.CRM.ACCESS-VERTICALS-BY-AUTOMATIONS ## Introduction Retrieve the sender email info by the email address, or creates a new one. If you try to create an email with a name that already exists, this method won't return an error. Instead, the info of the existing sender email will be returned. --- ## REST API ### Schema ``` Method: getOrCreateSenderEmail Description: Retrieve the sender email info by the email address, or creates a new one. If you try to create an email with a name that already exists, this method won't return an error. Instead, the info of the existing sender email will be returned. URL: https://www.wixapis.com/sender-emails/v1/sender-emails/get-or-create Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: emailAddress Method parameters: param name: emailAddress | type: emailAddress | description: Requested sender email. | required: true Return type: GetOrCreateSenderEmailResponse - name: senderEmail | type: SenderEmail | description: The requested sender email. - name: id | type: string | description: Sender email GUID. - name: createdDate | type: string | description: Date and time the sender email was created. - name: updatedDate | type: string | description: Date and time the sender email was last updated. - name: emailAddress | type: string | description: Sender email address. - name: verified | type: boolean | description: Whether the sender email is verified. - name: extendedFields | type: ExtendedFields | description: Extensions allowing users to save custom data related to the sender emails. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). ``` ### Examples ### GetOrCreateSenderEmail ```curl ~~~cURL curl -X POST 'https://www.wixapis.com/sender-emails/v1/sender-emails/get-or-create' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{ "emailAddress": "john.doe@example.com" }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.emails.SenderEmailService.getOrCreateSenderEmail(emailAddress) Description: Retrieve the sender email info by the email address, or creates a new one. If you try to create an email with a name that already exists, this method won't return an error. Instead, the info of the existing sender email will be returned. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: emailAddress Method parameters: param name: emailAddress | type: string | description: Requested sender email. | required: true Return type: PROMISE - name: senderEmail | type: SenderEmail | description: The requested sender email. - name: _id | type: string | description: Sender email GUID. - name: _createdDate | type: Date | description: Date and time the sender email was created. - name: _updatedDate | type: Date | description: Date and time the sender email was last updated. - name: emailAddress | type: string | description: Sender email address. - name: verified | type: boolean | description: Whether the sender email is verified. - name: extendedFields | type: ExtendedFields | description: Extensions allowing users to save custom data related to the sender emails. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). ``` ### Examples ### getOrCreateSenderEmail ```javascript import { senderEmails } from '@wix/sender-emails'; async function getOrCreateSenderEmail(emailAddress) { const response = await senderEmails.getOrCreateSenderEmail(emailAddress); }; ``` ### getOrCreateSenderEmail (with elevated permissions) ```javascript import { senderEmails } from '@wix/sender-emails'; import { auth } from '@wix/essentials'; async function myGetOrCreateSenderEmailMethod(emailAddress) { const elevatedGetOrCreateSenderEmail = auth.elevate(senderEmails.getOrCreateSenderEmail); const response = await elevatedGetOrCreateSenderEmail(emailAddress); } ``` ### getOrCreateSenderEmail (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { senderEmails } from '@wix/sender-emails'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { senderEmails }, // Include the auth strategy and host as relevant }); async function getOrCreateSenderEmail(emailAddress) { const response = await myWixClient.senderEmails.getOrCreateSenderEmail(emailAddress); }; ``` ---