Making and Receiving Phone Calls (Compatibility XML)
Updated
---title: Making and Receiving Phone Calls (Compatibility XML)sidebar_label: Making and Receiving Phone Callsslug: /guides/voice/making-and-receiving-phone-callssidebar_position: 0x-custom: author: danieleds---# Making and Receiving Phone CallsIn this guide we are going to show how to make and receive phone calls using REST APIs and XML Bins.## PrerequisitesTo be able to make calls, you will need:- a SignalWire phone number- your API credentials (Space URL, Project ID, and API token)To acquire a phone number, [Log in](https://signalwire.com/signin) to your SignalWire Space. From the Phone Numbers section, you can [buy a new phone number](guides/numbers-api/getting-started/buying-a-phone-number/index.mdx). You will need at least one number to make and receive calls.For what concerns your API credentials, find these in the API section of your space, as shown in the following figure. You may need to create a new token if you never used one. Make sure that your token has the Voice scope enabled. You can find your Project ID and Token from the API tab in your SignalWire Space. Make sure your token has the Voice scope enabled. :::info Trial ModeIf your account is in [trial mode](guides/administration/guides/signalwire-space/trial-mode.mdx), you need to upgrade itin order to call numbers other than your own verified numbers. See [How to exit Trial Mode](guides/administration/guides/signalwire-space/trial-mode.mdx).:::## Making your first callYou now have all you need to make your first call, for example to your personal phone number.We want to call a number and play an audio message which says Welcome toSignalWire. This is my first call. We are going to define this behavior in anXML bin, which is used to declare what should happen during a call.To create an XML bin, go to the LaML section in your [SignalWire space](https://signalwire.com/signin), then click on Bins. To create a new XML bin, click the blue button in the LaML section of your SignalWire space. Create a new bin, and paste the following XML in it:xmlWelcome to SignalWire. This is my first call.The XML above uses the [<Say>](pathname:///compatibility-api/xml/voice/say)verb to play a text-to-speech message. Save the bin and take note of its RequestURL.You are now ready to start the call using cURL:bashcurl -L -X POST https://{SpaceName}.signalwire.com/api/laml/2010-04-01/Accounts/{ProjectID}/Calls \ -H Content-Type: application/x-www-form-urlencoded \ -H Accept: application/json \ -u {ProjectID}:{APIToken} \ --data-urlencode Url=https://{BinRequestURL} \ --data-urlencode From={+XXXXXXXXXX} \ --data-urlencode To={+YYYYYYYYYY}Make sure to replace all occurrences of {SpaceName}, {ProjectID},{APIToken}, {BinRequestURL}, {+XXXXXXXXXX}, and {+YYYYYYYYYY} withyour actual values.:::noteInstead of your own bin, feel free to try one of ours: .:::Congratulations! Once the cURL request is executed, your personal phone number({+YYYYYYYYYY}) will start ringing.## Receiving incoming calls {#receiving-incoming-calls}To handle incoming calls we need to configure the phone number in our[SignalWire space](https://signalwire.com/signin) to answer calls using an XMLbin.Take note of the Request URL for the bin that we created in the previoussection. You can even create a new bin if you want to define a differentbehavior for incoming calls.Click the Phone Numbers section within your SignalWire space, and select the specific number you would like to use to answer calls. The same number we used before can work. To configure your number to handle incoming calls with an XML bin, set Handle calls using to LaML Webhooks, then specify the URL of the XML bin. Make sure that _Accept Calls As_ is set to _Voice Calls_, _Handle Calls Using_ is set to _LaML Webhooks_, and paste your Bin URL in as the value for _When a Call Comes In_. Click _Save_, and youre done! Inbound calls to this SignalWire number will execute the specified bin.# Wrapping upXML bins allow you to program the behavior of phone calls, and REST APIs make iteasy to trigger calls to any phone number. Find the documentation for ourCompatibility API (XML and REST) [here](docs/compatibility-api/xml/index.mdx).As we have seen, REST APIs are easy to get started with. In case you need moreflexibility and real-time control on your calls, you may be interested in ourguide about how to [make and receive calls in Node.js](guides/voice-api/guides/realtime-api/first-steps-with-voice/index.mdx).