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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://closingdealz.gitbook.io/product-docs/developers/api-endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
