Struggling with Zoho Cliq API file upload permissions? Many developers encounter the "Scope does not exist" error when attempting to upload files via the Zoho Cliq REST API. This comprehensive guide will walk you through the steps to resolve OAuth scope issues and successfully implement file upload functionality in your Zoho Cliq integrations.
The most common issue developers face is using incorrect OAuth scopes for Zoho Cliq's file upload functionality.
Scope: ZohoCliq.Webhooks.Create (✗ Insufficient permissions) Required: ZohoCliq.files.CREATE (❓ Scope validation needed) API Response: "Scope does not exist"
Zoho's OAuth scope naming conventions can be inconsistent, and documentation may not always reflect the latest API changes. The /buddies/{email}/files
endpoint requires specific permissions that aren't covered by webhook scopes.
Try these scope variations:
ZohoCliq.files.CREATE ZohoCliq.files.create ZohoCliq.Files.CREATE ZohoCliq.Files.Create ZohoCliq.file.CREATE
For authorization URL:
https://accounts.zoho.com/oauth/v2/auth?scope=ZohoCliq.files.CREATE&client_id={your_client_id}&response_type=code&redirect_uri={your_redirect_uri}&access_type=offline&prompt=consent
For token exchange:
curl -X POST "https://accounts.zoho.com/oauth/v2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=authorization_code" \ -d "client_id={your_client_id}" \ -d "client_secret={your_client_secret}" \ -d "redirect_uri={your_redirect_uri}" \ -d "code={authorization_code}"
curl -X POST "https://cliq.zoho.com/api/v2/buddies/{email}/files" \ -H "Authorization: Zoho-oauthtoken {access_token}" \ -H "Content-Type: multipart/form-data" \ -F "file=@/path/to/your/file.pdf"
If individual file scopes don't work, request broader Cliq permissions:
ZohoCliq.full_access ZohoCliq.messages.CREATE,ZohoCliq.files.CREATE,ZohoCliq.channels.CREATE
Implementation:
https://accounts.zoho.com/oauth/v2/auth?scope=ZohoCliq.full_access&client_id={your_client_id}&response_type=code&redirect_uri={your_redirect_uri}&access_type=offline
Use Cliq's message API with attachments:
const shareFileViaMessage = async (chatId, filePath, accessToken) => { const formData = new FormData(); formData.append('text', 'File shared via API'); formData.append('attachments', fs.createReadStream(filePath)); const response = await fetch(`https://cliq.zoho.com/api/v2/chats/${chatId}/messages`, { method: 'POST', headers: { 'Authorization': `Zoho-oauthtoken ${accessToken}` }, body: formData }); return response.json(); };
Required Scope: ZohoCliq.messages.CREATE
or ZohoCliq.Webhooks.Create
{ "name": "FileUploadBot", "permissions": ["files.upload", "messages.send"], "webhook_url": "https://your-server.com/webhook" }
curl -X POST "https://cliq.zoho.com/api/v2/bots/{bot_id}/message" \ -H "Authorization: Zoho-oauthtoken {access_token}" \ -H "Content-Type: application/json" \ -d '{ "text": "File uploaded successfully", "attachments": [{"file_url": "your_file_url"}] }'
Ensure you're using the correct regional endpoint:
const getCliqApiBase = (region) => { const endpoints = { 'US': 'https://cliq.zoho.com/api/v2/', 'EU': 'https://cliq.zoho.eu/api/v2/', 'IN': 'https://cliq.zoho.in/api/v2/', 'AU': 'https://cliq.zoho.com.au/api/v2/', 'JP': 'https://cliq.zoho.jp/api/v2/' }; return endpoints[region] || endpoints['US']; };
curl -X GET "https://cliq.zoho.com/api/v2/users/me" \ -H "Authorization: Zoho-oauthtoken {access_token}"
curl -X GET "https://cliq.zoho.com/api/v2/buddies" \ -H "Authorization: Zoho-oauthtoken {access_token}"
const refreshToken = async (refreshToken, clientId, clientSecret) => { const response = await fetch('https://accounts.zoho.com/oauth/v2/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ 'grant_type': 'refresh_token', 'refresh_token': refreshToken, 'client_id': clientId, 'client_secret': clientSecret }) }); return response.json(); };
const handleCliqApiError = (error, response) => { if (response.status === 401) { return 'REFRESH_TOKEN_REQUIRED'; } else if (response.status === 403) { return 'SCOPE_INSUFFICIENT'; } else if (response.status === 404) { return 'ENDPOINT_INVALID'; } return 'UNKNOWN_ERROR'; };
const rateLimitedRequest = async (url, options, maxRetries = 3) => { for (let i = 0; i < maxRetries; i++) { const response = await fetch(url, options); if (response.status === 429) { const retryAfter = response.headers.get('Retry-After') || 60; await new Promise(resolve => setTimeout(resolve, retryAfter * 1000)); continue; } return response; } throw new Error('Max retries exceeded'); };
const validateFile = (file) => { const maxSize = 25 * 1024 * 1024; const allowedTypes = [ 'image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'text/plain', 'application/msword', 'application/vnd.ms-excel' ]; if (file.size > maxSize) { throw new Error('File size exceeds 25MB limit'); } if (!allowedTypes.includes(file.type)) { throw new Error('File type not supported'); } return true; };
Ready to implement robust file sharing in your applications? Start your Zoho Cliq integration journey and explore the full potential of team collaboration APIs.
For comprehensive team communication solutions, consider Zoho Workplace which includes Cliq along with other productivity tools.
Struggling with complex Zoho integrations? Our team at Creator Scripts specializes in Zoho API implementations and can help you build robust, scalable solutions.