> For the complete documentation index, see [llms.txt](https://closingdealz.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://closingdealz.gitbook.io/product-docs/developers/api-endpoints.md).

# API Endpoints

Currently, our API offers the following endpoint for lead creation:

### Create Leads

* **Endpoint:** `POST /api/v1/leads`
* **Description:** This endpoint allows for the creation of new leads in the ClosingDealz CRM system.
* **Headers:**
  * `Content-Type: application/json`
  * `X-API-Key: your_api_key_here`
* **Example Body Request:**

```json
[
    {
        "company": "Company Name",
        "contactPerson": "Contact Person Name",
        "jobTitle": "Job Title",
        "email": "email@example.com",
        "phoneNumber": "Phone Number",
        "notes": "Any relevant notes or information about the lead"
    }
]
```

Visit Lead and Contact Request Objects to view all the available fields of the request.

{% content-ref url="/pages/TBtlyNwCZNc9oKD80Rmc" %}
[Lead Request Object](/product-docs/developers/api-endpoints/lead-request-object.md)
{% endcontent-ref %}

{% content-ref url="/pages/UCHCrZkKt29QtESK67aI" %}
[Contact Request Object](/product-docs/developers/api-endpoints/contact-request-object.md)
{% endcontent-ref %}

###

### **Success Responses:**

**Code:** `200 OK`

**Description:** Successfully created leads.

```json
{ 
    "succeeded": true, 
    "statusCode": 200, 
    "statusCodeDescription": "NONE", 
    "message": null
}
```

### **Error Responses:**

**Code:** `401 Unauthorized`

**Description:** The submitted API key was not valid.

```json
{ 
    "succeeded": false, 
    "statusCode": 401, 
    "statusCodeDescription": "NONE", 
    "message": "Invalid API key."
}
```

OR

**Code:** `400 Bad Request`

**Description:** Only 100 leads is allowed to be created at once.

```json
{ 
    "succeeded": false, 
    "statusCode": 400, 
    "statusCodeDescription": "NONE", 
    "message": "The maximum amount of leads to create at once is 100, but was {lead_count}."
}
```

OR

**Code:** `400 Bad Request`

**Description:** Workspace plan has been downgrade to **Free Plan**, only workspaces with **Basic Plan** can use the API without limits.

```json
{ 
    "succeeded": false, 
    "statusCode": 400, 
    "statusCodeDescription": "NONE", 
    "message": "Reached the maximum limit of leads on the free plan."
}
```

OR

**Code:** `400 Bad Request`

**Description:** Can not have more than 5 leads on the F**ree Plan**. Only workspaces with **Basic Plan** can use the API without limits.

```json
{ 
    "succeeded": false, 
    "statusCode": 400, 
    "statusCodeDescription": "NONE", 
        "message": "Can not have more than 5 leads on the free plan."
}
```

OR

**Code:** `429 Too Many Requests`

**Description:** Too many requests, only 1000 requests every 5 minutes is allowed.

```json
{ 
    "succeeded": false, 
    "statusCode": 429, 
    "statusCodeDescription": "NONE", 
    "message": "Too many requests. Please try again later."
}
```

### Example Request

Here's an example of how to create a lead using `curl`:

```bash
curl -X POST https://app.closingdealz.io/api/v1/leads \
     -H 'X-API-Key: your_api_key_here' \
     -H 'Content-Type: application/json' \
     -d '[{ "Company": "Open AI", "Notes": "Interested in API integration" }]'
```

Replace `your_api_key_here` with your actual API key.
