> ## 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.

> Deletes a lemlist company. Use `force=true` to detach attached contacts before deletion.

# Delete Company

Removes a lemlist company. Only the lemlist record is deleted — **no CRM-side propagation** is performed.

By default, the request fails with `400 COMPANY_HAS_CONTACTS` if any contact is still attached to the company. Pass `?force=true` to detach those contacts (their `companyId` is unset) before deletion.

## Remapping duplicates: typical workflow

This endpoint is the final step of the contact-to-company remapping flow used to resolve `UNIQUE_INDEX_ERROR_COMPANY` sync failures:

1. `GET /companies?crmSyncStatus=unique_index_error_company` — list lemlist companies that fail to sync because another lemlist company already occupies their CRM record. Each result exposes `crmSync.errors[].metadata.alreadyExistingCompanyId` — the **canonical** lemlist company already linked to the CRM record.
2. `GET /contacts?companyId={duplicateCompanyId}` — list contacts attached to the duplicate.
3. `POST /contacts/{idOrEmail}` with `companyId: {canonicalCompanyId}` — reassign each contact to the canonical lemlist company.
4. `DELETE /companies/{duplicateCompanyId}` — drop the now-empty duplicate. If step 3 was completed for every contact, the call succeeds without `force`. Otherwise use `?force=true` to detach the remaining contacts as part of the deletion.

<Warning>
  There is no soft-delete or undo. Once deleted, the lemlist company record is gone. Contacts detached via `force=true` keep all their other data — only their `companyId` is unset.
</Warning>


## OpenAPI

````yaml delete /companies/{companyId}
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:
  /companies/{companyId}:
    delete:
      tags:
        - Companies
      summary: Delete Company
      description: >-
        Deletes a lemlist company. Refuses by default when contacts are still
        attached — pass `force=true` to detach them (the `companyId` field is
        unset on each contact) before deleting the company.


        **No CRM-side propagation:** only the lemlist record is removed.
        Designed for the contact-to-company remapping workflow: after
        reassigning the contacts of a duplicate company to the canonical one
        (via `POST /contacts/{idOrEmail}`), call this endpoint to drop the
        now-empty duplicate.
      parameters:
        - name: companyId
          in: path
          required: true
          description: The lemlist company ID to delete.
          example: cpn_A1B2C3D4E5F6G7H8I
          schema:
            type: string
            pattern: ^cpn_[a-zA-Z0-9]+$
        - name: force
          in: query
          required: false
          description: >-
            When `true`, detaches contacts attached to this company (unsets
            their `companyId`) before deleting it. When omitted or `false`, the
            request fails with `400 COMPANY_HAS_CONTACTS` if any contact is
            still attached.
          example: 'true'
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Company deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  deletedCompanyId:
                    type: string
                    description: ID of the deleted lemlist company.
                  unlinkedContacts:
                    type: integer
                    description: >-
                      Number of contacts whose `companyId` was unset before
                      deletion. Only present when `force=true`.
                required:
                  - success
                  - deletedCompanyId
              examples:
                no contacts attached:
                  value:
                    success: true
                    deletedCompanyId: cpn_A1B2C3D4E5F6G7H8I
                force=true with attached contacts:
                  value:
                    success: true
                    deletedCompanyId: cpn_A1B2C3D4E5F6G7H8I
                    unlinkedContacts: 3
        '400':
          description: >-
            Invalid request. Possible error codes: `INVALID_COMPANY_ID`
            (malformed ID), `COMPANY_HAS_CONTACTS` (contacts still attached and
            `force` not set).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      contactCount:
                        type: integer
                        description: >-
                          Only on `COMPANY_HAS_CONTACTS` — how many contacts are
                          still attached.
              example:
                success: false
                error:
                  code: COMPANY_HAS_CONTACTS
                  message: >-
                    Company still has contacts attached. Pass ?force=true to
                    detach them before deletion. (3 contacts attached)
                  contactCount: 3
        '401':
          description: The authentication you supplied is incorrect.
          content:
            text/plain:
              example: The authentication you supplied is incorrect
        '404':
          description: Company not found (`COMPANY_NOT_FOUND_BY_ID`).
          content:
            application/json:
              example:
                success: false
                error:
                  code: COMPANY_NOT_FOUND_BY_ID
                  message: Company not found by ID
        '405':
          description: Method not allowed.
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````