> ## Documentation Index
> Fetch the complete documentation index at: https://developer.lemlist.com/llms.txt
> Use this file to discover all available pages before exploring further.

> Connects a new SMTP/IMAP email account to your team.

# Connect Email Account

Connects a custom SMTP/IMAP email account that can be used as a sender in your campaigns.

The account is validated against banned hosts and SSRF checks before being connected. Gmail SMTP/IMAP connections are not allowed — use OAuth instead.

## Examples

<CodeGroup>
  ```json minimal (required fields only) theme={"theme":"dracula"}
  {
    "sender_name": "John Doe",
    "sender_email": "john@company.com",
    "smtp_host": "smtp.company.com",
    "smtp_port": 587,
    "smtp_login": "john@company.com",
    "smtp_password": "password123",
    "imap_host": "imap.company.com",
    "imap_port": 993,
    "imap_login": "john@company.com",
    "imap_password": "password123"
  }
  ```

  ```json with secure flags and user assignment theme={"theme":"dracula"}
  {
    "sender_name": "John Doe",
    "sender_email": "john@company.com",
    "smtp_host": "smtp.company.com",
    "smtp_port": 465,
    "smtp_login": "john@company.com",
    "smtp_password": "password123",
    "smtp_secure": true,
    "imap_host": "imap.company.com",
    "imap_port": 993,
    "imap_login": "john@company.com",
    "imap_password": "password123",
    "imap_secure": true,
    "userId": "usr_A1B2C3D4E5F6G7H8I9"
  }
  ```
</CodeGroup>

<Note>
  The `userId` parameter is optional. When provided, the email account is assigned to that specific team member (who must belong to the team). When omitted, it defaults to the API key creator or team owner.
</Note>


## OpenAPI

````yaml post /user/email-accounts
openapi: 3.0.0
info:
  title: lemlist API
  version: 1.0.0
  description: >-
    Welcome to the lemlist Developer Documentation.


    lemlist is very customizable and open. You'll find on this page all the API
    and integration you can do with lemlist.


    # Rate Limit


    lemlist's API rate limits requests in order to prevent abuse and overload of
    our services.  

    Rate limits are applied on all routes and per API key performing the
    request.  

    The rate limits are **20** requests per **2** seconds.  

    The response provides any information you may need about it:


    | Header | Description |

    | --- | --- |

    | Retry-After | The number of seconds in which you can retry |

    | X-RateLimit-Limit | The maximum requests in that time |

    | X-RateLimit-Remaining | The number of remaining requests you can make |

    | X-RateLimit-Reset | The date when the rate limit will reset |


    _Example of values for the rate limit headers_


    ``` json

    {
        "Retry-After": 2,
        "X-RateLimit-Limit": 20,
        "X-RateLimit-Remaining": 7,
        "X-RateLimit-Reset" : "Tue Feb 16 2021 09:02:42 GMT+0100 (Central European Standard Time)"
    }

     ```

    # Definitions


    ## Team


    A team is the entity of lemlist that can handle users and billing.


    ## Credits


    Credits are the coins a team uses to enrich emails, LinkedIn URLs, etc. via
    the enrich route. Each enrichment feature needs a certain amount of credits
    to run.


    ## User


    You use a user account to connect to lemlist and send messages via the
    connected emails or LinkedIn account.


    ## Campaign


    A campaign is the entity to automate outreach. A campaign has multiple
    sequences composed of steps.


    ## Lead


    A lead is a person that you try to contact via a campaign.


    ## Activity


    An activity is the history of all the steps.


    ## Unsubscribe


    An unsubscribe occurs when a person decides they don't want to receive
    emails from you anymore.


    # Authentication


    All API routes use the dedicated subdomain `api.lemlist.com`.


    lemlist uses API keys to allow access to the API. You can get your lemlist
    API key at our [integration
    page](https://app.lemlist.com/settings/integrations).


    You need to add the `Authorization` header using the `Basic` authentication
    type. `login:password` **where the login is always empty and the password is
    the API key**.


    ⚠️ **Don't forget to add the semicolon (**`:`**) before your API key in curl
    command.**


    > To authorize, use this code: 
      

    ``` shell

    curl https://api.lemlist.com/api/team \
      --user ":YourApiKey"

     ```

    **Make sure to replace** **`YourApiKey`** **with your API key.**


    # Give feedback


    If you want to report a bug, ask for data, or share with us a use case,
    please fill this [form](https://lemlist.typeform.com/to/mfVlkyGf). It will
    help us centralize your needs!
servers:
  - url: https://api.lemlist.com/api
security:
  - basicAuth: []
paths:
  /user/email-accounts:
    post:
      tags:
        - Email Accounts
      summary: Connect Email Account
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - sender_name
                - sender_email
                - smtp_host
                - smtp_port
                - smtp_login
                - smtp_password
                - imap_host
                - imap_port
                - imap_login
                - imap_password
              properties:
                sender_name:
                  type: string
                  description: Display name for the sender.
                  example: John Doe
                sender_email:
                  type: string
                  format: email
                  description: Email address used as the sender.
                  example: john@company.com
                smtp_host:
                  type: string
                  description: SMTP server hostname.
                  example: smtp.company.com
                smtp_port:
                  type: integer
                  description: SMTP server port.
                  example: 587
                smtp_login:
                  type: string
                  description: SMTP authentication login.
                  example: john@company.com
                smtp_password:
                  type: string
                  description: SMTP authentication password.
                  example: password123
                smtp_secure:
                  type: boolean
                  description: Use SSL/TLS for SMTP connection.
                  default: false
                imap_host:
                  type: string
                  description: IMAP server hostname.
                  example: imap.company.com
                imap_port:
                  type: integer
                  description: IMAP server port.
                  example: 993
                imap_login:
                  type: string
                  description: IMAP authentication login.
                  example: john@company.com
                imap_password:
                  type: string
                  description: IMAP authentication password.
                  example: password123
                imap_secure:
                  type: boolean
                  description: Use SSL/TLS for IMAP connection.
                  default: false
                userId:
                  type: string
                  description: >-
                    Assign the email account to a specific team member. Must be
                    a member of the team. Defaults to the API key creator or
                    team owner.
      responses:
        '201':
          description: Email account connected successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier of the created email account.
                  email:
                    type: string
                    format: email
                    description: The sender email address.
                  provider:
                    type: string
                    description: Always `custom` for SMTP/IMAP accounts.
                    example: custom
              example:
                id: umx_A1B2C3D4E5F6G7H8I9
                email: john@company.com
                provider: custom
        '400':
          description: >-
            Possible errors: Bad team / Missing required fields / Invalid host /
            This SMTP mailbox already exists
          content:
            text/plain:
              example: Missing required fields
        '401':
          description: The authentication you supplied is incorrect
          content:
            text/plain:
              example: The authentication you supplied is incorrect
        '403':
          description: User is not a member of this team
          content:
            text/plain:
              example: User is not a member of this team
        '405':
          description: Method not allowed
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````