Monitor business names

Monitor for changes to a business’s name to ensure your records are accurate.

To handle changes to a business’s name, subscribe to the name.created and name.deleted events in your webhook endpoint.

1require 'json'
2
3# Sinatra
4post '/my/monitoring_webhook/url' do
5 payload = request.body.read
6 event = JSON.parse(payload)
7
8 case event.type
9 when 'name.created'
10 name_event = event['data']['object']
11 business_id = name_event['business_id']
12 puts 'Business name changed!
13 else
14 # Unexpected event type
15 status 400
16 return
17 end
18
19 status 200
20end

Use the event payload

Depending on your use case, you can use the name event directly (like storing the new name for review in your application) or use the event as a trigger to reevaluate the approval status of the business using the full business payload.

name.created.json
1{
2 "object": "name",
3 "id": "8d876707-651d-46ab-94e2-3f9062b4c0dd",
4 "name": "A new state",
5 "submitted": false,
6 "type": null,
7 "business_id": "2f30n1b4-c508-4792-9354-e59b5a9e1adf",
8 "sources": [
9 {
10 "id": "c6f763df-494d-4446-b328-9a27484b24db",
11 "type": "registration",
12 "metadata": {
13 "state": "MO",
14 "status": "inactive",
15 "file_number": "X00781734",
16 "jurisdiction": "DOMESTIC"
17 }
18 }
19 ]
20}

Use business review tasks

Reevaluate the business’s review tasks by requesting the full business payload using the GET /businesses endpoint.

For example, use the Name Review Task to evaluate whether the name still matches to the submitted business name.

1require 'net/http'
2require 'net/https'
3require 'json'
4
5def send_request
6 business_id = "<business_id>"
7 uri = URI("https://api.middesk.com/v1/businesses/#{business_id}")
8
9 # Create client
10 http = Net::HTTP.new(uri.host, uri.port)
11 http.use_ssl = true
12 http.verify_mode = OpenSSL::SSL::VERIFY_PEER
13
14 # Create Request
15 req = Net::HTTP::Get.new(uri)
16 # Add headers
17 req.add_field "Accept", "application/json"
18 # Add headers
19 req.add_field "Authorization", "Basic <api_key>"
20
21 # Fetch Request
22 res = http.request(req)
23
24 response = JSON.parse(res.body)
25 name_task = response['review']['tasks'].find { |task| task['category'] == 'name' }
26
27 if name_task['status'] == 'success'
28 puts 'Name match'
29 else
30 puts 'Name match failure'
31 end
32rescue StandardError => e
33 puts "HTTP Request failed (#{e.message})"
34end
Get a demo
Contact your account manager or contact sales to inquire about access.