Get Optout

Estimated reading: 2 minutes 542 views

Base URL

https://cellcast.com.au/api/v3/get-optout

Method: GET

Parameters

Header ParametersDescription
APPKEYPlease add provided APPKEY – linked to your Cellcast account.
Content-Typeapplication/json

How do I activate the opt-out list via API?

– Select ‘Settings’ on the left menu, then select ‘Inbound SMS settings’.

– Select ‘Active’ from ‘Opt-out for API’ dropdown.

Successful Responses

CodeStatusDescription
200SUCCESSYou have <<Total>> optout contact(s)

Successful Responses look like

				
					{
    "meta": {
        "code": 200,
        "status": "SUCCESS"
    },
    "msg": "You have 1 optout contact(s)",
    "data": {
        "page": {
            "count": 1,
            "number": 1
        },
        "total": "3",
        "responses": [
            {
                "number": "+61NNNNNNNNN",
                "first_name": "Peter",
                "last_name": "berg",
                "gender": "Male",
                "post_code": "6688",
                "dob": "2010-11-12",
                "created_at": null
            }
        ]
    }
}
				
			

Error Response

StatusCodeDescription
AUTH_FAILED400You are not a registered user

Error Responses look like

				
					{
    "meta": {
        "code": 401,
        "status": "AUTH_FAILED"
    },
    "msg": "APPKEY you have provided is invalid",
    "data": []
}
				
			

PHP Code Example

You can call following function to get SMS responses.

				
					function getOptoutList() {
    try {
        $url = 'https://cellcast.com.au/api/v3/get-optout'; //API URL

        $headers = array(
            'APPKEY: <<APPKEY>>',
            'Accept: application/json',
            'Content-Type: application/json',
        );

        $ch = curl_init(); //open connection
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 4);
        if (!$result = curl_exec($ch)) {
            $response_error = json_decode(curl_error($ch));
            return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again", "result" => $response_error));
        }
        curl_close($ch);
        return json_encode(array("status" => 200, "msg" => "Successfully set status", "result" => json_decode($result)));
    } catch (\Exception $e) {
        return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again.", "result" => array()));
    }
}
                                
				
			

Call Function

				
					//Call function to get opt out list function
$response_status = getOptoutList();