> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracklysms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Your First SMS

> Send an SMS message via the API in under 5 minutes

This quickstart walks you through sending your first SMS message using the Trackly SMS API.

## Prerequisites

<Check>A Trackly SMS account with an active API key</Check>
<Check>A configured sending list with a phone number</Check>
<Check>A test phone number to receive the message</Check>

Don't have these yet? See the [dashboard quickstart](/getting-started/quickstart) first.

## Step 1: Get Your API Key

1. Log into the [Trackly SMS Dashboard](https://app.tracklysms.com)
2. Go to **Settings > API Keys**
3. Copy your API key (or create one if you haven't)

<Warning>
  Keep your API key secret. Never commit it to version control.
</Warning>

## Step 2: Find Your Sending List Phone Number

1. Navigate to **Lists** in the dashboard
2. Click on your sending list
3. Copy the **Phone Number** in E.164 format (e.g., `+18005551234`)

## Step 3: Send a Message

Choose your preferred language:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.tracklysms.com/api/v2/send \
    -H "X-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "to": "+14155551234",
      "body": "Hello from Trackly SMS! This is my first message.",
      "list_number": "+18005551234"
    }'
  ```

  ```python Python theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"
  LIST_NUMBER = "+18005551234"  # Your sending list phone number

  response = requests.post(
      "https://api.tracklysms.com/api/v2/send",
      headers={
          "X-Api-Key": API_KEY,
          "Content-Type": "application/json"
      },
      json={
          "to": "+14155551234",  # Replace with your test number
          "body": "Hello from Trackly SMS! This is my first message.",
          "list_number": LIST_NUMBER
      }
  )

  if response.status_code == 201:
      result = response.json()
      print(f"Message queued! ID: {result['message_id']}")
  else:
      print(f"Error: {response.json()}")
  ```

  ```javascript Node.js theme={null}
  const API_KEY = "YOUR_API_KEY";
  const LIST_NUMBER = "+18005551234"; // Your sending list phone number

  const response = await fetch("https://api.tracklysms.com/api/v2/send", {
    method: "POST",
    headers: {
      "X-Api-Key": API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      to: "+14155551234", // Replace with your test number
      body: "Hello from Trackly SMS! This is my first message.",
      list_number: LIST_NUMBER,
    }),
  });

  const result = await response.json();
  if (result.success) {
    console.log("Message queued! ID:", result.message_id);
  } else {
    console.error("Error:", result.error);
  }
  ```

  ```php PHP theme={null}
  <?php

  $apiKey = 'YOUR_API_KEY';
  $listNumber = '+18005551234'; // Your sending list phone number

  $data = [
      'to' => '+14155551234', // Replace with your test number
      'body' => 'Hello from Trackly SMS! This is my first message.',
      'list_number' => $listNumber
  ];

  $ch = curl_init('https://api.tracklysms.com/api/v2/send');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'X-Api-Key: ' . $apiKey,
      'Content-Type: application/json'
  ]);

  $response = curl_exec($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode === 201) {
      $result = json_decode($response, true);
      echo "Message queued! ID: " . $result['message_id'];
  } else {
      echo "Error: " . $response;
  }
  ```
</CodeGroup>

## Step 4: Check the Response

A successful response looks like:

```json theme={null}
{
  "success": true,
  "message_id": "AbC12345",
  "status": "queued"
}
```

Your message is now queued and will be delivered within seconds!

## Common Issues

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    Your API key is missing or invalid.

    **Solution**: Check that you're including the `X-Api-Key` header and the key is correct.
  </Accordion>

  <Accordion title="400 Invalid phone number">
    The phone number format is incorrect.

    **Solution**: Use E.164 format with country code (e.g., `+14155551234`)
  </Accordion>

  <Accordion title="400 Sending list not found">
    The `list_number` doesn't match any active sending list in your account.

    **Solution**: Check the phone number in your Lists dashboard. It must be in E.164 format (e.g., `+18005551234`).
  </Accordion>

  <Accordion title="Message not received">
    * Verify the recipient number is correct
    * Check if the number can receive SMS (not a landline)
    * Look for delivery status in the dashboard
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Send Bulk Messages" icon="layer-group" href="/api-reference/v2/messages/send-bulk">
    Send up to 1,000 messages at once
  </Card>

  <Card title="Build an Audience" icon="users" href="/quickstarts/create-audience">
    Segment your contacts for targeting
  </Card>

  <Card title="Set Up Alerts" icon="bell" href="/integrations/discord-alerts">
    Get notified of delivery failures
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore all API endpoints
  </Card>
</CardGroup>
