# Chatroom

## Create a new chatroom for a lead V3

> \<ul>\<li> Roles Allowed: ADMIN \</li>\<li> Impersonated User Allowed: False \</li>\<li> Partner Allowed: True \</li>\<li> leadId is the id field in contact table \</li>\<li> API will create a chatroom or return an existing chatroom for this contact \</li>\<li> Chatroom will be created for the provided Waba and the Phone number if they are registered for this org \</li>\<li> Chatroom's display name will be display name if provided \</li>\<li> Otherwise Chatroom's display name will be contact's crm\_id + FN + LN \</li>\<li> After a certain thresold number of days of inactivity a chatroom is Deactivated. After Deactivation of chatroom, a new chatroom for the same contact with a different crmId can be created\</li>\<li> After a certain thresold number of days of creation a chatroom is Expired. After Expiry of chatroom, a new chatroom for the same contact with a different crmId can be created\</li>\<li> At any point of time only one active chatroom (not deactivated & not expired) can exist for a unique phone number\</li>\<li> On every chatroom creation, a new contact-waba is created if not already present \</li>\<li> Each contact can only have one waba mapping\</li>\<li> Every contact-waba mapping is per Waba per Waba Phone, i.e any contact with same phone can one active chatroom present across multiple Waba Phone(s)\</li>\<li> By default (fail\_if\_chatroom\_exists\_on\_other\_wabaphone = true), in case of an existing contact-waba mapping, we throw a Conflict upon trying to create a chatroom for the same phone number.\</li>\<li> For fail\_if\_chatroom\_exists\_on\_other\_wabaphone = false, we create chatroom with same phone number with the next available Waba Phone.\</li>\<li> This API allows chatroom handover, that is, that the agent will only be assigned to chatroom after the lead has responded\</li>\<li> Assignment of this chatroom can be done by specifying a user or a group from which the user can be selected\</li>\</ul>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]},{}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"CreateChatroomReqV3Dto":{"required":["assign_details","lead_id"],"type":"object","properties":{"lead_id":{"type":"string"},"display_name":{"type":"string","deprecated":true},"remote_waba_id":{"type":"string"},"remote_phone_id":{"type":"string"},"force_deactivate":{"type":"boolean","description":"When this option is set to true, then all the existing chatrooms for the lead will be deactivated and a new chatroom would be created.","default":false},"fail_if_chatroom_exists_on_other_waba_phone":{"type":"boolean","description":"If set to true, the request will fail if a chatroom already exists on a different WABA phone.","default":true},"assign_details":{"$ref":"#/components/schemas/ChatroomAssignmentDetailsDto"}}},"ChatroomAssignmentDetailsDto":{"required":["assign_mode"],"type":"object","properties":{"assign_mode":{"type":"string","enum":["USER","GROUP","DELEGATE"]},"user_id":{"type":"string","description":"User ID to assign the chatroom to. Either user_id or user_email is required when assign_mode is USER."},"user_email":{"type":"string","description":"User Email to assign the chatroom to. Either user_id or user_email is required when assign_mode is USER."},"group_id":{"type":"string","description":"Group ID to assign the chatroom to. Required when assign_mode is GROUP."},"assign_on_handover":{"type":"boolean","description":"Whether to assign the chatroom on handover","default":false}}},"ChatroomRespDto":{"type":"object","properties":{"chatroom_id":{"type":"string"},"external_ref_id":{"type":"string"},"is_existing":{"type":"boolean"},"is_deactivated":{"type":"boolean"},"is_expired":{"type":"boolean"},"expiry_ts":{"type":"string","format":"date-time"},"deactivation_ts":{"type":"string","format":"date-time"},"user_id":{"type":"string"}}},"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v3/org/{orgId}/lead/chatroom":{"post":{"tags":["chatroom-controller"],"summary":"Create a new chatroom for a lead V3","description":"<ul><li> Roles Allowed: ADMIN </li><li> Impersonated User Allowed: False </li><li> Partner Allowed: True </li><li> leadId is the id field in contact table </li><li> API will create a chatroom or return an existing chatroom for this contact </li><li> Chatroom will be created for the provided Waba and the Phone number if they are registered for this org </li><li> Chatroom's display name will be display name if provided </li><li> Otherwise Chatroom's display name will be contact's crm_id + FN + LN </li><li> After a certain thresold number of days of inactivity a chatroom is Deactivated. After Deactivation of chatroom, a new chatroom for the same contact with a different crmId can be created</li><li> After a certain thresold number of days of creation a chatroom is Expired. After Expiry of chatroom, a new chatroom for the same contact with a different crmId can be created</li><li> At any point of time only one active chatroom (not deactivated & not expired) can exist for a unique phone number</li><li> On every chatroom creation, a new contact-waba is created if not already present </li><li> Each contact can only have one waba mapping</li><li> Every contact-waba mapping is per Waba per Waba Phone, i.e any contact with same phone can one active chatroom present across multiple Waba Phone(s)</li><li> By default (fail_if_chatroom_exists_on_other_wabaphone = true), in case of an existing contact-waba mapping, we throw a Conflict upon trying to create a chatroom for the same phone number.</li><li> For fail_if_chatroom_exists_on_other_wabaphone = false, we create chatroom with same phone number with the next available Waba Phone.</li><li> This API allows chatroom handover, that is, that the agent will only be assigned to chatroom after the lead has responded</li><li> Assignment of this chatroom can be done by specifying a user or a group from which the user can be selected</li></ul>","operationId":"createChatroomV3","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateChatroomReqV3Dto"}}},"required":true},"responses":{"200":{"description":"Successfully created the chatroom","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatroomRespDto"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"User or Partner does not have access to this org","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"404":{"description":"Waba does not exist / WabaPhone does not exist / User or group does not exist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"409":{"description":"Active chatroom already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"422":{"description":"Required fields are missing or invalid values are provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Internal Exception","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}},"deprecated":true}}}}
```

## Reassign Chatroom V3

> \<ul>\<li> Roles Allowed: ADMIN \</li>\<li> Impersonated User Allowed: False \</li>\<li> Partner Allowed: True \</li>\<li> This API works only for chatrooms created for waba. Hence explicitly added /waba in the API endpoint \</li>\<li> API will revoke access of all the existing users from the chatroom and add new users to the chatroom \</li>\<li> Depending on the room history visibility flag while creating the chatroom the new users may or may not see messages from the past \</li>\<li> This API allows chatroom handover, that is, that the agent will only be assigned to chatroom after the lead has responded\</li>\<li> Reassignment of this chatroom can be done by specifying a user or a group from which the user can be selected\</li>\</ul>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]},{}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"ChatroomReassignReqV3Dto":{"required":["assign_details"],"type":"object","properties":{"assign_details":{"$ref":"#/components/schemas/ChatroomAssignmentDetailsDto"}}},"ChatroomAssignmentDetailsDto":{"required":["assign_mode"],"type":"object","properties":{"assign_mode":{"type":"string","enum":["USER","GROUP","DELEGATE"]},"user_id":{"type":"string","description":"User ID to assign the chatroom to. Either user_id or user_email is required when assign_mode is USER."},"user_email":{"type":"string","description":"User Email to assign the chatroom to. Either user_id or user_email is required when assign_mode is USER."},"group_id":{"type":"string","description":"Group ID to assign the chatroom to. Required when assign_mode is GROUP."},"assign_on_handover":{"type":"boolean","description":"Whether to assign the chatroom on handover","default":false}}},"ChatroomRespDto":{"type":"object","properties":{"chatroom_id":{"type":"string"},"external_ref_id":{"type":"string"},"is_existing":{"type":"boolean"},"is_deactivated":{"type":"boolean"},"is_expired":{"type":"boolean"},"expiry_ts":{"type":"string","format":"date-time"},"deactivation_ts":{"type":"string","format":"date-time"},"user_id":{"type":"string"}}},"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v3/org/{orgId}/lead/chatroom/{chatroomId}/reassign":{"post":{"tags":["reassignment-controller"],"summary":"Reassign Chatroom V3","description":"<ul><li> Roles Allowed: ADMIN </li><li> Impersonated User Allowed: False </li><li> Partner Allowed: True </li><li> This API works only for chatrooms created for waba. Hence explicitly added /waba in the API endpoint </li><li> API will revoke access of all the existing users from the chatroom and add new users to the chatroom </li><li> Depending on the room history visibility flag while creating the chatroom the new users may or may not see messages from the past </li><li> This API allows chatroom handover, that is, that the agent will only be assigned to chatroom after the lead has responded</li><li> Reassignment of this chatroom can be done by specifying a user or a group from which the user can be selected</li></ul>","operationId":"reassignChatroomV3","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"chatroomId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatroomReassignReqV3Dto"}}},"required":true},"responses":{"200":{"description":"Successfully re-assigned the chatroom","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatroomRespDto"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"User or Partner does not have access to this org","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"404":{"description":"Chatroom does not exist for this org / OrgId does not exist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"422":{"description":"Required fields are missing or invalid values are provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"429":{"description":"Rate limit exceeded. Allows 1 request per 10 seconds per chatroom","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Internal Exception","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}},"deprecated":true}}}}
```

## Create Chatroom V2

> \<ul>\<li> Roles Allowed: ADMIN \</li>\<li> Impersonated User Allowed: False \</li>\<li> Partner Allowed: True \</li>\<li> contactId is the id field in contact table \</li>\<li> API will create a chatroom or return an existing chatroom for this contact \</li>\<li> Chatroom will be created for the provided Waba and the Phone number if they are registered for this org \</li>\<li> Chatroom's display name will be display name if provided \</li>\<li> Otherwise Chatroom's display name will be contact's crm\_id + FN + LN \</li>\<li> After a certain thresold number of days of inactivity a chatroom is Deactivated. After Deactivation of chatroom, a new chatroom for the same contact with a different crmId can be created\</li>\<li> After a certain thresold number of days of creation a chatroom is Expired. After Expiry of chatroom, a new chatroom for the same contact with a different crmId can be created\</li>\<li> At any point of time only one active chatroom (not deactivated & not expired) can exist for a unique phone number\</li>\<li> On every chatroom creation, a new contact-waba is created if not already present \</li>\<li> Each contact can only have one waba mapping\</li>\<li> Every contact-waba mapping is per Waba per Waba Phone, i.e any contact with same phone can one active chatroom present across multiple Waba Phone(s)\</li>\<li> By default (fail\_if\_chatroom\_exists\_on\_other\_wabaphone = true), in case of an existing contact-waba mapping, we throw a Conflict upon trying to create a chatroom for the same phone number.\</li>\<li> For fail\_if\_chatroom\_exists\_on\_other\_wabaphone = false, we create chatroom with same phone number with the next available Waba Phone.\</li>\</ul>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]},{}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"CreateChatroomReqV2Dto":{"required":["contact_id","user_id"],"type":"object","properties":{"user_id":{"type":"string"},"display_name":{"type":"string"},"remote_waba_id":{"type":"string"},"remote_phone_id":{"type":"string"},"contact_id":{"type":"string"},"fail_if_chatroom_exists_on_other_wabaphone":{"type":"boolean"},"assign_on_handover":{"type":"boolean"}}},"ChatroomRespDto":{"type":"object","properties":{"chatroom_id":{"type":"string"},"external_ref_id":{"type":"string"},"is_existing":{"type":"boolean"},"is_deactivated":{"type":"boolean"},"is_expired":{"type":"boolean"},"expiry_ts":{"type":"string","format":"date-time"},"deactivation_ts":{"type":"string","format":"date-time"},"user_id":{"type":"string"}}},"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v2/org/{orgId}/chatroom":{"post":{"tags":["chatroom-controller"],"summary":"Create Chatroom V2","description":"<ul><li> Roles Allowed: ADMIN </li><li> Impersonated User Allowed: False </li><li> Partner Allowed: True </li><li> contactId is the id field in contact table </li><li> API will create a chatroom or return an existing chatroom for this contact </li><li> Chatroom will be created for the provided Waba and the Phone number if they are registered for this org </li><li> Chatroom's display name will be display name if provided </li><li> Otherwise Chatroom's display name will be contact's crm_id + FN + LN </li><li> After a certain thresold number of days of inactivity a chatroom is Deactivated. After Deactivation of chatroom, a new chatroom for the same contact with a different crmId can be created</li><li> After a certain thresold number of days of creation a chatroom is Expired. After Expiry of chatroom, a new chatroom for the same contact with a different crmId can be created</li><li> At any point of time only one active chatroom (not deactivated & not expired) can exist for a unique phone number</li><li> On every chatroom creation, a new contact-waba is created if not already present </li><li> Each contact can only have one waba mapping</li><li> Every contact-waba mapping is per Waba per Waba Phone, i.e any contact with same phone can one active chatroom present across multiple Waba Phone(s)</li><li> By default (fail_if_chatroom_exists_on_other_wabaphone = true), in case of an existing contact-waba mapping, we throw a Conflict upon trying to create a chatroom for the same phone number.</li><li> For fail_if_chatroom_exists_on_other_wabaphone = false, we create chatroom with same phone number with the next available Waba Phone.</li></ul>","operationId":"createChatroomV2","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateChatroomReqV2Dto"}}},"required":true},"responses":{"200":{"description":"Successfully returning the chatroom","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatroomRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"User or Partner does not have access to this org","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"404":{"description":"OrgId, UserId, Contact or WABA does not exist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"409":{"description":"Active chatroom already exists with a different crmId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"422":{"description":"Required fields are missing or invalid values are provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Internal Exception","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}},"deprecated":true}}}}
```

## Reassign Chatroom V2

> \<ul>\<li> Roles Allowed: ADMIN \</li>\<li> Impersonated User Allowed: False \</li>\<li> Partner Allowed: True \</li>\<li> This API works only for chatrooms created for waba. Hence explicitly added /waba in the API endpoint \</li>\<li> API will revoke access of all the existing users from the chatroom and add new users to the chatroom \</li>\<li> Depending on the room history visibility flag while creating the chatroom the new users may or may not see messages from the past \</li>\</ul>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]},{}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"ReassignRoomReqV2Dto":{"required":["user_id"],"type":"object","properties":{"user_id":{"type":"string"}}},"ChatroomRespDto":{"type":"object","properties":{"chatroom_id":{"type":"string"},"external_ref_id":{"type":"string"},"is_existing":{"type":"boolean"},"is_deactivated":{"type":"boolean"},"is_expired":{"type":"boolean"},"expiry_ts":{"type":"string","format":"date-time"},"deactivation_ts":{"type":"string","format":"date-time"},"user_id":{"type":"string"}}},"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v2/org/{orgId}/waba/chatroom/{chatroomId}/reassign":{"post":{"tags":["reassignment-controller"],"summary":"Reassign Chatroom V2","description":"<ul><li> Roles Allowed: ADMIN </li><li> Impersonated User Allowed: False </li><li> Partner Allowed: True </li><li> This API works only for chatrooms created for waba. Hence explicitly added /waba in the API endpoint </li><li> API will revoke access of all the existing users from the chatroom and add new users to the chatroom </li><li> Depending on the room history visibility flag while creating the chatroom the new users may or may not see messages from the past </li></ul>","operationId":"reassignChatroom","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"chatroomId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReassignRoomReqV2Dto"}}},"required":true},"responses":{"200":{"description":"Successfully reassigned the chatroom","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatroomRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"User or Partner does not have access to this org","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"404":{"description":"Chatroom does not exist for this org","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"422":{"description":"Required fields are missing or invalid values are provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"429":{"description":"Rate limit exceeded. Allows 1 request per 10 seconds per chatroom","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Internal Exception","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}},"deprecated":true}}}}
```

