Create a Slack channel
This endpoint will let you create a new Slack channel, link it to a WhatsApp group, and add a user for bidirectional message synchronization.
Path Parameters
Field | Description | Required |
---|---|---|
slack_channel_name | Name of the Slack channel to create. Must contain only lowercase letters, numbers, hyphens, and underscores. Maximum length: 80 characters | Yes |
group_uuid_to_assign | UUID of the WhatsApp group to link with the Slack channel | Yes |
user_email_to_assign | Email of the user to add to the Slack channel | Yes |
Invocation
- cURL
- Python
- NodeJS
curl --location --request POST 'https://api.p.2chat.io/open/slack/create-channel/my-channel/assign-to-group-uuid/WAG123456789/user-email-to-assign/user@example.com' \
--header 'X-User-API-Key: your_api_key_here'
import requests
import json
url = "https://api.p.2chat.io/open/slack/create-channel/my-channel/assign-to-group-uuid/WAG123456789/user-email-to-assign/user@example.com"
headers = {
'X-User-API-Key': 'your_api_key_here'
}
response = requests.request("POST", url, headers=headers)
print(response.text)
var axios = require('axios');
var config = {
method: 'post',
url: 'https://api.p.2chat.io/open/slack/create-channel/my-channel/assign-to-group-uuid/WAG123456789/user-email-to-assign/user@example.com',
headers: {
'X-User-API-Key': 'your_api_key_here'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Response
The API will respond with the channel details if the invocation succeeded.
{
"success": true,
"data": {
"slack_channel_id": "C0123ABC456",
"slack_channel_name": "my-channel",
"whatsapp_group_uuid": "WAG123456789",
"user_linked_to_channel": "user@example.com"
}
}
Error Responses
Status Code | Description |
---|---|
400 | Params missing. Received group_uuid_to_assign=[null] |
400 | slack_channel_name can't contain special characters. Received slack_channel_name=[invalid-name] |
400 | slack_channel_name can't be longer than 80 characters. Received slack_channel_name=[too-long-name] |
400 | Channel is already assign to another channel [existing-channel]. Received group_uuid_to_assign=[group-uuid] |
400 | Slack configuration is disabled. Reason: [reason] |
400 | Error creating the channel. Received response=[error] |
404 | Account is None. Please connect your account with Slack |
404 | Group not found. Received group_uuid_to_assign=[group-uuid] |
404 | Slack configuration not found. Please connect your account with Slack |
500 | Something went wrong, please try again |
Notes
- The Slack channel name must follow Slack's naming conventions (lowercase letters, numbers, hyphens, and underscores only)
- The WhatsApp group must exist and be accessible to your account
- The user email must be a valid email address and must be on Your Workspace
- Your account must have Slack integration properly configured and enabled
- The WhatsApp group must not be already linked to another Slack channel