Sonar API - Get account ID via IP address


#1

Is there a way in the v1 API to search for customer id using just an assigned IP address.

I’m sure this is possible using the search functions but we haven’t had any luck finding the secret sauce yet. Any help would be greatly appreciated.

Please note: wait for v2 is not an appropriate answer.


#2

Use the search endpoint to search ip_assignments

https://sonar.software/apidoc/#api-Search-Search


#3

Didn’t you say in a previous message that the v1 search endpoint is going away (will be broken) when v2 comes out? I recall reading something about that.


#4

ughh. probably, - v1 limbo problems.
As for the v1 search: Sounds easy enough… but it isn’t.
https://swift.sonar.software/api/v1/search/accounts
Json: tried ‘ip’ ‘address’ ‘subnet’ thoughts? there really isn’t any example usage.

{
"search": {
	"fields": {
		"ip":"10.30.6.90"
	}
},
"size":100,
"page":1
}

Doesn’t work, something simple like this:

{
"search": "10.30.6.90"
},
"size":100,
"page":1
}

Doesn’t work. like I said above - I just can’t seem to find the secret sauce… any help would be greatly appreciated.
Both have 0 results (yes its an inventoried IP assigned to an account, tried other IP’s aswell)


#5

You need to search ip_assignments. Just do a simple request to it first to see the data structure.


#6

Yes, the entire data structure has changed in v2. Every single endpoint in the API implements searching there, so we don’t need a dedicated search endpoint anymore.


#7

For the simple search I think you are using the endpoint incorrectly, I believe it should be:

{
	"size": 100,
	"page": 1,
	"search": {
		"search": "10.30.6.90"
	}
}

#8

Are the webhooks being improved in v2 along with the API?


#9

Yep - that was it - I was using the incorrect ‘entity’.

Thanks!


#10

Order doesn’t seem matter - as long as its properly formatted and you have it nested correctly.

  • ‘size’ and ‘page’ can come before or after the ‘search’ parameter

#11

Yep!