DNC API Integration

  • This endpoint allows you to scrub an array of numbers
  • API Token should be included in the Authorization header as a Bearer token.
  • Numbers params is an array. we support 1000 number/request.
  • Scrub Type is an array containing the type of scrub to perform.
  • Numbers must be cleaned 10 char per number
  • API response only returns result.
$token = "{YOUR_TOKEN_HERE}";
$response = post("https://thedncproject.org/api/v2/scrubs", $token, [
    3105551212, 3105551213, 3105551214, 3105551215, 3105551216
], [
    'dnc_mobile'
]);

/**
 * @param  string $apiUrl  API endpoint
 * @param  string $token   Your personal access token
 * @param  array  $numbers Numbers to scrub
 * @param  array  $scrubTypes Scrub types to run
 * @return array|null
 */
function post(string $apiUrl, string $token, array $numbers, array $scrubTypes) {
    $authorization = "Authorization: Bearer {$token}";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [ $authorization ]);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    
    // Remember to wrap your numbers and scrub_type inside their respective variables.
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
        'numbers' => $numbers,
        'scrub_type' => $scrubTypes
    ]));

    $result = curl_exec($ch);
    curl_close($ch);

    return json_decode($result);
}
                
{#2644
  +"result": array:5 [
    0 => {#2652
      +"number": "3105551212"
      +"is_dnc": true
      +"is_mobile": true
      +"state_co": true
      +"state_fl": true
      +"state_tx": true
    }
    ...
    4 => {#2649
      +"number": "3105551216"
      +"is_dnc": true
      +"state_co": true
      +"state_fl": true
      +"state_tx": true
    }
  ]
}
                    
// You can submit multiple numbers. 
// api is limited to 60 request/min
axios.post("https://thedncproject.org/api/v2/scrubs", {
    numbers: [
        '3105551212',
        '3105551213', 
        '3105551214', 
        '3105551215', 
        '3105551216', 
    ],
    scrub_type: [
        'dnc_mobile'
    ]
}, {
    headers: { 
        Authorization: `Bearer ${token}`
    }
})
.then(response => {
    // success response
}).catch(error => {
    // error response
})
                
{#2644
  +"result": array:5 [
    0 => {#2652
      +"number": "3105551212"
      +"is_dnc": true
      +"is_mobile": true
      +"state_co": true
      +"state_fl": true
      +"state_tx": true
    }
    ...
    4 => {#2649
      +"number": "3105551216"
      +"is_dnc": true
      +"state_co": true
      +"state_fl": true
      +"state_tx": true
    }
  ]
}