# Send an SMS Message with Python SDK

Note:
Before you can get started, you need the following already set up:

* 
* [Python](https://www.python.org/) and a familiarity with how to create a new file.
* [Poetry](https://python-poetry.org/) for dependency management.
* [PIP (package installer for Python)](https://pypi.org/project/pip/) and a familiarity with how to install Python modules.


Learn how to quickly send SMS messages in a Python application with the Sinch SMS API.

## Set up your Python application

To quickly get started setting up a simple client application using the Python SDK:

1. If you haven't already, clone the [sinch-sdk-python](https://github.com/sinch/sinch-sdk-python) repository.
2. Navigate to the `examples/snippets` folder.
3. Copy the example `.env` file by running the following command:


Linux/Mac
```bash
cp .env.example .env
```

Windows (Command Prompt)
```cmd
copy .env.example .env
```

Windows (Powershell)
```powershell
Copy-Item .env.example .env
```

1. Open the `.env` [file](https://github.com/sinch/sinch-sdk-python/blob/main/examples/snippets/.env.example) you just created. Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, populate the following fields with your values:


| Field | Description |
|  --- | --- |
| SINCH_PROJECT_ID | The unique ID of your Project. |
| SINCH_KEY_ID | The unique ID of your access key. |
| SINCH_KEY_SECRET | The secret that goes with your access key.  **Note:** For security reasons, this secret is only visible right after access key creation. |


1. Save the file.
2. The Python SDK uses [Poetry](https://python-poetry.org/) to manage packages and dependencies, so install those dependencies using the following command:


```cmd
poetry install
```

## Modify your code

1. Navigate to `examples/snippets/sms/batches/send_sms/` and open the `snippet.py` file.


snippet.py
```python snippet.py
"""
Sinch Python Snippet

This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
"""

import os
from dotenv import load_dotenv
from sinch import SinchClient

load_dotenv()

sinch_client = SinchClient(
    project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
    key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
    key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
    sms_region=os.environ.get("SINCH_SMS_REGION") or "MY_SMS_REGION"
)

response = sinch_client.sms.batches.send_sms(
    to=["+1234567890"],
    from_="+2345678901",
    body="Hello, this is a test message!"
)

print(f"Batch sent:\n{response}")
```

br
This code initializes the Sinch Client and then sends a message using the `batches` class.

1. Assign your values to the following parameters:


| Parameter | Your value |
|  --- | --- |
| `from_` | Any number you've assigned to your Sinch account. Find the number on your Customer [Dashboard](https://dashboard.sinch.com/sms/api/rest) by clicking the service plan ID link and scrolling to the bottom of the page. |
| `to` | The phone number to which you want to send the test SMS message. |


1. Save the file.


## Send your first SMS message

Now you can execute the code and send your test SMS message. Navigate to `examples/snippets/sms/batches/send_sms/` and run the following command:

```shell
python snippet.py
```

## Next steps

The code you used in the `snippet.py` file uses the Sinch SDK `batches` endpoint to send the SMS message.

- Click [here to learn more about the batches endpoint](/docs/sms/sdks/python/syntax-reference/#batches-endpoint-category/).
- [Learn how to recieve SMS](/docs/sms/getting-started/python/receive-sms-sdk)


## Additional resources

- Visit our [API specification](/docs/sms/api-reference/) to test more endpoints.