Agent fields api

Hello, i tried to use both Agent Apis:

GET : /api/v2/agents/[id] and GET : /api/v2/agent_fields

but results are not matching, for example, agent_fields api returns this field:

{
    "default_field": true,
    "editable_by_admins": false,
    "editable_by_agents": true,
    "label_for_admins": "Full Name",
    "label_for_agents": "Full Name",
    "mandatory_for_admins": true,
    "mandatory_for_agents": true,
    "name": "name",
    "type": "name",
    "visible_to_agents": true
}

and when i get the agent by it’s id, i don’t see that field in the response but i get a “first_name” and “last_name” attributes wich are not listed in the agent_fields api’s response.

Am i doing something wrong or the Api docs are not updated ?

Thank you !

I think there’s a difference between both APIs.

/api/v2/agents/[id] is specifically used to consume information about the agents.

/api/v2/agent_fields is used to consume to view all the built-in and custom fields for agents in your Freshservice account.

Hi Saif,

If I look at the agent fields in Freshservice I see the following:

But when doing a GET https://ABC123.freshservice.com/api/v2/agent_fields
I get the following response:

{
    "agent_fields": [
        {
            "name": "name",
            "label_for_admins": "Full Name",
            "mandatory_for_admins": true,
            "editable_by_admins": false,
            "label_for_agents": "Full Name",
            "editable_by_agents": true,
            "mandatory_for_agents": true,
            "visible_to_agents": true,
            "type": "name",
            "default_field": true
        },
        {
            "name": "email",
            "label_for_admins": "Email",
            "mandatory_for_admins": true,
            "editable_by_admins": true,
            "label_for_agents": "Email",
            "editable_by_agents": false,
            "mandatory_for_agents": true,
            "visible_to_agents": true,
            "type": "email",
            "default_field": true
        },
        {
            "name": "job_tile",
            "label_for_admins": "Title",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Title",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "job_tile",
            "default_field": true
        },
        {
            "name": "work_phone",
            "label_for_admins": "Work Phone",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Work Phone",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "work_phone",
            "default_field": true
        },
        {
            "name": "mobile_phone",
            "label_for_admins": "Mobile Phone",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Mobile Phone",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "mobile_phone",
            "default_field": true
        },
        {
            "name": "location",
            "label_for_admins": "Location",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Location",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "location",
            "default_field": true
        },
        {
            "name": "department_ids",
            "label_for_admins": "Department",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Department",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "department_ids",
            "default_field": true
        },
        {
            "name": "reporting_manager",
            "label_for_admins": "Reporting Manager",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Reporting Manager",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "reporting_manager",
            "default_field": true
        },
        {
            "name": "address",
            "label_for_admins": "Address",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Address",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "address",
            "default_field": true
        },
        {
            "name": "groups",
            "label_for_admins": "Groups",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Groups",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "groups",
            "default_field": true
        },
        {
            "name": "role",
            "label_for_admins": "Roles",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Roles",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "role",
            "default_field": true
        },
        {
            "name": "description",
            "label_for_admins": "Background Information",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Background Information",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "description",
            "default_field": true
        },
        {
            "name": "time_zone",
            "label_for_admins": "Time Zone",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Time Zone",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "time_zone",
            "default_field": true
        },
        {
            "name": "time_format",
            "label_for_admins": "Time Format",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Time Format",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "time_format",
            "default_field": true
        },
        {
            "name": "language",
            "label_for_admins": "Language",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Language",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "language",
            "default_field": true
        },
        {
            "name": "level",
            "label_for_admins": "Label",
            "mandatory_for_admins": false,
            "editable_by_admins": true,
            "label_for_agents": "Label",
            "editable_by_agents": true,
            "mandatory_for_agents": false,
            "visible_to_agents": true,
            "type": "level",
            "default_field": true
        }
    ]
}

In the response I dont see “First name” or “Last name” as separate fields.
And also not the check box for “Can see all tickets from associated departments”

Either something is wrong, or I’m wrong :smiley:

1 Like

Thank you for your answer, but i still dont get it, docs says that:

GET: /api/v2/agent_fields: This operation allows you to view all the built-in and custom fields for agents in your Freshservice account.

GET: /api/v2/agents/[id]: This operation allows you to view information about a particular agent.

Here’s the responses i get:
for /agent_fields:

for /agents/[id]:

Some fields match, some don’t exist, and some have different attribute names.
I hope I explained the problem more, thank you !

1 Like

@MedAmineAyadi There seems to be a lot of inconsistency of our these fields are presented in the UI vs. what API returns. In my experience, items like this one would be treated as improvements and will be incorporated in the next versions. The current one is harder to change because there would already be clients consuming the API as is.

1 Like

This topic was automatically closed after 12 days. New replies are no longer allowed.