# 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="api-endpoints/lead-request-object" %}
[lead-request-object](api-endpoints/lead-request-object)
{% endcontent-ref %}

{% content-ref url="api-endpoints/contact-request-object" %}
[contact-request-object](api-endpoints/contact-request-object)
{% 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.
