Swif allows you to manage custom device metadata—called extension attributes—using a powerful webhook API. This guide will show you how to set, update, and delete extension attributes for your devices programmatically.
Prerequisites
API Key: You’ll need your Swif API key. Find instructions here: How to get your API key
Base URL: Replace
{{base_url}}withhttps://api.swifteam.com.
API Endpoints
1. Retrieve Extension Attributes
GET
{{base_url}}/restful/organization/deviceExtensionAttributes?ids=<device_id>&offset=0&limit=10Example:
GET {{base_url}}/restful/organization/deviceExtensionAttributes?ids=69114f7534000025006e720e&offset=0&limit=102. Set or Update Extension Attributes
POST
{{base_url}}/restful/organization/deviceExtensionAttributes?ids=<device_id>Body Example:
{
"items": [
{
"deviceId": "69114f7534000025006e720e",
"attributes": [
{
"key": "owner",
"value": "alice@example.com"
},
{
"key": "disk_size_gb",
"value": "512"
}
]
}
]
}To update an attribute: Provide the key and a non-empty value.
To delete an attribute: Provide the key with an empty string or
nullas the value (see below for behavior).
3. Delete Extension Attributes
DELETE
{{base_url}}/restful/organization/deviceExtensionAttributesBody Example:
{
"deviceIds": [
"69114f7534000025006e720e"
],
"keys": [
"owner",
"assetTag"
]
}Behavior and Test Scenarios
The webhook API is designed to be robust and intuitive. Here’s how it behaves in common scenarios:
Scenario | What Happens? |
Set Attribute | Sending a non-empty value sets or updates the attribute for the device. |
Delete Attribute (Empty/Null Value) | Sending an empty string or |
No Attribute Present, Empty/Null Value | If the attribute does not exist and you send an empty/null value, nothing happens—no attribute is created. |
Bulk Ingestion (Mixed Values) | For each device/attribute: non-empty values are set/updated; empty/null values are deleted. |
All Empty/Null | All specified attributes are deleted for the listed devices. |
All Non-Empty | All specified attributes are set/updated for the listed devices. |
Unknown Key | If you send a key not present in your schema, it is ignored or rejected. You’ll receive an error: |
Invalid Value Type |
|
Explicit Removal | You can remove an attribute by sending an empty string, |
Example: Setting and Deleting Attributes
Set or Update:
curl --location 'https://api.swifteam.com/restful/organization/deviceExtensionAttributes?ids=69114f7534000025006e720e' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxx' \
--data-raw '{
"items": [
{
"deviceId": "69114f7534000025006e720e",
"attributes": [
{
"key": "owner",
"value": "alice@example.com"
},
{
"key": "disk_size_gb",
"value": "512"
}
]
}
]
}'
Delete (by empty value):
curl --location 'https://api.swifteam.com/restful/organization/deviceExtensionAttributes?ids=69114f7534000025006e720e' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxx' \
--data-raw '{
"items": [
{
"deviceId": "69114f7534000025006e720e",
"attributes": [
{ "key": "owner", "value": "" }
]
}
]
}'
Delete (by DELETE endpoint):
curl --location --request DELETE 'https://api.swifteam.com/restful/organization/deviceExtensionAttributes' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxx' \
--data '{
"deviceIds": [
"69114f7534000025006e720e"
],
"keys": [
"owner",
"assetTag"
]
}'
Tips
Always check your attribute schema for valid keys and value types.
Use the GET endpoint to verify changes after webhook calls.
For bulk operations, you can include multiple devices and attributes in a single request.
More Information
By following this guide, you can efficiently automate the management of device extension attributes in Swif using webhooks. If you encounter errors, refer to the error messages for troubleshooting or reach out to support.
