This knowledge base articles consists of detailed steps and examples for Asset management via HappyFox API on your account.
You will need an auth key and auth code.
4. Specifying custom field values in request data
7. Read all asset custom fields
8. Read asset custom field by id
The URL section shown, is to be appended to your HappyFox account url.
Eg. If acmes is your HappyFox account name, the account url is https://acmes.happyfox.com/
If you are using a custom domain, please use the appropriate custom domain url
URL |
/api/1.1/json/assets/?size=<page_size>&page=<page_number> |
HTTP Method |
GET |
Response data |
List of assets |
Request Query Parameters
Parameter |
Required |
Description |
size |
no |
number of assets info to be returned per page Default - 10 Maximum allowed per page - 50 |
page |
no |
page number |
Example Response (status code - 200)
{
"page_info": {
"count": 10,
"last_index": 12,
"page_count": 2,
"start_index": 1,
"end_index": 10
},
"data": [
{
"display_id": "mac_pro",
"name": "Macbook Pro",
"id": 1,
"contacts": [],
"custom_fields": [
{
"id": 1,
"name": "Asset Category",
"type": "dropdown",
"value": 1,
"order": 1
},
{
"id": 2,
"name": "Description",
"type": "textarea",
"value": null,
"order": 2
}
]
},
{
"display_id": "mac_1pro",
"name": "Macbook Pro",
"id": 2,
"contacts": [],
"custom_fields": [
{
"id": 1,
"name": "Asset Category",
"type": "dropdown",
"value": 1,
"order": 1
},
{
"id": 2,
"name": "Description",
"type": "textarea",
"value": null,
"order": 2
}
]
}
]
}
URL |
/api/1.1/json/asset/<id>/ |
HTTP Method |
GET |
Response data |
Asset |
Example Response (status code - 200)
{
"display_id": "mac_pro",
"name": "Macbook Pro",
"id": 1,
"contacts": [
{
"email": "john@example.com",
"id": 2,
"name": "John"
}
],
"custom_fields": [
{
"id": 1,
"name": "Asset Category",
"type": "dropdown",
"value": 1,
"order": 1
},
{
"id": 2,
"name": "Description",
"type": "textarea",
"value": null,
"order": 2
}
]
}
3. Create asset
URL |
/api/1.1/json/assets/ |
HTTP Method |
POST |
Response data |
Asset |
Requirements
Only an active agent who has Manage Assets permission enabled, can create an asset.
Request Data Fields
Field |
Type |
Required |
Description |
name |
string |
yes |
Name of the asset |
display_id |
string |
yes |
Display ID of the asset |
contact_ids |
list |
no |
List of ids of existing contacts to link with the asset. Refer the api documentation for the list contacts api. |
contacts |
list |
no |
List of JSON containing details of new contacts to be created during asset creation
For an agent to create contacts when creating or updating an asset, the agent should have Manage all Contacts permission |
custom_fields |
JSON |
no |
JSON of custom fields to be set for the asset |
created_by |
int |
yes |
Id of agent who is making the request. Refer the api documentation for the list agents api |
4. Specifying custom field values in request data
Custom field type |
Value format |
Example |
Text |
string |
“Lorem ipsum” |
Textarea |
string |
“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor” |
Number |
number |
123 |
Dropdown |
option id |
1 |
Multiple option |
List of option ids |
[1,2,3] |
Date |
yyyy-mm-dd |
2019-11-11 |
Example Request
{
"name": "Macbook pro",
"display_id": "macbook_pro",
"contact_ids": ["1"],
"contacts": [
{"email": "donald@example.com"}
],
"created_by": 1,
"custom_fields": {
"1": "1",
"2": "text",
"3": "textraea\n textarea",
"4": "55555", // number custom field
"5": 4, // dropdown custom field
"6": [3, 4], //multiple option custom field
"7": 2019-11-15 // date custom field
}
}
Example Successful Response (status code - 200)
{
"id": 13,
"name": "Macbook Pro",
"display_id": "mac_d11pro",
"created_by": 1,
"created_at": "2019-11-15T07:49:40Z",
"updated_by": null,
"updated_at": "2019-11-15T07:49:40Z",
"contacts": [
{
"email": "john@example.com",
"id": 1,
"name": "John"
},
{
"email": "donald@example.com",
"id": 2,
"name": "Donald"
}
],
"custom_fields": [
{
"id": 1,
"name": "Asset Category",
"type": "dropdown",
"value": 1,
"order": 1
},
{
"id": 2,
"name": "Description",
"type": "textarea",
"value": null,
"order": 2
}
]
}
Example failure response in case of validation errors (status code - 400)
{
"error": {
"display_id": [
"This field is required."
],
"contact_ids": "Enter a list of values.",
"custom_fields": {
"1": "Provide a valid choice. 5 is not one of the available choices."
}
}
}
5. Update asset
URL |
/api/1.1/json/asset/<id> |
HTTP Method |
PUT |
Response data |
Asset |
Requirements
Only an active agent who has Manage Assets permission enabled, can update an asset.
Request data fields
Field |
Type |
Required |
Description |
name |
string |
no |
Name of the asset |
display_id |
string |
no |
Display id of the asset |
contact_ids |
list |
no |
List of ids of existing contacts to link with the asset. Refer the api documentation for the list contacts api. |
contacts |
list |
no |
List of json containing details of new contacts to be created during asset creation
For an agent to create contacts when creating or updating an asset, the agent should have Manage all Contacts permission |
custom_fields |
json |
no |
Json of custom fields to be set for the asset |
updated_by |
int |
yes |
Id of agent who is making the request. Refer the api documentation for the list agents api |
Example Request
{
"name": "Macbook pro 2019 15' inch Retina",
"updated_by": 1,
"contact_ids": [2]
}
Example Successful Response (status code - 200)
{
"id": 2,
"name": "Macbook pro 2019 15' inch Retina",
"display_id": "mac_1pro",
"created_by": 1,
"created_at": "2019-11-15T06:43:51Z",
"updated_by": 1,
"updated_at": "2019-11-15T08:00:14Z",
"contacts": [
{
"email": "john@example.com",
"id": 2,
"name": "John"
}
],
"custom_fields": [
{
"id": 1,
"name": "Asset Category",
"type": "dropdown",
"value": 1,
"order": 1
},
{
"id": 2,
"name": "Description",
"type": "textarea",
"value": null,
"order": 2
}
]
}
6. Delete asset
URL |
/api/1.1/json/asset/<id>/ |
HTTP Method |
Delete |
Response |
Successful request will give a 204 response code |
Requirements
Only an active agent who has Manage Assets permission enabled, can delete an asset.
Request Query Parameters:
Parameter |
Required |
Description |
deleted_by |
Yes |
ID of the agent/staff that is making the request |
7. Read all asset custom fields
URL |
/api/1.1/json/asset_custom_fields/?size=<page_size>&page=<page_no> |
HTTP Method |
GET |
Response |
List of asset custom field |
Request Query Parameters
Parameter |
Required |
Description |
size |
no |
number of asset info per page Default - 10 Maximum limit per page - 50 |
page |
no |
page number |
Example Response (status code - 200)
{
"page_info": {
"count": 5,
"last_index": 5,
"page_count": 1,
"start_index": 1,
"end_index": 5
},
"data": [
{
"id": 1,
"type": "dropdown",
"name": "Asset Category",
"choices": [
{
"text": "Hardware",
"id": "1"
},
{
"text": "Others",
"id": "3"
},
{
"text": "Software",
"id": "2"
}
]
},
{
"id": 2,
"type": "textarea",
"name": "Description",
"choices": null
},
{
"id": 3,
"type": "number",
"name": "age",
"choices": null
},
{
"id": 4,
"type": "date",
"name": "Date of purchase",
"choices": null
},
{
"id": 5,
"type": "multiple_option",
"name": "Multiple Choice Example",
"choices": [
{
"text": "chat",
"id": "1"
},
{
"text": "workflows",
"id": "2"
},
{
"text": "helpdesk",
"id": "3"
}
]
}
]
}
8. Read one asset custom field by id
URL |
/api/1.1/json/asset_custom_fields/<id> |
HTTP Method |
GET |
Response data |
Asset custom field |
Example Response (status code - 200)
{
"type": "dropdown",
"id": 1,
"choices": [
{
"text": "Hardware",
"id": "1"
},
{
"text": "Others",
"id": "3"
},
{
"text": "Software",
"id": "2"
}
],
"name": "Asset Category"
}