> For the complete documentation index, see [llms.txt](https://docs-vnext.kiflo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-vnext.kiflo.com/developers/api-reference/deals/associate-a-customer-to-a-deal.md).

# Associate a customer to a deal

Associate a customer to a deal.

You can either:

* associate an existing customer to an existing deal, by `customerId`
* create a new customer and associate with an existing deal, using `customer` field

Specify either the `customerId` field or the `customer` field.

Here is an example when you associate an existing customer by ID:

```json
{
    "customerId": 42
}
```

Here is an example when you create a new customer. The `properties` field contains the list of custom properties defined on **Customers**.

```json
{
    "customer": {
        "properties": {
            "name": "John Doe",
            "email": "john.doe@customer.com",
            "...": "..."
        },
        "partnerId": 42,
        "source": "Deal"
    }
}
```

````json
{"openapi":"3.0.1","info":{"title":"Kiflo Public API v3","version":"v3"},"security":[{"oauth2":["Api","Deal.AssociateCustomer"]}],"components":{"securitySchemes":{},"schemas":{"DealAssociateCustomerRequestDto":{"type":"object","properties":{"customerId":{"type":"integer","format":"int32","nullable":true},"customer":{"$ref":"#/components/schemas/CustomerCreateRequestDto"}},"additionalProperties":false},"CustomerCreateRequestDto":{"type":"object","properties":{"properties":{"type":"object","additionalProperties":{"nullable":true},"nullable":true},"partnerId":{"type":"integer","format":"int32","nullable":true},"source":{"$ref":"#/components/schemas/CustomerSource"},"status":{"$ref":"#/components/schemas/CustomerStatus"}},"additionalProperties":false},"CustomerSource":{"enum":["Unknown","OnlineReferral","Lead","Deal"],"type":"string"},"CustomerStatus":{"enum":["Unknown","New","Paying","Canceled"],"type":"string"},"DealDto":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"contactId":{"type":"integer","format":"int32"},"sourcePartnerId":{"type":"integer","format":"int32","nullable":true},"stage":{"type":"string","nullable":true},"creationDate":{"type":"string","format":"date-time"},"totalAmount":{"type":"number","format":"double","nullable":true},"properties":{"type":"object","additionalProperties":{"nullable":true},"nullable":true},"sourceLeadId":{"type":"integer","format":"int32","nullable":true},"status":{"$ref":"#/components/schemas/DealStatus"},"partners":{"type":"array","items":{"$ref":"#/components/schemas/DealPartnerRoleDto"},"nullable":true},"contractStartDate":{"type":"string","format":"date-time","nullable":true},"contractEndDate":{"type":"string","format":"date-time","nullable":true},"ownerUserId":{"type":"integer","format":"int32","nullable":true},"owner":{"$ref":"#/components/schemas/UserDto"},"closeDate":{"type":"string","format":"date-time","nullable":true},"customerId":{"type":"integer","format":"int32","nullable":true},"currency":{"type":"string","nullable":true}},"additionalProperties":false},"DealStatus":{"enum":["Unknown","Pending","Accepted","Refused","Expired"],"type":"string"},"DealPartnerRoleDto":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"dealId":{"type":"integer","format":"int32"},"userPartnerOwnerId":{"type":"integer","format":"int32","nullable":true},"userPartnerOwnerName":{"type":"string","nullable":true},"userPartnerFirstName":{"type":"string","nullable":true},"userPartnerLastName":{"type":"string","nullable":true},"userPartnerEmail":{"type":"string","nullable":true},"userPartnerJobTitle":{"type":"string","nullable":true},"userPartnerPhoneNumber":{"type":"string","nullable":true},"userPartnerLinkedInProfileUrl":{"type":"string","nullable":true},"partnerId":{"type":"integer","format":"int32"},"partnerTypeId":{"type":"integer","format":"int32","nullable":true},"creationDate":{"type":"string","format":"date-time"},"partnerName":{"type":"string","nullable":true},"partnerTypeName":{"type":"string","nullable":true}},"additionalProperties":false},"UserDto":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"email":{"type":"string","nullable":true},"firstName":{"type":"string","nullable":true},"lastName":{"type":"string","nullable":true}},"additionalProperties":false}}},"paths":{"/v3/deals/{id}/associate/customer":{"post":{"tags":["Deals"],"summary":"Associate a customer to a deal","description":"Associate a customer to a deal.\r\n\r\nYou can either:\r\n\r\n*   associate an existing customer to an existing deal, by `customerId`\r\n*   create a new customer and associate with an existing deal, using `customer` field\r\n\r\nSpecify either the `customerId` field or the `customer` field.      \r\n\r\nHere is an example when you associate an existing customer by ID:\r\n\r\n``` json\r\n{\r\n    \"customerId\": 42\r\n}\r\n```\r\n\r\nHere is an example when you create a new customer. The `properties` field contains the list of custom properties defined on **Customers**.\r\n\r\n``` json\r\n{\r\n    \"customer\": {\r\n        \"properties\": {\r\n            \"name\": \"John Doe\",\r\n            \"email\": \"john.doe@customer.com\",\r\n            \"...\": \"...\"\r\n        },\r\n        \"partnerId\": 42,\r\n        \"source\": \"Deal\"\r\n    }\r\n}\r\n```","parameters":[{"name":"id","in":"path","description":"The ID of the deal to associate to customer.","required":true,"schema":{"type":"integer","format":"int32"}}],"requestBody":{"content":{"application/json-patch+json":{"schema":{"$ref":"#/components/schemas/DealAssociateCustomerRequestDto"}},"application/json":{"schema":{"$ref":"#/components/schemas/DealAssociateCustomerRequestDto"}},"text/json":{"schema":{"$ref":"#/components/schemas/DealAssociateCustomerRequestDto"}},"application/*+json":{"schema":{"$ref":"#/components/schemas/DealAssociateCustomerRequestDto"}}}},"responses":{"200":{"description":"Customer associated to deal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealDto"}}}},"404":{"description":"Deal not found"}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs-vnext.kiflo.com/developers/api-reference/deals/associate-a-customer-to-a-deal.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
