API to create or update requester(s) in Service Desk

By vignesh ravichandran 6222 views
API Endpoint {account_url}/api/v2/public/requesters/
Method POST
Request Data

create or update requester(s)

 

Create or Update Requester

Bulk Create or Update Requester

Parameters

Parameter Required Description
email *Yes Email address of the requester
name *Yes Name of the requester
phones *Yes List of phone numbers of the requester
custom_fields     No  Custom fields of the requester
skip_mandatory_requester_custom_fields_check No Skip mandatory check for requester cfs. Defaults to false

 

Note:

Case 1: If email is present

Case 2: If email is not present

Criteria to decide whether a requester already exists or not:

  1. If email is present, we will check if a requester with the same email exists.
  2. If email is not present, we will check if a requester with the same name and primary phone number exists.
  3. If more than one requester with the same name and phone number exists, we will return an error.
  4. If skip_mandatory_requester_custom_fields_check is not passed or passed as false, we will check if all the mandatory custom fields are present in the payload. If any mandatory custom field is missing, we will return an error.

Authorization

Basic Auth

Authorization: Basic <auth_token>

Sample Request for single create or update Requester

{
    "email": "[email protected]",
    "name": "Lisa Taylor",
    "custom_fields": {
        "1": "Test", // Text type custom field
        "2": 1, // Dropdown type custom field. Value is id of the option.
        "3": [1, 2], // Multi select type custom field. Value is list of ids of the options.
        "4": "2021-05-08", // Date type custom field. Value is in yyyy-mm-dd.
        "5": 100 // Number type custom field
    }
}

{
    "name": "Lisa Taylor",
    "phones": [
        {
            "type": "main",
            "number": "7887679890",
            "is_primary": true
        },
        {
            "type": "mobile",
            "number": "5213456745"
        }
    ],
    "custom_fields": {
        "1": "Sample", // Text type custom field
        "2": 1, // Dropdown type custom field. Value is id of the option.
        "3": [1, 2], // Multi select type custom field. Value is list of ids of the options.
        "4": "2021-05-08", // Date type custom field. Value is in yyyy-mm-dd.
        "5": 100 // Number type custom field
    }
}

 

Sample Response

Success Response: Status code 200

{
    "id": 17,
    "name": "Lisa Taylor",
    "email": "[email protected]",
    "phones": [
        {
            "id": 2,
            "type": "main",
            "number": "823548723"
        }
    ],
    "primary_phone": {
        "id": 2,
        "type": "main",
        "number": "823548723"
    }, 
    "custom_fields": [
        {
            "id": 8,
            "name": "Department",
            "type": "d",
            "value": 1
        }
    ],
    "created_at": "2024-01-10T13:05:05Z",
    "updated_at": "2024-01-10T13:05:05Z",
}

 

Error Response for Invalid Data

Error Response: Status code 422

{
    "non_field_errors": [
        "Email or phones is required"
    ]
}
{
    "field": "name",
    "message": "Name is required when only phones is passed in the request payload."
}

 

Sample Request for bulk create or update Requester(s)

[
    {
        "email": "[email protected]",
        "name": "Lisa Taylor",
        "custom_fields": {
            "1": "Sample", // Text type custom field
            "2": 1, // Dropdown type custom field. Value is id of the option.
            "3": [1, 2], // Multi select type custom field. Value is list of ids of the options.
            "4": "2021-05-08", // Date type custom field. Value is in yyyy-mm-dd.
            "5": 100 // Number type custom field
        }
    },
    {
        "name": "Lisa Taylor",
        "phones": [
            {
                "type": "main",
                "number": "3414567890",
                "is_primary": true
            },
            {
                "type": "mobile",
                "number": "9234567345"
            }
        ],
        "custom_fields": {
            "1": "Sample", // Text type custom field
            "2": 1, // Dropdown type custom field. Value is id of the option.
            "3": [1, 2], // Multi select type custom field. Value is list of ids of the options.
            "4": "2021-05-08", // Date type custom field. Value is in yyyy-mm-dd.
            "5": 100 // Number type custom field
        } 
    }
]

 

Sample Response for bulk create or update Requester(s)

Success Response: Status code 200

[
    {
        "id": 31,
        "success": true,
        "name": "Lisa Taylor",
        "email": "[email protected]"
    },
    {
        "id": 32,
        "success": true,
        "name": "Lisa Taylor",
        "primary_phone": {
            "id": 42,
            "type": "main",
            "number": "1234567876"
        }
    }
]

 

Error Response for Invalid Data

Error Response: Status code 422

[
    {
        "errors": {
            "field": "name",
            "message": "Name is required when only phones is passed in the request payload."
        },
        "success": false
    },
    {
        "errors": {
            "non_field_errors": [
                "Email or phones is required"
            ]
        },
        "success": false,
        "name": "Test 1"
    }
]