## Deactivate Chatroom

> \<ul>\<li> Roles Allowed: ADMIN \</li>\<li> Impersonated User Allowed: True \</li>\<li> Partner Allowed: True \</li>\</ul>\<ul>\<li> Message aren't allowed in a deactivated chatroom.\</li>\<li> After a certain threshold of inactivity based on org config a chatroom is marked deactivated \</li>\<li> A deactivated chatroom can be activated \</li>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"DeactivateChatroomReqDto":{"type":"object","properties":{"deactivation_reason":{"type":"string","enum":["LEAD_OPTED_OUT","LEAD_LIFECYCLE_THRESHOLD_EXPIRED","FORCE_DEACTIVATE"]}}},"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v1/org/{orgId}/contacts/chatroom/{chatroomId}/deactivate":{"put":{"tags":["chatroom-controller"],"summary":"Deactivate Chatroom","description":"<ul><li> Roles Allowed: ADMIN </li><li> Impersonated User Allowed: True </li><li> Partner Allowed: True </li></ul><ul><li> Message aren't allowed in a deactivated chatroom.</li><li> After a certain threshold of inactivity based on org config a chatroom is marked deactivated </li><li> A deactivated chatroom can be activated </li>","operationId":"deactivateContactChatroom","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"chatroomId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeactivateChatroomReqDto"}}}},"responses":{"202":{"description":"Successfully accepted request for deactivating contact chatroom","content":{"application/json":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"Forbidden - You don't have permission to access this resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Failed to deactivate chatroom due to some internal error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}}}}}}
```

## Activate Chatroom

> \<ul>\<li> Roles Allowed: ADMIN \</li>\<li> Impersonated User Allowed: False \</li>\<li> Partner Allowed: True \</li>\<li> A flag force\_deactivate is used with false default value \</li>\<li> By default we won't allow activation if any active chatroom already exists with the same phone number \</li>\<li> If force\_deactivate is set to true, then all existing active chatrooms for the same Waba Phone with same pn will be deactivated \</li>\</ul>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v1/org/{orgId}/contacts/chatroom/{chatroomId}/activate":{"put":{"tags":["chatroom-controller"],"summary":"Activate Chatroom","description":"<ul><li> Roles Allowed: ADMIN </li><li> Impersonated User Allowed: False </li><li> Partner Allowed: True </li><li> A flag force_deactivate is used with false default value </li><li> By default we won't allow activation if any active chatroom already exists with the same phone number </li><li> If force_deactivate is set to true, then all existing active chatrooms for the same Waba Phone with same pn will be deactivated </li></ul>","operationId":"activateContactChatroom","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"chatroomId","in":"path","required":true,"schema":{"type":"string"}},{"name":"force_deactivate","in":"query","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"202":{"description":"Successfully accepted request for re-activating contact chatroom","content":{"application/json":{"schema":{"type":"string"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"Forbidden - You don't have permission to access this resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Failed to activate chatroom due to some internal error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}}}}}}
```

## Get Chatroom by Contact

> \<ul>\<li> Roles Allowed: MEMBER \</li>\<li> Impersonated User Allowed: True \</li>\<li> Partner Allowed: True \</li>\</ul>

```json
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"https://apis.saleschat.pro"}],"security":[{"bearer-key":[]}],"components":{"securitySchemes":{"bearer-key":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"WabaChatroomRespDto":{"type":"object","properties":{"chatroom_id":{"type":"string"},"external_ref_id":{"type":"string"},"is_existing":{"type":"boolean"},"is_deactivated":{"type":"boolean"},"is_expired":{"type":"boolean"},"expiry_ts":{"type":"string","format":"date-time"},"deactivation_ts":{"type":"string","format":"date-time"},"waba":{"$ref":"#/components/schemas/WabaDto"}}},"WabaDto":{"type":"object","properties":{"remote_waba_id":{"type":"string"},"matrix_host_name":{"type":"string"},"name":{"type":"string"}}},"ErrorRespDto":{"type":"object","properties":{"error_code":{"type":"integer"},"error_message":{"type":"string"},"error_description":{"type":"string"},"payload":{"type":"object"}}}}},"paths":{"/v1/org/{orgId}/chatroom/contact/{contactId}":{"get":{"tags":["chatroom-controller"],"summary":"Get Chatroom by Contact","description":"<ul><li> Roles Allowed: MEMBER </li><li> Impersonated User Allowed: True </li><li> Partner Allowed: True </li></ul>","operationId":"getChatroomByContact","parameters":[{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}},{"name":"contactId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully fetched chatroom by contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WabaChatroomRespDto"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"401":{"description":"Unauthorized - Authentication is required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"403":{"description":"Forbidden - You don't have permission to access this resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"404":{"description":"No contact waba mapping found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"422":{"description":"Required fields are missing or invalid values are provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}},"500":{"description":"Failed to fetch chatroom due to some internal error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorRespDto"}}}}}}}}}
```


---

# 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://docs.saleschat.pro/api-documentation/chatroom.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.
