# Make a call with PHP You can quickly see how the Voice API works by calling yourself using the API. In this guide you will learn: 1. How to [create](#create-your-php-file) your PHP application. 2. How to [call](#make-your-first-call) your phone number. ## What you need to know before you start Before you can get started, you need the following already set up: * Set all Voice API [configuration settings](/docs/voice/getting-started). * [PHP 8.1](https://www.php.net/manual/en/install.php) or later and a familiarity with how to create a new file. ## Create your PHP file Create a new file named **make-call.php** and paste the provided "make-call.php" code into the file. make-call.php "ttsCallout", "ttsCallout" => [ "cli" => fromNumber, "destination" => [ "type" => "number", "endpoint" => to ], "locale" => locale, "text" => "Hello, this is a call from Sinch. Congratulations! You made your first call." ] ]; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Basic " . base64_encode(key . ":" . secret) ], CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_URL => "https://calling.api.sinch.com/calling/v1/callouts", CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => "POST", ]); $response = curl_exec($curl); $error = curl_error($curl); curl_close($curl); if ($error) { echo "cURL Error #:" . $error; } else { echo $response; } ?> Note This tutorial uses basic authentication for testing purposes. We recommend using a signed request for authentication in a production environment. You can follow the steps in this guide, but use the code samples from [here](/docs/voice/api-reference/authentication/signed-request#example-implementations-of-application-signing) to use request signing authentication instead. This code makes a POST request to the Voice API **/callouts** endpoint which then makes a call out to the `to` parameter in the body of the request. The Voice API uses [callouts](/docs/voice/api-reference/voice/callouts) to make voice calls. In this guide, we are using the `ttsCallout` or "text-to-speech callout" to call a number and then play a text-to-speech message before hanging up. ### To In this example you want to call a phone number. Change the value of the `to` parameter to the phone number you verified in your [dashboard](https://dashboard.sinch.com) in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format. Note When your account is in trial mode, you can only call your [verified numbers](https://dashboard.sinch.com/numbers/verified-numbers). If you want to call any number, you need to upgrade your account! ### Fill in your parameters Before you can run the code, you need to update some values so you can connect to your Sinch account. Update the following parameters with your own values: | Parameter | Your value | | --- | --- | | `key` | The application key found on your Sinch [dashboard](https://dashboard.sinch.com/voice/apps). | | `secret` | The application secret found on your Sinch [dashboard](https://dashboard.sinch.com/voice/apps). | | `fromNumber` | Any number you've assigned to your application. This can be a number you've purchased or your [free test number](https://community.sinch.com/t5/Virtual-Numbers/How-can-I-activate-my-free-number-for-testing/ta-p/8578). Find the number on your Sinch [dashboard](https://dashboard.sinch.com/voice/apps) by clicking on your app, navigating to the Voice and Video tab, and looking in the Inbound Numbers section. | | `locale` | The language and locale you want to use for the text-to-speech call. Locale is specified with a language code according to `ISO 639`, a dash and a country code according to `ISO 3166-1 alpha-2`. For example, American English is represented by `en-US`. | Save the file. ## Make your first call Now you can execute the code and make your text-to-speech call. Run the following command: ```shell php make-call.php ``` You should receive a phone call to the number you called with the message "Hello, this is a call from Sinch. Congratulations! You made your first call." Tip If the text-to-speech message starts playing too early for your needs, you can use [SSML](https://community.sinch.com/t5/Calling/How-do-I-add-a-pause-to-the-beginning-of-a-text-to-speech/ta-p/9918) to add a pause at the beginning of the message. Troubleshooting tip If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again. ## Next steps Now that you know how to make a call, learn how to [handle an incoming call](/docs/voice/getting-started/php/incoming-call). ## Additional resources - [API specification](/docs/voice/api-reference/voice)