Beam Help
Get help now

How-to · Zoho DESK

How to retrieve a profile in Zoho Desk

Fetch detailed information about a specific user profile.

Retrieving a profile in Zoho Desk requires a valid OAuth connection, a resolved organisation ID, and a correctly initialised API client — get any one of those wrong and the call will silently fail or return a 401.


Why this matters


When you need to pull agent, contact, or account profile data from Zoho Desk — whether for a support workflow, an automation, or a reporting dashboard — the retrieval chain must be set up in the right order. Missing or stale credentials, or an undiscovered org_id, are the two most common reasons profile lookups return nothing. As independent expert support for Zoho (not official Zoho support), Beam Help walks you through the full sequence below.


---


Step-by-step


Step 1. Confirm the user has an active Zoho connection.


Before any Desk API call can succeed, the system must locate a stored connection record for the user. The connection is fetched from the zohoconnections table using the userid. If no record exists, the entire retrieval chain returns None and nothing further can proceed. [7]


Step 2. Refresh the access token if it is close to expiry.


The connection layer checks whether the current time is within 120 seconds of tokenexpiresat. If so, it calls ZohoOAuth.refreshtokens() with the stored refreshtoken, writes the new access_token and updated expiry back to the database, and continues with the refreshed credentials. This prevents mid-request 401 errors during profile retrieval. [7]


Step 3. Initialise the Zoho Desk client with app_type = "desk".


Pass "desk" as the apptype when calling getzohoapi. This branches the logic to create a ZohoDeskClient — rather than a CRM client — using the stored apidomain, accesstoken, and orgid. A ZohoDeskApi instance is then built on top of that client. [1]


Step 4. Auto-discover the organisation ID if it is not already stored.


If deskorgid is blank in the connection record, the system calls api.getallorganizations() automatically. It inspects the returned payload — checking both a data list and a bare list format — extracts the first organisation's id, and persists it back to zohoconnections under the deskorg_id column. The live client is also updated immediately so the current request can continue without a restart. [1][6]


Step 5. Resolve the portal/subdomain if needed.


In parallel with the org ID, the system may also need to discover the Desk portal identifier. It checks fields such as urlName, subDomain, portalName, and id from the help-centre response, stores the first non-empty value as desk_portal, and updates the connection record. [5]


Step 6. Call the profile endpoint with the resolved API instance.


Once the ZohoDeskApi instance is fully initialised and the org_id is confirmed, you can invoke the relevant method for the profile type you need — agent, contact, or account. The Desk assistant prompt recognises these as key entities: tickets, contacts, accounts, agents, departments, teams, and articles. [3]


Step 7. Format and display the returned profile data.


When the API returns results, present the key fields in a readable structure: Name, Email, Status, Subject, and Owner/Agent on separate lines, followed by any other relevant fields. Skip empty values and internal IDs to keep the output clean. [3]


---


Common pitfalls


  • Missing orgid causes silent failures. If auto-discovery cannot reach the organisations endpoint (for example, due to a network timeout or insufficient OAuth scope), orgid remains an empty string and subsequent profile calls will be rejected by the Desk API. Always verify the value is stored after the first successful connection. [1][6]

  • Token refresh failures block everything. If refreshtokens() returns a response that does not contain accesstoken, the refresher function returns None and the client is initialised with a stale token. The test runner explicitly checks for an "error" key in the refresh response and aborts early — replicate this check in any custom integration. [8]

  • Data-centre mismatch on user info calls. The user-info endpoint is constructed using a configurable ZOHODC value (e.g. com, eu, in). If this is set incorrectly, the OAuth user-info fetch will fail and fields like ZUID, Email, and orgid will not resolve. Field names also vary by data centre, so the code tries multiple alternatives (orgid, organizationid, ZGID) before falling back. [4]

  • deskorgid vs deskportal confusion. These are two distinct stored values. The orgid is a numeric identifier required in API request headers, while desk_portal is the subdomain/URL name used for building browser links. Mixing them up will cause either API calls or UI links to break. [5][6]

---


What to check


  • Verify deskorgid is populated in the zoho_connections record after the first Desk API call; if it is still empty, re-trigger the organisations discovery step manually. [6]
  • Confirm the access token is valid and not expired by checking tokenexpiresat against the current timestamp — the system refreshes automatically only if the skew threshold is met. [7]
  • Ensure the OAuth scopes granted include Desk profile read permissions; an insufficient scope will cause the organisations or profile endpoint to return an authorisation error even when the token itself is fresh. [4]

Sources cited

  1. [1] server.py: get_zoho_api
  2. [2] server.py: build_zoho_links
  3. [3] planner.py
  4. [4] zoho_oauth.py
  5. [5] server.py: get_zoho_connection
  6. [6] desk_test_runner.py
Retrieve Profile Details | Beam Help